From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgUzt-0008Vi-E3 for qemu-devel@nongnu.org; Wed, 13 Nov 2013 02:36:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgUzn-0005UO-DU for qemu-devel@nongnu.org; Wed, 13 Nov 2013 02:36:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgUzn-0005U8-5F for qemu-devel@nongnu.org; Wed, 13 Nov 2013 02:36:15 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAD7aE6W014425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Nov 2013 02:36:14 -0500 Date: Wed, 13 Nov 2013 15:36:10 +0800 From: Amos Kong Message-ID: <20131113073610.GA17674@amosk.info> References: <1384315458-23417-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1384315458-23417-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qemu-img: Fix content mismatch offset of image compare List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, Miroslav Rezanina , qemu-devel@nongnu.org, stefanha@redhat.com On Wed, Nov 13, 2013 at 12:04:18PM +0800, Fam Zheng wrote: > 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 > --- > 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; Looks good > goto out; > } > } > -- > 1.8.4.2 > -- Amos.