X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=parse.c;h=ad2b1e3c76cf9a3691a7466598de6823b8064b20;hb=d091d099aa867596745f2fa0d58631a14a746520;hp=cbe8e35f2bd7e9fc5c5785c5d2afe77c95f341ca;hpb=b62bdf2c3e8877c276796d1ed7909df194fc846c;p=fio.git diff --git a/parse.c b/parse.c index cbe8e35f..ad2b1e3c 100644 --- a/parse.c +++ b/parse.c @@ -289,7 +289,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, fio_opt_str_fn *fn = o->cb; const struct value_pair *vp; struct value_pair posval[PARSE_MAX_VP]; - int i; + int i, all_skipped = 1; posval_sort(o, posval); @@ -298,6 +298,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, vp = &posval[i]; if (!vp->ival || vp->ival[0] == '\0') continue; + all_skipped = 0; if (!strncmp(vp->ival, ptr, strlen(vp->ival))) { ret = 0; if (o->roff1) { @@ -314,7 +315,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, } } - if (ret) + if (ret && !all_skipped) show_option_values(o); else if (fn) ret = fn(data, ptr); @@ -351,13 +352,13 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (o->type == FIO_OPT_INT) { if (first) { if (o->roff1) - *(unsigned long long *) o->roff1 = ull; + *(unsigned int *) o->roff1 = ull; else val_store(ilp, ull, o->off1, 0, data); } if (!more) { if (o->roff2) - *(unsigned long long *) o->roff2 = ull; + *(unsigned int *) o->roff2 = ull; else if (o->off2) val_store(ilp, ull, o->off2, 0, data); } @@ -428,17 +429,17 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (first) { if (o->roff1) - *(unsigned long *) o->roff1 = ul1; + *(unsigned int *) o->roff1 = ul1; else val_store(ilp, ul1, o->off1, 0, data); if (o->roff2) - *(unsigned long *) o->roff2 = ul2; + *(unsigned int *) o->roff2 = ul2; else val_store(ilp, ul2, o->off2, 0, data); } if (o->roff3 && o->roff4) { - *(unsigned long *) o->roff3 = ul1; - *(unsigned long *) o->roff4 = ul2; + *(unsigned int *) o->roff3 = ul1; + *(unsigned int *) o->roff4 = ul2; } else if (o->off3 && o->off4) { val_store(ilp, ul1, o->off3, 0, data); val_store(ilp, ul2, o->off4, 0, data); @@ -836,7 +837,7 @@ static void print_option(struct fio_option *o) int show_cmd_help(struct fio_option *options, const char *name) { struct fio_option *o, *closest; - unsigned int best_dist; + unsigned int best_dist = -1U; int found = 0; int show_all = 0; @@ -889,7 +890,12 @@ int show_cmd_help(struct fio_option *options, const char *name) return 0; printf("No such command: %s", name); - if (closest) { + + /* + * Only print an appropriately close option, one where the edit + * distance isn't too big. Otherwise we get crazy matches. + */ + if (closest && best_dist < 3) { printf(" - showing closest match\n"); printf("%20s: %s\n", closest->name, closest->help); show_option_help(closest, stdout);