changeset 5280:a986083da0ba draft

Fix some clang analyzer issues
author Roy Marples <roy@marples.name>
date Sat, 30 May 2020 09:51:49 +0000
parents cab28576ec7e
children 9f9a330f6e24
files src/arp.c src/common.c src/dhcp.c src/dhcpcd.c src/if.c src/script.c
diffstat 6 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/arp.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/arp.c	Sat May 30 09:51:49 2020 +0000
@@ -538,7 +538,7 @@
 		}
 		TAILQ_INIT(&state->arp_states);
 	} else {
-		if (addr && (astate = arp_find(ifp, addr)))
+		if ((astate = arp_find(ifp, addr)) != NULL)
 			return astate;
 	}
 
--- a/src/common.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/common.c	Sat May 30 09:51:49 2020 +0000
@@ -160,6 +160,8 @@
 
 	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);
--- a/src/dhcp.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/dhcp.c	Sat May 30 09:51:49 2020 +0000
@@ -3753,7 +3753,7 @@
 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 @@
 		 * 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)));
--- a/src/dhcpcd.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/dhcpcd.c	Sat May 30 09:51:49 2020 +0000
@@ -1267,7 +1267,8 @@
 	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 @@
 
 #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,
--- a/src/if.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/if.c	Sat May 30 09:51:49 2020 +0000
@@ -686,10 +686,15 @@
 			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));
--- a/src/script.c	Fri May 29 22:33:30 2020 +0300
+++ b/src/script.c	Sat May 30 09:51:49 2020 +0000
@@ -719,7 +719,7 @@
 	}
 #endif
 
-	status = script_run(ctx, argv);
+	script_run(ctx, argv);
 
 send_listeners:
 	/* Send to our listeners */