From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YstpN-0006qU-R4 for qemu-devel@nongnu.org; Thu, 14 May 2015 10:09:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YstpH-0002yF-Rw for qemu-devel@nongnu.org; Thu, 14 May 2015 10:09:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YstpH-0002wo-KX for qemu-devel@nongnu.org; Thu, 14 May 2015 10:09:27 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4EE9RU2003151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 14 May 2015 10:09:27 -0400 Date: Thu, 14 May 2015 22:09:25 +0800 From: Fam Zheng Message-ID: <20150514140925.GE22867@ad.nay.redhat.com> References: <1431599702-10431-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431599702-10431-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH] block: get_block_status: use "else" when testing the opposite condition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, stefanha@redhat.com On Thu, 05/14 12:35, Paolo Bonzini wrote: > A bit of Boolean algebra (and common sense) tells us that the > second "if" here is looking for blocks that are not allocated. > This is the opposite of the "if" that sets BDRV_BLOCK_ALLOCATED, > and thus it can use an "else". > > Signed-off-by: Paolo Bonzini > --- > block/io.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/block/io.c b/block/io.c > index 1ce62c4..494e3b3 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -1456,9 +1456,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, > > if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { > ret |= BDRV_BLOCK_ALLOCATED; > - } > - > - if (!(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO)) { > + } else { > if (bdrv_unallocated_blocks_are_zero(bs)) { > ret |= BDRV_BLOCK_ZERO; > } else if (bs->backing_hd) { > -- > 2.4.0 > Reviewed-by: Fam Zheng