]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Zero out a local variable also when PURIFY is not defined.
authortuexen <tuexen@FreeBSD.org>
Thu, 10 Sep 2015 10:23:23 +0000 (10:23 +0000)
committertuexen <tuexen@FreeBSD.org>
Thu, 10 Sep 2015 10:23:23 +0000 (10:23 +0000)
This silence a warning brought up by valgrind whenever if_nametoindex
is used. This was already discussed in PR 166483, but the code
committed in r234329 guards the initilization with #ifdef PURIFY.
Therefore, valgrind still complains. Since this code is not performance
critical, always zero out the local variable to silence valgrind.

PR: 166483
Discussed with: eadler@
MFC after: 4 weeks

lib/libc/net/if_nametoindex.c

index 8f04921760ebb8646786ab1e3971a2d2d5cba947..debf3fabc6af6975b6073336e8307d9afe295240 100644 (file)
@@ -70,9 +70,7 @@ if_nametoindex(const char *ifname)
 
        s = _socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
        if (s != -1) {
-#ifdef PURIFY
                memset(&ifr, 0, sizeof(ifr));
-#endif
                strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
                if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
                        _close(s);