From: Vincent Bernat Date: Tue, 1 May 2012 08:16:10 +0000 (+0200) Subject: valgrind: initialize some buffers to make valgrind happy X-Git-Tag: 0.6.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f0d19bb5a7a5bbcced7bdb1b0652f035bb3b418;p=thirdparty%2Flldpd.git valgrind: initialize some buffers to make valgrind happy Valgrind does not understand some ioctl and thinks we are using unitialized buffers while the ioctl will initialize them. We get rid of those warnings by initializing them ourselves. --- diff --git a/src/interfaces.c b/src/interfaces.c index e22dd115..e9ce4cef 100644 --- a/src/interfaces.c +++ b/src/interfaces.c @@ -440,6 +440,7 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) /* Check if the driver is whitelisted */ memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, ifa->ifa_name); + memset(ðc, 0, sizeof(ethc)); ifr.ifr_data = (caddr_t) ðc; ethc.cmd = ETHTOOL_GDRVINFO; if (ioctl(cfg->g_sock, SIOCETHTOOL, &ifr) == 0) { @@ -470,10 +471,11 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) static int iface_set_filter(const char *name, int fd) { - const struct sock_fprog prog = { - .filter = lldpd_filter_f, - .len = sizeof(lldpd_filter_f) / sizeof(struct sock_filter) - }; + struct sock_fprog prog; + memset(&prog, 0, sizeof(struct sock_fprog)); + prog.filter = lldpd_filter_f; + prog.len = sizeof(lldpd_filter_f) / sizeof(struct sock_filter); + if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog)) < 0) { LLOG_WARN("unable to change filter for %s", name); diff --git a/src/privsep_fdpass.c b/src/privsep_fdpass.c index 4a1a3140..6b004806 100644 --- a/src/privsep_fdpass.c +++ b/src/privsep_fdpass.c @@ -60,6 +60,7 @@ send_fd(int sock, int fd) ssize_t n; memset(&msg, 0, sizeof(msg)); + memset(&cmsgbuf.buf, 0, sizeof(cmsgbuf.buf)); if (fd >= 0) { msg.msg_control = (caddr_t)&cmsgbuf.buf;