From: Miroslav Rezanina <mrezanin@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: peter maydell <peter.maydell@linaro.org>,
Thomas Huth <thuth@redhat.com>, Andrew Jeffery <andrew@aj.id.au>,
qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning
Date: Tue, 21 Jan 2020 05:57:06 -0500 (EST) [thread overview]
Message-ID: <105074722.2949784.1579604226517.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <fdc3e6c2-87e4-2e51-cbee-d9c7a008eec9@kaod.org>
----- Original Message -----
> From: "Cédric Le Goater" <clg@kaod.org>
> To: "Thomas Huth" <thuth@redhat.com>, mrezanin@redhat.com, qemu-devel@nongnu.org
> Cc: "peter maydell" <peter.maydell@linaro.org>, "Andrew Jeffery" <andrew@aj.id.au>, "Joel Stanley" <joel@jms.id.au>,
> qemu-trivial@nongnu.org
> 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, mrezanin@redhat.com wrote:
> >> From: Miroslav Rezanina <mrezanin@redhat.com>
> >>
> >> Compiler reports uninitialized warning for cmd_flags variable.
> >>
> >> Adding NULL initialization to prevent this warning.
> >>
> >> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> >> ---
> >> 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 <thuth@redhat.com>
> >
> > ... 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
next prev parent reply other threads:[~2020-01-21 10:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 9:28 [PATCH 0/2] Prevent uninitialized warnings mrezanin
2020-01-21 9:28 ` [PATCH 1/2] test-logging: Fix -Werror=maybe-uninitialized warning mrezanin
2020-01-21 9:58 ` Thomas Huth
2020-01-21 15:03 ` Robert Foley
2020-01-21 9:28 ` [PATCH 2/2] aspeed/i2c: Prevent uninitialized warning mrezanin
2020-01-21 10:02 ` Thomas Huth
2020-01-21 10:44 ` Cédric Le Goater
2020-01-21 10:57 ` Miroslav Rezanina [this message]
2020-01-21 11:43 ` Thomas Huth
2020-02-06 10:13 ` Laurent Vivier
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=105074722.2949784.1579604226517.JavaMail.zimbra@redhat.com \
--to=mrezanin@redhat.com \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=thuth@redhat.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 NNTP newsgroup(s).