X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=parse.c;h=90874f1642c792917d4081b73362199337e627b3;hb=97e8cd444561ef03dd65c6c3c37c934796a4993f;hp=962538c066ecace330da6ebb1a946b4294a003e2;hpb=afdf935261b23cdf08214e708133318548ddf2c4;p=fio.git diff --git a/parse.c b/parse.c index 962538c0..90874f16 100644 --- a/parse.c +++ b/parse.c @@ -106,7 +106,7 @@ static unsigned long get_mult_bytes(char c) /* * convert string into decimal value, noting any size suffix */ -static int str_to_decimal(const char *str, long long *val, int kilo) +int str_to_decimal(const char *str, long long *val, int kilo) { int len; @@ -188,7 +188,7 @@ static int check_int(const char *p, int *val) { if (!strlen(p)) return 1; - if (strstr(p, "0x")) { + if (strstr(p, "0x") || strstr(p, "0X")) { if (sscanf(p, "%x", val) == 1) return 0; } else { @@ -350,7 +350,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, val_store(ilp, ul1, o->off1, data); val_store(ilp, ul2, o->off2, data); } - if (!more && o->off3 && o->off4) { + if (o->off3 && o->off4) { val_store(ilp, ul1, o->off3, data); val_store(ilp, ul2, o->off4, data); } @@ -566,30 +566,31 @@ static struct fio_option *find_child(struct fio_option *options, { struct fio_option *__o; - for (__o = &options[0]; __o->name; __o++) + for (__o = options + 1; __o->name; __o++) if (__o->parent && !strcmp(__o->parent, o->name)) return __o; return NULL; } -static void print_option(struct fio_option *options, struct fio_option *o, +static void print_option(struct fio_option *o, struct fio_option *org, int level) { char name[256], *p; - int i; if (!o) return; + if (!org) + org = o; p = name; - for (i = 0; i < level; i++) + if (level) p += sprintf(p, "%s", " "); sprintf(p, "%s", o->name); printf("%-24s: %s\n", name, o->help); - print_option(options, find_child(options, o), level + 1); + print_option(find_child(o, org), org, level + 1); } int show_cmd_help(struct fio_option *options, const char *name) @@ -628,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) - print_option(options, o, 0); + print_option(o, NULL, 0); continue; } }