From: Stefan Hajnoczi <stefanha@gmail.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
"Kevin Wolf" <kwolf@redhat.com>,
"Andreas Färber" <andreas.faerber@web.de>,
qemu-devel <qemu-devel@nongnu.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] block: Fix compiler warning (-Werror=uninitialized)
Date: Mon, 23 Sep 2013 14:12:53 +0200 [thread overview]
Message-ID: <20130923121253.GB3623@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1379830750-23801-1-git-send-email-sw@weilnetz.de>
On Sun, Sep 22, 2013 at 08:19:10AM +0200, Stefan Weil wrote:
> 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>
> ---
>
> v2:
>
> As noted by Andreas Färber, 'copy' must be set to false after the goto label.
> Thanks for this hint.
>
> Regards,
> Stefan
>
> block/stream.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/block/stream.c b/block/stream.c
> index 078ce4a..45837f4 100644
> --- a/block/stream.c
> +++ b/block/stream.c
> @@ -119,11 +119,12 @@ wait:
> break;
> }
>
> + copy = false;
> +
> ret = bdrv_is_allocated(bs, sector_num,
> 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). */
> @@ -138,7 +139,7 @@ wait:
> copy = (ret == 1);
> }
> trace_stream_one_iteration(s, sector_num, n, ret);
> - if (ret >= 0 && copy) {
> + if (copy) {
> if (s->common.speed) {
> delay_ns = ratelimit_calculate_delay(&s->limit, n);
> if (delay_ns > 0) {
> --
> 1.7.10.4
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
next prev parent reply other threads:[~2013-09-23 12:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-22 6:19 [Qemu-devel] [PATCH v2] block: Fix compiler warning (-Werror=uninitialized) Stefan Weil
2013-09-23 12:12 ` Stefan Hajnoczi [this message]
2013-09-25 11:28 ` Kevin Wolf
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=20130923121253.GB3623@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=andreas.faerber@web.de \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
--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).