diff mbox series

Disable spurious -Warray-bounds for ypclnt.c (bug 26687)

Message ID alpine.DEB.2.22.394.2010282239450.233090@digraph.polyomino.org.uk
State Committed
Headers show
Series Disable spurious -Warray-bounds for ypclnt.c (bug 26687) | expand

Commit Message

Joseph Myers Oct. 28, 2020, 10:39 p.m. UTC
Included among the GCC 11 warnings listed in bug 26687, but not fixed
when that bug was marked as FIXED, are -Warray-bounds warnings in
nis/ypclnt.c.  These are all for different calls to the same piece of
code, which already has a comment explaining that the element accessed
is in a common prefix of the various structures.  On the basis of that
comment, this patch treats the warning as a false positive and
disables it for that code.

Tested with build-many-glibcs.py for arm-linux-gnueabi, where,
together with my previous two patches, this allows the build of glibc
to complete with GCC 11 (not yet tested whether further build failures
appear in the testsuite).
diff mbox series


diff --git a/nis/ypclnt.c b/nis/ypclnt.c
index ada08bf..898f814 100644
--- a/nis/ypclnt.c
+++ b/nis/ypclnt.c
@@ -30,6 +30,7 @@ 
 #include <sys/uio.h>
 #include <libc-lock.h>
 #include <shlib-compat.h>
+#include <libc-diag.h>
 /* This should only be defined on systems with a BSD compatible ypbind */
@@ -368,12 +369,19 @@  do_ypcall_tr (const char *domain, u_long prog, xdrproc_t xargs,
 	      caddr_t req, xdrproc_t xres, caddr_t resp)
   int status = do_ypcall (domain, prog, xargs, req, xres, resp);
+  /* This cast results in a warning that a ypresp_val is partly
+     outside the bounds of the actual object referenced, but as
+     explained below only the stat element (in a common prefix) is
+     accessed.  */
+  DIAG_IGNORE_NEEDS_COMMENT (11, "-Warray-bounds");
   if (status == YPERR_SUCCESS)
     /* We cast to ypresp_val although the pointer could also be of
        type ypresp_key_val or ypresp_master or ypresp_order or
        ypresp_maplist.  But the stat element is in a common prefix so
        this does not matter.  */
     status = ypprot_err (((struct ypresp_val *) resp)->stat);
   return status;