Micro-optimize __load_ioengine()
authorBart Van Assche <bvanassche@acm.org>
Wed, 1 Jan 2020 00:31:26 +0000 (16:31 -0800)
committerBart Van Assche <bvanassche@acm.org>
Wed, 1 Jan 2020 16:58:50 +0000 (08:58 -0800)
Instead of copying the I/O engine name, use a pointer to the I/O engine
name. This patch suppresses the following false positive Valgrind complaint:

Conditional jump or move depends on uninitialised value(s)
   at 0x41D451: __load_ioengine (ioengines.c:133)
   by 0x41D451: load_ioengine (ioengines.c:161)
   by 0x41FA59: ioengine_load (init.c:1126)
   by 0x423B64: parse_cmd_line (init.c:2670)
   by 0x4241A3: parse_options (init.c:2965)
   by 0x40F587: main (fio.c:42)

The code for copying I/O engine names was introduced by commit 2866c82d598e
("[PATCH] Separate io engines into separate loadable objects").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
ioengines.c

index 9e3fcc9f681a46fa336ef247a6aa6497dade09af..b9200ba9223488923ed2cc879d58971c31c70dab 100644 (file)
@@ -121,18 +121,15 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
        return ops;
 }
 
-static struct ioengine_ops *__load_ioengine(const char *name)
+static struct ioengine_ops *__load_ioengine(const char *engine)
 {
-       char engine[64];
-
-       snprintf(engine, sizeof(engine), "%s", name);
-
        /*
         * linux libaio has alias names, so convert to what we want
         */
        if (!strncmp(engine, "linuxaio", 8)) {
-               dprint(FD_IO, "converting ioengine name: %s -> libaio\n", name);
-               strcpy(engine, "libaio");
+               dprint(FD_IO, "converting ioengine name: %s -> libaio\n",
+                      engine);
+               engine = "libaio";
        }
 
        dprint(FD_IO, "load ioengine %s\n", engine);