Be a little more clever in finding child options
authorJens Axboe <jens.axboe@oracle.com>
Tue, 31 Jul 2007 21:06:09 +0000 (23:06 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 31 Jul 2007 21:06:09 +0000 (23:06 +0200)
We don't need ->parent_seen, just start from the next option.

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

diff --git a/parse.c b/parse.c
index ffe435a44f2b86a9e9463b2933431dcb1ddc46f1..b40d51c754d76c3d87b62c72ce89adee7f7a8b13 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -566,19 +566,15 @@ static struct fio_option *find_child(struct fio_option *options,
 {
        struct fio_option *__o;
 
 {
        struct fio_option *__o;
 
-       for (__o = &options[0]; __o->name; __o++) {
-               if (__o->parent && !strcmp(__o->parent, o->name)
-                   && !__o->parent_seen) {
-                       __o->parent_seen = 1;
+       for (__o = options + 1; __o->name; __o++)
+               if (__o->parent && !strcmp(__o->parent, o->name))
                        return __o;
                        return __o;
-               }
-       }
 
        return NULL;
 }
 
 
        return NULL;
 }
 
-static void print_option(struct fio_option *options, struct fio_option *o,
-                        struct fio_option *org, int level)
+static void print_option(struct fio_option *o, struct fio_option *org,
+                        int level)
 {
        char name[256], *p;
 
 {
        char name[256], *p;
 
@@ -594,7 +590,7 @@ static void print_option(struct fio_option *options, struct fio_option *o,
        sprintf(p, "%s", o->name);
 
        printf("%-24s: %s\n", name, o->help);
        sprintf(p, "%s", o->name);
 
        printf("%-24s: %s\n", name, o->help);
-       print_option(options, find_child(options, org), org, level + 1);
+       print_option(find_child(o, org), org, level + 1);
 }
 
 int show_cmd_help(struct fio_option *options, const char *name)
 }
 
 int show_cmd_help(struct fio_option *options, const char *name)
@@ -633,7 +629,7 @@ int show_cmd_help(struct fio_option *options, const char *name)
                                printf("%24s: %s\n", o->name, o->help);
                        if (show_all) {
                                if (!o->parent)
                                printf("%24s: %s\n", o->name, o->help);
                        if (show_all) {
                                if (!o->parent)
-                                       print_option(options, o, NULL, 0);
+                                       print_option(o, NULL, 0);
                                continue;
                        }
                }
                                continue;
                        }
                }
diff --git a/parse.h b/parse.h
index 36ff2b2357d673cd07134bbe7751a441b8ea4462..c3b66d75be34216ff1f3df33b85db9d7779ef6c6 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -46,7 +46,6 @@ struct fio_option {
        const char *def;                /* default setting */
        const struct value_pair posval[PARSE_MAX_VP];/* possible values */
        const char *parent;             /* parent option */
        const char *def;                /* default setting */
        const struct value_pair posval[PARSE_MAX_VP];/* possible values */
        const char *parent;             /* parent option */
-       char parent_seen;
 };
 
 typedef int (str_cb_fn)(void *, char *);
 };
 
 typedef int (str_cb_fn)(void *, char *);