fsck: fix strange logic

llvm warns about the confusingly written comparison:

                              !strncmp(argv[i+1], "-", 1) == 0) {
    misc/fsck.c:1178 col 9: warning: logical not is only applied to
      the left hand side of comparison [-Wlogical-not-parentheses]
    misc/fsck.c:1178 col 9: note: add parentheses after the '!' to
      evaluate the comparison first
    misc/fsck.c:1178 col 9: note: add parentheses around left hand
      side expression to silence this warning

It makes sense to simplify this to a character comparison rather
than using strncmp() to check only one character.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
maint
Andreas Dilger 2016-08-10 18:21:19 -04:00 committed by Theodore Ts'o
parent 127e2291bf
commit 713edbd082
1 changed files with 2 additions and 2 deletions

View File

@ -1174,8 +1174,8 @@ static void PRS(int argc, char *argv[])
progress_fd = 0;
else
goto next_arg;
} else if ((i+1) < argc &&
!strncmp(argv[i+1], "-", 1) == 0) {
} else if (argc > i + 1 &&
argv[i + 1][0] != '-') {
progress_fd = string_to_int(argv[i]);
if (progress_fd < 0)
progress_fd = 0;