swconfig: fix un-initialized return value
authorAlexander Couzens <lynxis@fe80.eu>
Fri, 29 Jun 2018 03:27:16 +0000 (05:27 +0200)
committerAlexander Couzens <lynxis@fe80.eu>
Fri, 29 Jun 2018 03:45:20 +0000 (05:45 +0200)
Fix CID 1330844

Found-by: Coverity
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
package/network/config/swconfig/src/swlib.c

index e6e9aead474b5f2177d316a68dad0161b6e952b4..0fb8ebb392c63f6e8a659d5645d22ccc257adc46 100644 (file)
@@ -92,7 +92,7 @@ swlib_call(int cmd, int (*call)(struct nl_msg *, void *),
        struct nl_cb *cb = NULL;
        int finished;
        int flags = 0;
-       int err;
+       int err = 0;
 
        msg = nlmsg_alloc();
        if (!msg) {
@@ -105,7 +105,8 @@ swlib_call(int cmd, int (*call)(struct nl_msg *, void *),
 
        genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, genl_family_get_id(family), 0, flags, cmd, 0);
        if (data) {
-               if (data(msg, arg) < 0)
+               err = data(msg, arg);
+               if (err < 0)
                        goto nla_put_failure;
        }