hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
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
62
63
64
65
66
From 38f1b80deb83421872b430fa93211a4e060b0f01 Mon Sep 17 00:00:00 2001
From: Alistair Francis <alistair.francis@wdc.com>
Date: Tue, 24 Sep 2019 21:55:36 +0100
Subject: [PATCH 19/19] inet/net-internal.h: Fix uninitalised clntudp_call()
 variable
 
The total_deadline variable inside the clntudp_call() function inside
sunrpc/clnt_udp.c can cause uninitalised variable warnings when building
with GCC 8.3 or 9.2 on a platform with a 64-bit tv_nsec on a 32-bit
architecture.  To fix the warning let's use the DIAG_* macros to hide the
warning.
 
A GCC bug case has also been submitted:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691
 
2019-09-24  Alistair Francis  <alistair.francis@wdc.com>
 
   * inet/net-internal.h: Fix uninitalised clntudp_call() variable.
 
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 5d245b5f8d9663953c20107e3bb16fe249e48126)
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 inet/net-internal.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 
diff --git a/inet/net-internal.h b/inet/net-internal.h
index ef92c80a..4825e7f1 100644
--- a/inet/net-internal.h
+++ b/inet/net-internal.h
@@ -23,6 +23,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <sys/time.h>
+#include <libc-diag.h>
 
 int __inet6_scopeid_pton (const struct in6_addr *address,
                           const char *scope, uint32_t *result);
@@ -96,6 +97,16 @@ __deadline_is_infinite (struct deadline deadline)
   return deadline.absolute.tv_nsec < 0;
 }
 
+/* GCC 8.3 and 9.2 both incorrectly report total_deadline
+ * (from sunrpc/clnt_udp.c) as maybe-uninitialized when tv_sec is 8 bytes
+ * (64-bits) wide on 32-bit systems. We have to set -Wmaybe-uninitialized
+ * here as it won't fix the error in sunrpc/clnt_udp.c.
+ * A GCC bug has been filed here:
+ *    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91691
+ */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized");
+
 /* Return true if the current time is at the deadline or past it.  */
 static inline bool
 __deadline_elapsed (struct deadline_current_time current,
@@ -120,6 +131,8 @@ __deadline_first (struct deadline left, struct deadline right)
     return right;
 }
 
+DIAG_POP_NEEDS_COMMENT;
+
 /* Add TV to the current time and return it.  Returns a special
    infinite absolute deadline on overflow.  */
 struct deadline __deadline_from_timeval (struct deadline_current_time,
-- 
2.20.1