[31/40] sim/ppc: Initialize help variables

Message ID 91681f1c5c0144e59196ec40e456f214cc74568d.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  GCC / Clang generate a warning if a variables is used uninitialized on some
cases.  On the default configuration, it causes a build failure (unless
"--disable-werror" is specified).

This commit initializes two help variables with { 0 }.
---
 sim/ppc/hw_sem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 3:08 p.m. UTC | #1
Andrew posted a diff fix that i think we should use instead
-mike
  
Andrew Burgess Oct. 24, 2022, 4:33 p.m. UTC | #2
Tsukasa OI <research_trasio@irq.a4lg.com> writes:

> GCC / Clang generate a warning if a variables is used uninitialized on some
> cases.  On the default configuration, it causes a build failure (unless
> "--disable-werror" is specified).
>
> This commit initializes two help variables with { 0 }.

I've not pushed my fix as I'd like to reach consensus before merging
anything.

But I agree with Mike here, initializing help here just so that it can
be used somewhere it's not needed seems like the wrong solution.

Thanks,
Andrew


> ---
>  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..034191b10b7 100644
> --- a/sim/ppc/hw_sem.c
> +++ b/sim/ppc/hw_sem.c
> @@ -109,7 +109,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 = { 0 };
>  
>    /* initialize the properties of the sem */
>  
> @@ -188,7 +188,7 @@ hw_sem_io_read_buffer(device *me,
>    struct sembuf sb;
>    int status;
>    uint32_t u32;
> -  union semun help;
> +  union semun help = { 0 };
>  
>    /* do we need to worry about out of range addresses? */
>  
> -- 
> 2.34.1
  

Patch

diff --git a/sim/ppc/hw_sem.c b/sim/ppc/hw_sem.c
index 937e2ad6f81..034191b10b7 100644
--- a/sim/ppc/hw_sem.c
+++ b/sim/ppc/hw_sem.c
@@ -109,7 +109,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 = { 0 };
 
   /* initialize the properties of the sem */
 
@@ -188,7 +188,7 @@  hw_sem_io_read_buffer(device *me,
   struct sembuf sb;
   int status;
   uint32_t u32;
-  union semun help;
+  union semun help = { 0 };
 
   /* do we need to worry about out of range addresses? */