]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv: Suppress maybe uninitialized warning
authorStefan Liebler <stli@linux.vnet.ibm.com>
Thu, 11 Dec 2014 12:38:01 +0000 (07:38 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 12 Dec 2014 21:30:12 +0000 (16:30 -0500)
In send_vc function at resolv/res_send.c, There is the
following warning on some architectures:

  'resplen' may be used uninitialized in this function
  [-Wmaybe-uninitialized]

And this is a false positive.  This patch suppress the
compiler warning.

ChangeLog
resolv/res_send.c

index 9f18f4e95e4609d4c0530bfbd93608ea9de6ffc5..b815868543c796a18b64ae5b613e41a89ddde998 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-12  Stefan Liebler  <stli@linux.vnet.ibm.com>
+           Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       * resolv/res_send.c (send_vc): Disable warning resplen may
+       be used uninitialized.
+
 2014-12-12  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
        * nptl/tst-mutex6.c
index af42b8aac216356a5466998df5c47c21357881d3..4a95eb80cb4d5c298b0e959732214e3bf8161ce6 100644 (file)
@@ -96,6 +96,7 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
 #include <string.h>
 #include <unistd.h>
 #include <kernel-features.h>
+#include <libc-internal.h>
 
 #if PACKETSZ > 65536
 #define MAXPACKET       PACKETSZ
@@ -668,7 +669,24 @@ send_vc(res_state statp,
        // int anssiz = *anssizp;
        HEADER *anhp = (HEADER *) ans;
        struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns];
-       int truncating, connreset, resplen, n;
+       int truncating, connreset, n;
+       /* On some architectures compiler might emit a warning indicating
+          'resplen' may be used uninitialized.  However if buf2 == NULL
+          then this code won't be executed; if buf2 != NULL, then first
+          time round the loop recvresp1 and recvresp2 will be 0 so this
+          code won't be executed but "thisresplenp = &resplen;" followed
+          by "*thisresplenp = rlen;" will be executed so that subsequent
+          times round the loop resplen has been initialized.  So this is
+          a false-positive.
+        */
+#if __GNUC_PREREQ (4, 7)
+       DIAG_PUSH_NEEDS_COMMENT;
+       DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
+#endif
+       int resplen;
+#if __GNUC_PREREQ (4, 7)
+       DIAG_POP_NEEDS_COMMENT;
+#endif
        struct iovec iov[4];
        u_short len;
        u_short len2;
@@ -787,6 +805,10 @@ send_vc(res_state statp,
                        /* No buffer allocated for the first
                           reply.  We can try to use the rest
                           of the user-provided buffer.  */
+#if __GNUC_PREREQ (4, 7)
+                       DIAG_PUSH_NEEDS_COMMENT;
+                       DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
+#endif
 #if _STRING_ARCH_unaligned
                        *anssizp2 = orig_anssizp - resplen;
                        *ansp2 = *ansp + resplen;
@@ -796,6 +818,9 @@ send_vc(res_state statp,
                             & ~(__alignof__ (HEADER) - 1));
                        *anssizp2 = orig_anssizp - aligned_resplen;
                        *ansp2 = *ansp + aligned_resplen;
+#endif
+#if __GNUC_PREREQ (4, 7)
+                       DIAG_POP_NEEDS_COMMENT;
 #endif
                } else {
                        /* The first reply did not fit into the