Ensure that command line options also end up in json output
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 0ef00b81cda60ffb6209a0c3b305b370aeee8810..ac1bee9c296ece240613d8759725aa2efe2b4233 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -960,8 +960,27 @@ void sort_options(char **opts, struct fio_option *options, int num_opts)
        __fio_options = NULL;
 }
 
+static void add_to_dump_list(struct fio_option *o, struct flist_head *dump_list,
+                            const char *post)
+{
+       struct print_option *p;
+
+       if (!dump_list)
+               return;
+
+       p = malloc(sizeof(*p));
+       p->name = strdup(o->name);
+       if (post)
+               p->value = strdup(post);
+       else
+               p->value = NULL;
+
+       flist_add_tail(&p->list, dump_list);
+}
+
 int parse_cmd_option(const char *opt, const char *val,
-                    struct fio_option *options, void *data)
+                    struct fio_option *options, void *data,
+                    struct flist_head *dump_list)
 {
        struct fio_option *o;
 
@@ -971,11 +990,13 @@ int parse_cmd_option(const char *opt, const char *val,
                return 1;
        }
 
-       if (!handle_option(o, val, data))
-               return 0;
+       if (handle_option(o, val, data)) {
+               log_err("fio: failed parsing %s=%s\n", opt, val);
+               return 1;
+       }
 
-       log_err("fio: failed parsing %s=%s\n", opt, val);
-       return 1;
+       add_to_dump_list(o, dump_list, val);
+       return 0;
 }
 
 int parse_option(char *opt, const char *input,
@@ -1006,18 +1027,7 @@ int parse_option(char *opt, const char *input,
                return 1;
        }
 
-       if (dump_list) {
-               struct print_option *p = malloc(sizeof(*p));
-
-               p->name = strdup((*o)->name);
-               if (post)
-                       p->value = strdup(post);
-               else
-                       p->value = NULL;
-
-               flist_add_tail(&p->list, dump_list);
-       }
-
+       add_to_dump_list(*o, dump_list, post);
        return 0;
 }