unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@wdc.com>
To: libc-alpha@sourceware.org
Cc: law@redhat.com, joseph@codesourcery.com, zackw@panix.com,
	alistair.francis@wdc.com, macro@wdc.com, alistair23@gmail.com
Subject: [PATCH] inet/net-internal.h: Fix uninitalised clntudp_call() variable
Date: Mon, 16 Sep 2019 15:15:36 -0700	[thread overview]
Message-ID: <20190916221536.18500-1-alistair.francis@wdc.com> (raw)

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-16  Alistair Francis  <alistair.francis@wdc.com>

	* inet/net-internal.h: Fix uninitalised clntudp_call() variable
---
 inet/net-internal.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/inet/net-internal.h b/inet/net-internal.h
index 2f522eef555..c774de2b78a 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.23.0


             reply	other threads:[~2019-09-16 22:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16 22:15 Alistair Francis [this message]
2019-09-24 17:04 ` [PATCH] inet/net-internal.h: Fix uninitalised clntudp_call() variable Alistair Francis
2019-09-24 20:21 ` Carlos O'Donell
2019-09-24 20:30   ` Alistair Francis
2019-09-24 21:00     ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190916221536.18500-1-alistair.francis@wdc.com \
    --to=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=law@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=macro@wdc.com \
    --cc=zackw@panix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).