From: Roy Marples Date: Thu, 11 Sep 2014 11:37:10 +0000 (+0000) Subject: Fix more clang analyzer errors. X-Git-Tag: v6.4.4~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=03f8f539fcc96f37f07cdc423b96f1fbc13703dd;p=thirdparty%2Fdhcpcd.git Fix more clang analyzer errors. --- diff --git a/if-linux.c b/if-linux.c index 61bfd9b0..f4a6265d 100644 --- a/if-linux.c +++ b/if-linux.c @@ -375,9 +375,11 @@ get_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, int fd, int flags, goto eexit; if (r) continue; - r = callback(ctx, ifp, nlm); - if (r != 0) - goto eexit; + if (callback) { + r = callback(ctx, ifp, nlm); + if (r != 0) + goto eexit; + } } } @@ -784,7 +786,8 @@ add_attr_l(struct nlmsghdr *n, unsigned short maxlen, unsigned short type, rta = NLMSG_TAIL(n); rta->rta_type = type; rta->rta_len = len; - memcpy(RTA_DATA(rta), data, alen); + if (alen) + memcpy(RTA_DATA(rta), data, alen); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len); return 0; diff --git a/script.c b/script.c index c931d3ba..4ff6823d 100644 --- a/script.c +++ b/script.c @@ -692,6 +692,7 @@ script_runreason(const struct interface *ifp, const char *reason) /* Send to our listeners */ bigenv = NULL; + status = 0; TAILQ_FOREACH(fd, &ifp->ctx->control_fds, next) { if (!fd->listener) continue; @@ -706,7 +707,11 @@ script_runreason(const struct interface *ifp, const char *reason) } if (control_queue(fd, bigenv, elen, 1) == -1) syslog(LOG_ERR, "%s: control_queue: %m", __func__); + else + status = 1; } + if (!status) + free(bigenv); out: /* Cleanup */