Make the 'closest option' print a bit better
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index fb5d45798d2bdf933ffb20beb87cb49d641d49c4..ad2b1e3c76cf9a3691a7466598de6823b8064b20 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -352,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);
                                }
@@ -429,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);
@@ -837,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;
 
@@ -890,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);