1From 4737853b0dcb7ed04c5b990cffe4aa9efba74e02 Mon Sep 17 00:00:00 2001 2From: Joseph Myers <joseph@codesourcery.com> 3Date: Fri, 30 Oct 2020 21:40:25 +0000 4Subject: [PATCH 17/20] Disable spurious -Warray-bounds for ypclnt.c (bug 5 26687) 6 7Included among the GCC 11 warnings listed in bug 26687, but not fixed 8when that bug was marked as FIXED, are -Warray-bounds warnings in 9nis/ypclnt.c. These are all for different calls to the same piece of 10code, which already has a comment explaining that the element accessed 11is in a common prefix of the various structures. On the basis of that 12comment, this patch treats the warning as a false positive and 13disables it for that code. 14 15Tested with build-many-glibcs.py for arm-linux-gnueabi, where, 16together with my previous two patches, this allows the build of glibc 17to complete with GCC 11 (further build failures appear in the 18testsuite). 19 20Reviewed-by: DJ Delorie <dj@redhat.com> 21(cherry picked from commit 882774658cb8daee4c16677a3fd674f6052cc157) 22Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 23--- 24 nis/ypclnt.c | 8 ++++++++ 25 1 file changed, 8 insertions(+) 26 27diff --git a/nis/ypclnt.c b/nis/ypclnt.c 28index 11a17db9..60c4da8a 100644 29--- a/nis/ypclnt.c 30+++ b/nis/ypclnt.c 31@@ -30,6 +30,7 @@ 32 #include <sys/uio.h> 33 #include <libc-lock.h> 34 #include <shlib-compat.h> 35+#include <libc-diag.h> 36 37 /* This should only be defined on systems with a BSD compatible ypbind */ 38 #ifndef BINDINGDIR 39@@ -368,12 +369,19 @@ do_ypcall_tr (const char *domain, u_long prog, xdrproc_t xargs, 40 caddr_t req, xdrproc_t xres, caddr_t resp) 41 { 42 int status = do_ypcall (domain, prog, xargs, req, xres, resp); 43+ DIAG_PUSH_NEEDS_COMMENT; 44+ /* This cast results in a warning that a ypresp_val is partly 45+ outside the bounds of the actual object referenced, but as 46+ explained below only the stat element (in a common prefix) is 47+ accessed. */ 48+ DIAG_IGNORE_NEEDS_COMMENT (11, "-Warray-bounds"); 49 if (status == YPERR_SUCCESS) 50 /* We cast to ypresp_val although the pointer could also be of 51 type ypresp_key_val or ypresp_master or ypresp_order or 52 ypresp_maplist. But the stat element is in a common prefix so 53 this does not matter. */ 54 status = ypprot_err (((struct ypresp_val *) resp)->stat); 55+ DIAG_POP_NEEDS_COMMENT; 56 return status; 57 } 58 59-- 602.20.1 61 62