From: Jens Axboe Date: Sat, 6 Dec 2014 16:17:52 +0000 (-0700) Subject: options: show closest match for unknown job option X-Git-Tag: fio-2.2.0~33 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=a2d027b9d2a419c207a18b982145f4b6e11e1bd7;p=fio.git options: show closest match for unknown job option Just like we did for the command line options. Signed-off-by: Jens Axboe --- diff --git a/options.c b/options.c index c3c62927..98f4b2b0 100644 --- a/options.c +++ b/options.c @@ -3933,6 +3933,27 @@ static char **dup_and_sub_options(char **opts, int num_opts) return opts_copy; } +static void show_closest_option(const char *name) +{ + int best_option, best_distance; + int i, distance; + + best_option = -1; + best_distance = INT_MAX; + i = 0; + while (fio_options[i].name) { + distance = string_distance(name, fio_options[i].name); + if (distance < best_distance) { + best_distance = distance; + best_option = i; + } + i++; + } + + if (best_option != -1) + log_err("Did you mean %s?\n", fio_options[best_option].name); +} + int fio_options_parse(struct thread_data *td, char **opts, int num_opts, int dump_cmdline) { @@ -3968,6 +3989,7 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts, for (i = 0; i < num_opts; i++) { struct fio_option *o = NULL; int newret = 1; + if (!opts_copy[i]) continue; @@ -3977,9 +3999,10 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts, td->eo, dump_cmdline); ret |= newret; - if (!o) + if (!o) { log_err("Bad option <%s>\n", opts[i]); - + show_closest_option(opts[i]); + } free(opts_copy[i]); opts_copy[i] = NULL; }