parse: fix wrong "might be used unitialized" warning on some compilers
authorJens Axboe <axboe@kernel.dk>
Thu, 29 Nov 2012 20:33:03 +0000 (21:33 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Nov 2012 20:33:03 +0000 (21:33 +0100)
GCC 3.4.3 on Solaris, I'm looking at you. Apparently:

if (a || b) {
if (a)
c = foo;
else if (b)
c = bar;

*c = foobar;
}

is too hard to figure out.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
parse.c

diff --git a/parse.c b/parse.c
index 0bbb0b30dafd5c8b57ac842e28bdaeba789c6022..13783fa6d60c06f1df0fb82dcaf18ac2636750ae 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -361,7 +361,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
        long long ull, *ullp;
        long ul1, ul2;
        double uf;
-       char **cp;
+       char **cp = NULL;
        int ret = 0, is_time = 0;
        const struct value_pair *vp;
        struct value_pair posval[PARSE_MAX_VP];
@@ -536,8 +536,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                cp = td_var(data, o->off1);
 
                        *cp = strdup(ptr);
-               } else {
-                       cp = NULL;
                }
 
                if (fn)