qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning


From: Miroslav Rezanina
Subject: Re: [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning
Date: Tue, 21 Jan 2020 05:57:06 -0500 (EST)


----- Original Message -----
> From: "Cédric Le Goater" <address@hidden>
> To: "Thomas Huth" <address@hidden>, address@hidden, address@hidden
> Cc: "peter maydell" <address@hidden>, "Andrew Jeffery" <address@hidden>, 
> "Joel Stanley" <address@hidden>,
> address@hidden
> Sent: Tuesday, January 21, 2020 11:44:14 AM
> Subject: Re: [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning
> 
> On 1/21/20 11:02 AM, Thomas Huth wrote:
> > On 21/01/2020 10.28, address@hidden wrote:
> >> From: Miroslav Rezanina <address@hidden>
> >>
> >> Compiler reports uninitialized warning for cmd_flags variable.
> >>
> >> Adding NULL initialization to prevent this warning.
> >>
> >> Signed-off-by: Miroslav Rezanina <address@hidden>
> >> ---
> >>  hw/i2c/aspeed_i2c.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
> >> index 2da04a4..445182a 100644
> >> --- a/hw/i2c/aspeed_i2c.c
> >> +++ b/hw/i2c/aspeed_i2c.c
> >> @@ -400,7 +400,7 @@ static bool aspeed_i2c_check_sram(AspeedI2CBus *bus)
> >>  
> >>  static void aspeed_i2c_bus_cmd_dump(AspeedI2CBus *bus)
> >>  {
> >> -    g_autofree char *cmd_flags;
> >> +    g_autofree char *cmd_flags = NULL;
> >>      uint32_t count;
> >>  
> >>      if (bus->cmd & (I2CD_RX_BUFF_ENABLE | I2CD_RX_BUFF_ENABLE)) {
> > 
> > Reviewed-by: Thomas Huth <address@hidden>
> > 
> > ... maybe someone with enough Perl-foo (i.e. not me ;-)) should add a
> > check to our check_patch.pl script so that it complains when new code is
> > introduced that uses g_autofree without initializing the variable...
> 
> weird. The cmd_flags variable is assigned just after and used
> in a trace.
> 

As g_autofree is used, variable has to be initialized otherwise will compiler
complain even in the case we write to variable immediately after.

Mirek

> C.
> 
> 

-- 
Miroslav Rezanina
Software Engineer - Virtualization Team Maintainer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]