From: Miroslav Rezanina <mrezanin@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image compare
Date: Wed, 13 Nov 2013 03:55:59 -0500 (EST) [thread overview]
Message-ID: <795456228.30035773.1384332959394.JavaMail.root@redhat.com> (raw)
In-Reply-To: <1384315458-23417-1-git-send-email-famz@redhat.com>
----- Original Message -----
> From: "Fam Zheng" <famz@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: stefanha@redhat.com, kwolf@redhat.com, "Miroslav Rezanina" <mrezanin@redhat.com>
> Sent: Wednesday, November 13, 2013 5:04:18 AM
> Subject: [PATCH] qemu-img: Fix content mismatch offset of image compare
>
> We were lucky to pass qemu-iotests 048 (qemu-img compare case) but when
> I tried to run with TEST_DIR=/tmp (tmpfs), it fails with a very weird
> mismatch offset. This fixes the bug.
>
> In the if branch, setting ret to 1 before using it makes dead code in
> the next line: pnum is never added to mismatch offset even if ret was 0.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> qemu-img.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index bf3fb4f..2bab20d 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1020,10 +1020,10 @@ static int img_compare(int argc, char **argv)
> }
> ret = compare_sectors(buf1, buf2, nb_sectors, &pnum);
> if (ret || pnum != nb_sectors) {
> - ret = 1;
> qprintf(quiet, "Content mismatch at offset %" PRId64
> "!\n",
> sectors_to_bytes(
> ret ? sector_num : sector_num + pnum));
> + ret = 1;
> goto out;
> }
> }
> --
> 1.8.4.2
>
>
Correct fix, setting variable to constant before test is definitely wrong.
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
--
Miroslav Rezanina
Software Engineer - Virtualization Team
prev parent reply other threads:[~2013-11-13 8:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 4:04 [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image compare Fam Zheng
2013-11-13 5:24 ` [Qemu-devel] [PATCH] qemu-img: re-assign ret after reporting original error Amos Kong
2013-11-13 9:25 ` Kevin Wolf
2013-11-13 7:36 ` [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image compare Amos Kong
2013-11-13 8:55 ` Miroslav Rezanina [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=795456228.30035773.1384332959394.JavaMail.root@redhat.com \
--to=mrezanin@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.