public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: ppc: workaround uninitialized variable compiler warnings
@ 2024-01-09  1:13 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2024-01-09  1:13 UTC (permalink / raw)
  To: gdb-patches

Some compilers don't understand the semctl API and think it's an input
argument even when it's used as an output, and then complains that it
is being used uninitialized.  Zero it out explicitly to workaround it.
This adds some runtime overhead, but should be fairly minor as it's a
small stack buffer, and shouldn't be that relevant relative to all the
other logic in these functions.
---
 sim/ppc/hw_sem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sim/ppc/hw_sem.c b/sim/ppc/hw_sem.c
index c43af3b1d9ed..9495b8591b92 100644
--- a/sim/ppc/hw_sem.c
+++ b/sim/ppc/hw_sem.c
@@ -111,7 +111,7 @@ hw_sem_init_data(device *me)
   hw_sem_device *sem = (hw_sem_device*)device_data(me);
   const device_unit *d;
   int status;
-  union semun help;
+  union semun help = {};
 
   /* initialize the properties of the sem */
 
@@ -190,7 +190,7 @@ hw_sem_io_read_buffer(device *me,
   struct sembuf sb;
   int status;
   uint32_t u32;
-  union semun help;
+  union semun help = {};
 
   /* do we need to worry about out of range addresses? */
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-09  1:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09  1:13 [PATCH] sim: ppc: workaround uninitialized variable compiler warnings Mike Frysinger

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).