[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block: get_block_status: use "else" when testin
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH] block: get_block_status: use "else" when testing the opposite condition |
Date: |
Thu, 14 May 2015 22:09:25 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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 <address@hidden>
> ---
> 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 <address@hidden>