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
This commit is contained in:
Alfonso Gregory 2023-06-28 16:14:07 -06:00 committed by Warner Losh
parent 31b3e4f1b4
commit 430168942f

View File

@ -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.");