Exit on bad command line options
authorJens Axboe <jens.axboe@oracle.com>
Mon, 18 Feb 2008 19:26:32 +0000 (20:26 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 18 Feb 2008 19:26:32 +0000 (20:26 +0100)
It could be dangerous, eg if you expected --read-only to do its job
when you really needed to type --readonly.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c

diff --git a/init.c b/init.c
index f5dff5059dabd76b6477a2a074de1ec42a79a3dc..e96b4102e122bde922d7ebb47360bbdabedbe01c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -837,7 +837,7 @@ static void set_debug(const char *string)
 static int parse_cmd_line(int argc, char *argv[])
 {
        struct thread_data *td = NULL;
-       int c, ini_idx = 0, lidx, ret, dont_add_job = 0;
+       int c, ini_idx = 0, lidx, ret, dont_add_job = 0, bad_options = 0;
 
        while ((c = getopt_long_only(argc, argv, "", long_options, &lidx)) != -1) {
                switch (c) {
@@ -914,10 +914,14 @@ static int parse_cmd_line(int argc, char *argv[])
                        break;
                }
                default:
+                       bad_options++;
                        break;
                }
        }
 
+       if (bad_options)
+               exit(1);
+
        if (td) {
                if (dont_add_job)
                        put_job(td);