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