From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, famz@redhat.com, jsnow@redhat.com,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 0/4] block: Avoid copy-on-read assertions
Date: Mon, 2 Oct 2017 16:50:30 +0200 [thread overview]
Message-ID: <20171002145030.GC4362@localhost.localdomain> (raw)
In-Reply-To: <4cac1113-5d6a-3dd1-1ef0-6fde5482a125@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]
Am 01.10.2017 um 00:05 hat Eric Blake geschrieben:
> On 09/30/2017 04:19 PM, no-reply@patchew.org wrote:
> > Hi,
> >
> > This series failed build test on s390x host. Please find the details below.
> >
>
> > /var/tmp/patchew-tester-tmp-a2p2tpcc/src/block/io.c: In function ‘bdrv_aligned_preadv’:
> > /var/tmp/patchew-tester-tmp-a2p2tpcc/src/block/io.c:955:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > int ret;
> > ^~~
>
> Blah - I compiled with -g instead of -O2, which masks this warning in my
> setup.
>
> The warning is a false negative (the error message is actually pointing
> to a line in bdrv_co_do_copy_on_readv - but the compiler must have
> inlined it into bdrv_aligned_preadv) - the function is only ever called
> with non-zero bytes, and therefore the 'while (cluster_bytes)' loop will
> execute at least once, and ret always gets assigned. But the compiler
> can't see that, so I'll squash this in:
Well, you could help the compiler with this:
assert(cluster_bytes > 0);
Then it compiles. Unfortunately, the compiler was right and you weren't:
$ ./qemu-io -C -c 'read 0 0' /tmp/test.qcow2
qemu-io: block/io.c:988: bdrv_co_do_copy_on_readv: Assertion `cluster_bytes > 0' failed.
Abgebrochen (Speicherabzug geschrieben)
Maybe a case to add to the test?
> commit a201636c3133827bd632d5fdd9eb1f5df81d0e0e
> Author: Eric Blake <eblake@redhat.com>
> Date: Sat Sep 30 14:27:51 2017 -0500
>
> fixup! block: Perform copy-on-read in loop
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> diff --git a/block/io.c b/block/io.c
> index 5ef5adc7a7..e7519464bb 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -952,7 +952,7 @@ static int coroutine_fn
> bdrv_co_do_copy_on_readv(BdrvChild *child,
> int64_t cluster_offset;
> unsigned int cluster_bytes;
> size_t skip_bytes;
> - int ret;
> + int ret = 0;
> int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
> BDRV_REQUEST_MAX_BYTES);
> unsigned int progress = 0;
I would prefer a ret = 0 immediately before err: so that we'll still get
warning if we forget assigning ret in any future error path.
Kevin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2017-10-02 14:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-30 19:53 [Qemu-devel] [PATCH 0/4] block: Avoid copy-on-read assertions Eric Blake
2017-09-30 19:53 ` [Qemu-devel] [PATCH 1/4] qemu-io: Add -C for opening with copy-on-read Eric Blake
2017-10-01 3:00 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-10-02 14:52 ` [Qemu-devel] " Kevin Wolf
2017-10-02 18:03 ` John Snow
2017-10-02 19:28 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-09-30 19:53 ` [Qemu-devel] [PATCH 2/4] block: Add blkdebug hook for copy-on-read Eric Blake
2017-10-01 3:00 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-10-02 14:52 ` [Qemu-devel] " Kevin Wolf
2017-10-02 18:08 ` John Snow
2017-10-02 19:28 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-09-30 19:53 ` [Qemu-devel] [PATCH 3/4] block: Perform copy-on-read in loop Eric Blake
2017-09-30 20:11 ` [Qemu-devel] [PATCH 4/4] iotests: Add test 197 for covering copy-on-read Eric Blake
2017-10-01 3:03 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-10-02 13:55 ` Eric Blake
2017-10-02 14:04 ` Jeff Cody
2017-09-30 21:19 ` [Qemu-devel] [PATCH 0/4] block: Avoid copy-on-read assertions no-reply
2017-09-30 22:05 ` Eric Blake
2017-10-02 14:50 ` Kevin Wolf [this message]
2017-10-02 15:10 ` Eric Blake
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=20171002145030.GC4362@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).