Rebased from upstream / out of band repository.
[librecmc/librecmc.git] / package / network / config / swconfig / src / swlib.c
index e6e9aead474b5f2177d316a68dad0161b6e952b4..0e09a1505ba249df03db7a7b659fa13e85b22c66 100644 (file)
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include <inttypes.h>
 #include <errno.h>
 #include <stdint.h>
@@ -92,7 +93,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 +106,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;
        }