git: 430168942f2b - main - newfs: prefer unsigned index over signed
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Jun 2023 22:20:03 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=430168942f2bf68b0230906a658a0ceb7acceef2 commit 430168942f2bf68b0230906a658a0ceb7acceef2 Author: Alfonso Gregory <gfunni234@gmail.com> AuthorDate: 2023-06-28 22:14:07 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-06-28 22:18:47 +0000 newfs: prefer unsigned index over signed We can just use a for loop starting at 0 instead of a while loop starting at -1. Reviewed by: imp, mckusick Pull Request: https://github.com/freebsd/freebsd-src/pull/733 --- sbin/newfs/newfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index a2d97131d3a7..2dbd27ce2a0f 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -137,7 +137,8 @@ main(int argc, char *argv[]) struct stat st; char *cp, *special; intmax_t reserved; - int ch, i, rval; + int ch, rval; + size_t i; char part_name; /* partition name, default to full disk */ part_name = 'c'; @@ -153,9 +154,10 @@ main(int argc, char *argv[]) break; case 'L': volumelabel = optarg; - i = -1; - while (isalnum(volumelabel[++i]) || - volumelabel[i] == '_' || volumelabel[i] == '-'); + for (i = 0; isalnum(volumelabel[i]) || + volumelabel[i] == '_' || volumelabel[i] == '-'; + i++) + continue; if (volumelabel[i] != '\0') { errx(1, "bad volume label. Valid characters " "are alphanumerics, dashes, and underscores.");