From: Paolo Bonzini Date: Thu, 14 May 2015 10:35:02 +0000 (+0200) Subject: block: get_block_status: use "else" when testing the opposite condition X-Git-Tag: qemu-xen-4.7.0-rc1~299^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a53f1a95f9605f300fbafbc8b60b8a8c67e9c4b4;p=qemu-xen.git block: get_block_status: use "else" when testing the opposite condition 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 Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Message-id: 1431599702-10431-1-git-send-email-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi --- diff --git a/block/io.c b/block/io.c index 284784eea1..e394d92626 100644 --- a/block/io.c +++ b/block/io.c @@ -1521,9 +1521,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) {