]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
options: Fix a static analysis error
authorRoy Marples <roy@marples.name>
Mon, 22 Jul 2019 10:49:54 +0000 (11:49 +0100)
committerRoy Marples <roy@marples.name>
Mon, 22 Jul 2019 10:49:54 +0000 (11:49 +0100)
Can't actually happen because the string doesn't change and the
result is already checked above. However, it's pretty harmless to
add.

src/if-options.c

index d880e0e34b7144878ac66f0b41b536e49080c247..d2c82a3a816a2a294eb2c9284cf86605db30a105 100644 (file)
@@ -719,9 +719,6 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                if (s == 0) {
                        ifo->script = NULL;
                        break;
-               } else if (s == -1) {
-                       logerr("%s: script", __func__);
-                       return -1;
                }
                dl = (size_t)s;
                if (s == -1 || (ifo->script = malloc(dl)) == NULL) {
@@ -729,8 +726,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        logerr(__func__);
                        return -1;
                }
-               parse_str(ifo->script, dl, arg, PARSE_STRING_NULL);
-               if (ifo->script[0] == '\0' ||
+               s = parse_str(ifo->script, dl, arg, PARSE_STRING_NULL);
+               if (s == -1 ||
+                   ifo->script[0] == '\0' ||
                    strcmp(ifo->script, "/dev/null") == 0)
                {
                        free(ifo->script);