]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix the 'array subscript is above array bounds' warning correctly
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Tue, 16 Dec 2014 14:10:47 +0000 (19:40 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Tue, 16 Dec 2014 14:10:47 +0000 (19:40 +0530)
Use DIAG_IGNORE_NEEDS_COMMENT instead since the compiler should have
seen that NS never goes beyond MAXNS.

ChangeLog
resolv/res_send.c

index 2a3e0b7bf2d2515c127c09de1c15454398abbfeb..fae86bbc476bf905bc9cd871b9e12d0ea67af884 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-12-16  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+       * resolv/res_send.c (__libc_res_nsend): Disable warning 'array
+       subscript above bounds'
+
        * resolv/res_send.c (__libc_res_nsend): Fix check for nsmap
        bounds.
 
index 5a9882c6ad51d4b2dee0ede5d0e6e2fcbccf7486..c35fb66bda166ca02d92bd60ed224eb62782f1f9 100644 (file)
@@ -429,9 +429,15 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
                                while (ns < MAXNS
                                       && EXT(statp).nsmap[ns] != MAXNS)
                                        ns++;
-                               if (ns >= MAXNS)
+                               if (ns == MAXNS)
                                        break;
+                               /* NS never exceeds MAXNS, but gcc 4.9 somehow
+                                  does not see this.  */
+                               DIAG_PUSH_NEEDS_COMMENT;
+                               DIAG_IGNORE_NEEDS_COMMENT (4.9,
+                                                          "-Warray-bounds");
                                EXT(statp).nsmap[ns] = n;
+                               DIAG_POP_NEEDS_COMMENT;
                                map[n] = ns++;
                        }
                EXT(statp).nscount = n;