From: Jens Axboe Date: Sat, 1 Mar 2008 14:12:14 +0000 (+0100) Subject: Fix recursive dump of options X-Git-Tag: fio-1.20-rc1~32 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=323d9113db91a8fb2efe93b9916c22f74ff9af3f Fix recursive dump of options If a child also had a child, we would miss it. Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index 3c203121..f9e0ebee 100644 --- a/parse.c +++ b/parse.c @@ -579,10 +579,11 @@ static struct fio_option *find_child(struct fio_option *options, return NULL; } -static void print_option(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; + int depth; if (!o) return; @@ -590,13 +591,37 @@ static void print_option(struct fio_option *o, struct fio_option *org, org = o; p = name; - if (level) - p += sprintf(p, "%s", " "); + depth = level; + while (depth--) + p += sprintf(p, "%s", " "); sprintf(p, "%s", o->name); printf("%-24s: %s\n", name, o->help); - print_option(find_child(o, org), org, level + 1); +} + +static void print_option(struct fio_option *o) +{ + struct fio_option *parent; + struct fio_option *__o; + unsigned int printed; + unsigned int level; + + __print_option(o, NULL, 0); + parent = o; + level = 0; + do { + level++; + printed = 0; + + while ((__o = find_child(o, parent)) != NULL) { + __print_option(__o, o, level); + o = __o; + printed++; + } + + parent = o; + } while (printed); } int show_cmd_help(struct fio_option *options, const char *name) @@ -635,7 +660,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) - print_option(o, NULL, 0); + print_option(o); continue; } }