engines/mmap: fix segfault on large devices and 32-bit archs
[fio.git] / init.c
diff --git a/init.c b/init.c
index 4f66759b59b551ea0364231c45e7e61110b85ca0..f606087e42c942e565314f20a57a038be2535d68 100644 (file)
--- a/init.c
+++ b/init.c
@@ -926,7 +926,13 @@ static void init_flags(struct thread_data *td)
                td->flags |= TD_F_READ_IOLOG;
        if (o->refill_buffers)
                td->flags |= TD_F_REFILL_BUFFERS;
-       if (o->scramble_buffers)
+       /*
+        * Scramble by default, but not if zero_buffer is true and has been
+        * set. But if scramble_buffers has been set, always scramble.
+        */
+       if (o->scramble_buffers && ((!o->zero_buffers &&
+           fio_option_is_set(o, zero_buffers)) ||
+           fio_option_is_set(o, scramble_buffers)))
                td->flags |= TD_F_SCRAMBLE_BUFFERS;
        if (o->verify != VERIFY_NONE)
                td->flags |= TD_F_VER_NONE;
@@ -1875,6 +1881,30 @@ static void parse_cmd_client(void *client, char *opt)
        fio_client_add_cmd_option(client, opt);
 }
 
+static void show_closest_option(const char *name)
+{
+       int best_option, best_distance;
+       int i, distance;
+
+       while (*name == '-')
+               name++;
+
+       best_option = -1;
+       best_distance = INT_MAX;
+       i = 0;
+       while (l_opts[i].name) {
+               distance = string_distance(name, l_opts[i].name);
+               if (distance < best_distance) {
+                       best_distance = distance;
+                       best_option = i;
+               }
+               i++;
+       }
+
+       if (best_option != -1)
+               log_err("Did you mean %s?\n", l_opts[best_option].name);
+}
+
 int parse_cmd_line(int argc, char *argv[], int client_type)
 {
        struct thread_data *td = NULL;
@@ -2237,6 +2267,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                case '?':
                        log_err("%s: unrecognized option '%s'\n", argv[0],
                                                        argv[optind - 1]);
+                       show_closest_option(argv[optind - 1]);
                default:
                        do_exit++;
                        exit_val = 1;