Skip to content

Commit

Permalink
nfc-mfultralight: Show help when no arguments are supplied
Browse files Browse the repository at this point in the history
For some reason, 0cece94 changed the argc count check to only show
the help if argc is 0. Obviously, argc is never zero, as the first
argument in argv is always the binary itself. Revert that and show usage
if there is no arguments supplied to the binary.

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed May 11, 2016
1 parent e1a25a8 commit 7b1ff70
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/nfc-mfultralight.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ main(int argc, const char *argv[])
bool bUID = false;
FILE *pfDump;

if (argc == 0) {
if (argc < 2) {
print_usage(argv);
exit(EXIT_FAILURE);
}
Expand Down

2 comments on commit 7b1ff70

@quantum-x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliv3r This change was put in place to allow for single switches to work, ie:
--check-magic
Apparently it was placed incorrectly, but your re-addition of the < 2 breaks / broke the --check-magic switch.

Suggest we need
a) Updated Tests
b) Better command line processing

@smortex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quantum-x agree! getopt(3) and getopt_long(3) where designed for this. Using these functions we could be able to detect no arguments, -h and invalid arguments and act accordingly in a more readable fashion.

Would someone mind proposing a pull-request for improving the command-line processing (patches for unit tests are accepted as well of course but requires waaaaaays more work 😄)?

Please sign in to comment.