From 79ab3841364336d8f2e9462a2e271411f6de0da3 Mon Sep 17 00:00:00 2001 From: tonton th Date: Thu, 18 Jun 2020 23:43:41 +0200 Subject: [PATCH] better use of bad arguments --- tools/fimgstats.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/fimgstats.c b/tools/fimgstats.c index f3a9286..dd14771 100644 --- a/tools/fimgstats.c +++ b/tools/fimgstats.c @@ -96,15 +96,20 @@ if (argc == 1) { exit(0); } -while ((opt = getopt(argc, argv, "cv")) != -1) { +while ((opt = getopt(argc, argv, "chv")) != -1) { switch(opt) { case 'c': make_csv++; break; case 'v': verbosity++; break; + case 'h': /* tombe dedans */ default: help(1); exit(1); } } +if (NULL==argv[optind]) { + fprintf(stderr, "optind %d is wtf\n", optind); + return 1; + } foo = various_numbers_from_file(argv[optind], 0); if (foo) { fprintf(stderr, "got a %d ?\n", foo);