qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image


From: Miroslav Rezanina
Subject: Re: [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image compare
Date: Wed, 13 Nov 2013 03:55:59 -0500 (EST)

----- Original Message -----
> From: "Fam Zheng" <address@hidden>
> To: address@hidden
> Cc: address@hidden, address@hidden, "Miroslav Rezanina" <address@hidden>
> 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 <address@hidden>
> ---
>  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 <address@hidden> 

-- 
Miroslav Rezanina
Software Engineer - Virtualization Team



reply via email to

[Prev in Thread] Current Thread [Next in Thread]