public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 04/10] sim/ppc: don't pass uninitialized value to semctl for GETVAL calls
Date: Wed, 19 Oct 2022 16:24:43 +0100	[thread overview]
Message-ID: <5155a6bb36800aa1a8bdb214f59f85f9d92b6989.1666192979.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1666192979.git.aburgess@redhat.com>

When calling semctl with an GETVAL action, the 'union semun' argument
is unused.

Rather than passing an uninitialized variable (as we currently do),
just pass the integer 0.  This silences some compiler warnings, and is
just as correct (given the argument is ignored).

To be honest, it might be the case that the argument is not needed at
all, however, I'm a little nervous to make this change as the amount
of testing I can do of this code is limited.  Every example I found
online for a semctl/GETVAL call did pass the final argument, so that's
what I've continued to do.
---
 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 937e2ad6f81..78e3dda9ae6 100644
--- a/sim/ppc/hw_sem.c
+++ b/sim/ppc/hw_sem.c
@@ -148,7 +148,7 @@ hw_sem_init_data(device *me)
       error("hw_sem_init_data() semget failed\n");
   }
 
-  sem->count = semctl( sem->id, 0, GETVAL, help );
+  sem->count = semctl( sem->id, 0, GETVAL, 0 );
   if (sem->count == -1)
     error("hw_sem_init_data() semctl -- get value failed\n");
   DTRACE(sem, ("semaphore OS value (%d)\n", sem->count) );
@@ -241,7 +241,7 @@ hw_sem_io_read_buffer(device *me,
   }
 
   /* assume target is big endian */
-  u32 = H2T_4(semctl( sem->id, 0, GETVAL, help ));
+  u32 = H2T_4(semctl( sem->id, 0, GETVAL, 0 ));
 
   DTRACE(sem, ("semaphore OS value (%d)\n", u32) );
   if (u32 == 0xffffffff) {
-- 
2.25.4


  parent reply	other threads:[~2022-10-19 15:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 15:24 [PATCH 00/10] Building the sim/ tree with clang Andrew Burgess
2022-10-19 15:24 ` [PATCH 01/10] sim/sh: use fabs instead of abs Andrew Burgess
2022-10-23 13:53   ` Mike Frysinger
2022-10-24 16:05     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 02/10] sim/ppc: don't try to print an uninitialized variable Andrew Burgess
2022-10-23 13:51   ` Mike Frysinger
2022-10-24 16:05     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 03/10] sim/ppc: initialize a memory buffer in all cases Andrew Burgess
2022-10-23 13:50   ` Mike Frysinger
2022-10-24 16:25     ` Andrew Burgess
2022-10-19 15:24 ` Andrew Burgess [this message]
2022-10-23 14:01   ` [PATCH 04/10] sim/ppc: don't pass uninitialized value to semctl for GETVAL calls Mike Frysinger
2022-10-19 15:24 ` [PATCH 05/10] sim/ppc: fix for operator precedence warning from clang Andrew Burgess
2022-10-23 13:55   ` Mike Frysinger
2022-10-24 16:26     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 06/10] sim/aarch64: remove two unused functions Andrew Burgess
2022-10-23 13:55   ` Mike Frysinger
2022-10-24 16:26     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 07/10] sim/rx: delete an unused function Andrew Burgess
2022-10-23 13:54   ` Mike Frysinger
2022-10-19 15:24 ` [PATCH 08/10] sim/h8300: avoid self assignment Andrew Burgess
2022-10-23 13:52   ` Mike Frysinger
2022-10-24 16:26     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 09/10] sim/lm32: fix some missing function declaration warnings Andrew Burgess
2022-10-23 14:13   ` Mike Frysinger
2022-10-24 16:27     ` Andrew Burgess
2022-10-19 15:24 ` [PATCH 10/10] sim/cris/m32c/sh: disable use of -Werror Andrew Burgess
2022-10-20  3:53   ` Tsukasa OI
2022-10-21 15:58     ` Andrew Burgess
2022-10-24  8:58       ` Tsukasa OI
2022-10-24 16:23         ` Andrew Burgess
2022-10-20 18:36   ` Tom Tromey
2022-10-23 14:17   ` Mike Frysinger
2022-10-20 18:36 ` [PATCH 00/10] Building the sim/ tree with clang Tom Tromey

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

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

  git send-email \
    --in-reply-to=5155a6bb36800aa1a8bdb214f59f85f9d92b6989.1666192979.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).