From: Siddhesh Poyarekar Date: Tue, 16 Dec 2014 14:10:47 +0000 (+0530) Subject: Fix the 'array subscript is above array bounds' warning correctly X-Git-Tag: glibc-2.21~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd8552045aeb0537b4f1ab5d1b30ada8ae50076;p=thirdparty%2Fglibc.git Fix the 'array subscript is above array bounds' warning correctly Use DIAG_IGNORE_NEEDS_COMMENT instead since the compiler should have seen that NS never goes beyond MAXNS. --- diff --git a/ChangeLog b/ChangeLog index 2a3e0b7bf2d..fae86bbc476 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-12-16 Siddhesh Poyarekar + * 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. diff --git a/resolv/res_send.c b/resolv/res_send.c index 5a9882c6ad5..c35fb66bda1 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -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;