]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix some clang analyzer issues
authorRoy Marples <roy@marples.name>
Sat, 30 May 2020 09:51:49 +0000 (09:51 +0000)
committerRoy Marples <roy@marples.name>
Sat, 30 May 2020 09:51:49 +0000 (09:51 +0000)
src/arp.c
src/common.c
src/dhcp.c
src/dhcpcd.c
src/if.c
src/script.c

index 0e057acab52e426d5aee52756fb360d0150f3097..db1e188c3c54e9bde611db40a200bd4d69d03355 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -538,7 +538,7 @@ arp_new(struct interface *ifp, const struct in_addr *addr)
                }
                TAILQ_INIT(&state->arp_states);
        } else {
-               if (addr && (astate = arp_find(ifp, addr)))
+               if ((astate = arp_find(ifp, addr)) != NULL)
                        return astate;
        }
 
index ddab3042ff90a3ff259de63a3339e0633e39c0d1..2586c41c5544732b35c550fe9c308bea604914f9 100644 (file)
@@ -160,6 +160,8 @@ get_line(char ** __restrict buf, ssize_t * __restrict buflen)
 
        do {
                p = *buf;
+               if (*buf == NULL)
+                       return NULL;
                c = memchr(*buf, '\n', (size_t)*buflen);
                if (c == NULL) {
                        c = memchr(*buf, '\0', (size_t)*buflen);
index a7f602056c0bc4a09433e8cac60e6a5d21c93ed7..1bad22ca98a996e28a9bb4f31d1b14baabeb865b 100644 (file)
@@ -3753,7 +3753,7 @@ static int
 dhcp_init(struct interface *ifp)
 {
        struct dhcp_state *state;
-       const struct if_options *ifo;
+       struct if_options *ifo;
        uint8_t len;
        char buf[(sizeof(ifo->clientid) - 1) * 3];
 
@@ -3824,7 +3824,7 @@ dhcp_init(struct interface *ifp)
                 * at device start. */
                return 0;
 
-       if (ifo->options & DHCPCD_CLIENTID)
+       if (ifo->options & DHCPCD_CLIENTID && state->clientid != NULL)
                logdebugx("%s: using ClientID %s", ifp->name,
                    hwaddr_ntoa(state->clientid + 1, state->clientid[0],
                        buf, sizeof(buf)));
index 459f24c0d1be4350fd3d215a1ecc2d853bd3729e..0842e6d00f79c185eee674a09a1e8a9d7de0bac8 100644 (file)
@@ -1267,7 +1267,8 @@ dhcpcd_handlehwaddr(struct interface *ifp,
        loginfox("%s: new hardware address: %s", ifp->name,
            hwaddr_ntoa(hwaddr, hwlen, buf, sizeof(buf)));
        ifp->hwlen = hwlen;
-       memcpy(ifp->hwaddr, hwaddr, hwlen);
+       if (hwaddr != NULL)
+               memcpy(ifp->hwaddr, hwaddr, hwlen);
 }
 
 static void
@@ -2062,7 +2063,7 @@ printpidfile:
 
 #ifdef USE_SIGNALS
        for (si = 0; si < dhcpcd_signals_ignore_len; si++)
-               signal(dhcpcd_signals_ignore[i], SIG_IGN);
+               signal(dhcpcd_signals_ignore[si], SIG_IGN);
 
        /* Save signal mask, block and redirect signals to our handler */
        if (eloop_signal_set_cb(ctx.eloop,
index 69e9ccb4552a305fec5ae0950529ec92508bfb69..acf8dcac259d69025996f1100c5d9c57f0e0d774 100644 (file)
--- a/src/if.c
+++ b/src/if.c
@@ -686,10 +686,15 @@ if_nametospec(const char *ifname, struct if_spec *spec)
                        errno = e;
                        return -1;
                }
-               *ep-- = '\0';
+               *ep = '\0';
+#ifdef __sun
+               ep--;
+#endif
        } else {
                spec->lun = -1;
+#ifdef __sun
                ep = spec->drvname + strlen(spec->drvname) - 1;
+#endif
        }
 
        strlcpy(spec->devname, spec->drvname, sizeof(spec->devname));
index e592f6f094775906974bf0db14b7857a0be64948..d14a8f79da026ca85633d6369a762d613c5f53b1 100644 (file)
@@ -719,7 +719,7 @@ script_runreason(const struct interface *ifp, const char *reason)
        }
 #endif
 
-       status = script_run(ctx, argv);
+       script_run(ctx, argv);
 
 send_listeners:
        /* Send to our listeners */