From: Kevin Wolf <kwolf@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org, QEMU Trivial <qemu-trivial@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Max Reitz <mreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>,
Miroslav Rezanina <mrezanin@redhat.com>
Subject: Re: Prevent compiler warning on block.c
Date: Wed, 9 Jun 2021 11:04:35 +0200 [thread overview]
Message-ID: <YMCEI3dEmkLmT2RN@redhat.com> (raw)
In-Reply-To: <9ef22266-25e1-36df-52e9-ad5244a648dc@redhat.com>
Am 09.06.2021 um 09:12 hat Thomas Huth geschrieben:
> On 05/05/2021 10.05, Vladimir Sementsov-Ogievskiy wrote:
> > 05.05.2021 10:59, Miroslav Rezanina wrote:
> > > Commit 3108a15cf (block: introduce bdrv_drop_filter()) introduced
> > > uninitialized
> > > variable to_cow_parent in bdrv_replace_node_common function that is
> > > used only when
> > > detach_subchain is true. It is used in two places. First if block
> > > properly initialize
> > > the variable and second block use it.
> > >
> > > However, compiler treats this two blocks as two independent cases so
> > > it thinks first
> > > block can fail test and second one pass (although both use same
> > > condition). This cause
> > > warning that variable can be uninitialized in second block.
> > >
> > > To prevent this warning, initialize the variable with NULL.
> > >
> > > Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> > > ---
> > > diff --git a/block.c b/block.c
> > > index 874c22c43e..3ca27bd2d9 100644
> > > --- a/block.c
> > > +++ b/block.c
> > > @@ -4851,7 +4851,7 @@ static int
> > > bdrv_replace_node_common(BlockDriverState *from,
> > > Transaction *tran = tran_new();
> > > g_autoptr(GHashTable) found = NULL;
> > > g_autoptr(GSList) refresh_list = NULL;
> > > - BlockDriverState *to_cow_parent;
> > > + BlockDriverState *to_cow_parent = NULL;
> > > int ret;
> > >
> > > if (detach_subchain) {
> > >
> >
> > Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
> This just popped up again here:
>
> https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg02067.html
>
> Kevin, Max, could you please pick it up to get this problem fixed?
Thanks for pinging, seems the intended refactoring hasn't happened.
I've applied this one to my block branch now.
Kevin
next prev parent reply other threads:[~2021-06-09 9:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <603798381.17174916.1620200426349.JavaMail.zimbra@redhat.com>
2021-05-05 7:59 ` Prevent compiler warning on block.c Miroslav Rezanina
2021-05-05 8:05 ` Vladimir Sementsov-Ogievskiy
2021-05-05 10:03 ` Paolo Bonzini
2021-05-05 10:32 ` Vladimir Sementsov-Ogievskiy
2021-06-09 7:12 ` Thomas Huth
2021-06-09 9:04 ` Kevin Wolf [this message]
2021-05-05 10:43 ` Peter Maydell
2021-05-05 11:12 ` Miroslav Rezanina
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=YMCEI3dEmkLmT2RN@redhat.com \
--to=kwolf@redhat.com \
--cc=crosa@redhat.com \
--cc=mreitz@redhat.com \
--cc=mrezanin@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=thuth@redhat.com \
--cc=vsementsov@virtuozzo.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).