Skip to content

Commit

Permalink
nfc-mfclassic: check argc < 4 only once
Browse files Browse the repository at this point in the history
Currently the check on argc is done twice, once in each if branch. This
is silly and we can just check once and fail right away.

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed May 11, 2016
1 parent 83b70d6 commit 898f3a4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions utils/nfc-mfclassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,11 @@ main(int argc, const char *argv[])
}
const char *command = argv[1];

if (argc < 4) {
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
if (strcmp(command, "r") == 0 || strcmp(command, "R") == 0) {
if (argc < 4) {
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
atAction = ACTION_READ;
if (strcmp(command, "R") == 0)
unlock = 1;
Expand All @@ -539,10 +539,6 @@ main(int argc, const char *argv[])
bUseKeyFile = (argc > 4);
bForceKeyFile = ((argc > 5) && (strcmp((char *)argv[5], "f") == 0));
} else if (strcmp(command, "w") == 0 || strcmp(command, "W") == 0 || strcmp(command, "f") == 0) {
if (argc < 4) {
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
atAction = ACTION_WRITE;
if (strcmp(command, "W") == 0)
unlock = 1;
Expand Down

0 comments on commit 898f3a4

Please sign in to comment.