ctdb-tool: Avoid data uninitialized warnings
authorAmitay Isaacs <amitay@gmail.com>
Tue, 18 Dec 2018 00:33:30 +0000 (11:33 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 18 Dec 2018 06:12:09 +0000 (07:12 +0100)
../../tools/ctdb.c: In function 'str_to_data':
../../tools/ctdb.c:624: warning: 'data.dsize' may be used uninitialized in this function
../../tools/ctdb.c:624: warning: 'data.dptr' may be used uninitialized in this function

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tools/ctdb.c

index b598a866c9bd3ab6c090182608e33310fcffe09d..eb4c684e8b083423ad427705b38c79f56a56c44f 100644 (file)
@@ -626,6 +626,9 @@ static int str_to_data(const char *str, size_t len, TALLOC_CTX *mem_ctx,
 
        if (strncmp(str, "0x", 2) == 0) {
                ret = hex_to_data(str+2, len-2, mem_ctx, &data);
+               if (ret != 0) {
+                       return ret;
+               }
        } else {
                data.dptr = talloc_memdup(mem_ctx, str, len);
                if (data.dptr == NULL) {
@@ -635,7 +638,7 @@ static int str_to_data(const char *str, size_t len, TALLOC_CTX *mem_ctx,
        }
 
        *out = data;
-       return ret;
+       return 0;
 }
 
 static int run_helper(TALLOC_CTX *mem_ctx, const char *command,