From 898f3a4d2f804b8b0fc0976d2b17dcde18118c42 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 18 Feb 2016 17:09:04 +0100 Subject: [PATCH] nfc-mfclassic: check argc < 4 only once 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 --- utils/nfc-mfclassic.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 333f710..f9a27b5 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -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; @@ -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;