hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 49d651f933d1213b31c1b75f19cc74b0c39da61b Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Wed, 2 Oct 2019 21:12:17 +0000
Subject: [PATCH 18/19] Disable -Wmaybe-uninitialized for total_deadline in
 sunrpc/clnt_udp.c.
 
To work around <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691>
for RV32, we recently disabled -Wmaybe-uninitialized for some inline
functions in inet/net-internal.h, as included by sunrpc/clnt_udp.c.
 
The same error has now appeared with current GCC trunk for MIPS, in a
form that is located at the definition of the variable in question and
so unaffected by the disabling in inet/net-internal.h.  Thus, this
patch adds the same disabling around the definition of that variable,
to cover the MIPS case.
 
Tested with build-many-glibcs.py (compilers and glibcs stages) for
mips64-linux-gnu with GCC mainline.
 
   * sunrpc/clnt_udp.c: Include <libc-diag.h>.
   (clntudp_call): Disable -Wmaybe-uninitialized around declaration
   of total_deadline.
 
(cherry picked from commit 2334a78a4982f8d594e8da8f29d9e06ee5c15824)
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 sunrpc/clnt_udp.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
 
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index c2436e3e..ee79b09b 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -57,6 +57,7 @@
 #include <kernel-features.h>
 #include <inet/net-internal.h>
 #include <shlib-compat.h>
+#include <libc-diag.h>
 
 extern u_long _create_xid (void);
 
@@ -290,7 +291,17 @@ clntudp_call (/* client handle */
   int anyup;            /* any network interface up */
 
   struct deadline_current_time current_time = __deadline_current_time ();
+  /* GCC 10 for MIPS reports total_deadline as possibly used
+     uninitialized; see
+     <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691>.  In fact it
+     is initialized conditionally and only ever used under the same
+     condition.  The same warning is also disabled in
+     inet/net-internal.h because in some other configurations GCC
+     gives the warning in an inline function.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10, "-Wmaybe-uninitialized");
   struct deadline total_deadline; /* Determined once by overall timeout.  */
+  DIAG_POP_NEEDS_COMMENT;
   struct deadline response_deadline; /* Determined anew for each query.  */
 
   /* Choose the timeout value.  For non-sending usage (xargs == NULL),
-- 
2.20.1