qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Stefan Weil <sw@weilnetz.de>, qemu-devel <qemu-devel@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] block: Fix compiler warning (-Werror=uninitialized)
Date: Fri, 20 Sep 2013 12:42:14 +0200	[thread overview]
Message-ID: <20130920104214.GB14159@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <523B2D6B.9050601@suse.de>

On Thu, Sep 19, 2013 at 06:59:23PM +0200, Andreas Färber wrote:
> Am 17.09.2013 18:43, schrieb Stefan Weil:
> > The patch fixes a warning from gcc (Debian 4.6.3-14+rpi1) 4.6.3:
> > 
> > block/stream.c:141:22: error:
> > ‘copy’ may be used uninitialized in this function [-Werror=uninitialized]
> > 
> > This is not a real bug - a better compiler would not complain.
> > 
> > Now 'copy' has always a defined value, so the check for ret >= 0
> > can be removed.
> > 
> > Signed-off-by: Stefan Weil <sw@weilnetz.de>
> > ---
> >  block/stream.c |    5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/block/stream.c b/block/stream.c
> > index 078ce4a..fc19194 100644
> > --- a/block/stream.c
> > +++ b/block/stream.c
> > @@ -108,7 +108,7 @@ static void coroutine_fn stream_run(void *opaque)
> >  
> >      for (sector_num = 0; sector_num < end; sector_num += n) {
> >          uint64_t delay_ns = 0;
> > -        bool copy;
> > +        bool copy = false;
> >  
> >  wait:
> >          /* Note that even when no rate limit is applied we need to yield
> > @@ -123,7 +123,6 @@ wait:
> >                                  STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
> >          if (ret == 1) {
> >              /* Allocated in the top, no need to copy.  */
> > -            copy = false;
> >          } else if (ret >= 0) {
> >              /* Copy if allocated in the intermediate images.  Limit to the
> >               * known-unallocated area [sector_num, sector_num+n).  */
> 
> Sorry for not spotting this patch earlier. This hunk looks wrong and
> needs to be dropped, I believe. In the ret >= 0 && copy case, there is a
> "goto wait" which would now no longer be able to go from copy == true ->
> copy == false. Not sure if that can happen in practice.

Thanks for catching this!

I've dropped the patch from my block tree for now.

Stefan


      parent reply	other threads:[~2013-09-20 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 16:43 [Qemu-trivial] [PATCH] block: Fix compiler warning (-Werror=uninitialized) Stefan Weil
2013-09-19 14:44 ` Stefan Hajnoczi
2013-09-19 16:59 ` [Qemu-trivial] [Qemu-devel] " Andreas Färber
2013-09-19 17:22   ` [Qemu-trivial] " Paolo Bonzini
2013-09-20 10:42   ` Stefan Hajnoczi [this message]

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=20130920104214.GB14159@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=afaerber@suse.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).