[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 38/38] block: get_block_status: use "else" when testi
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 38/38] block: get_block_status: use "else" when testing the opposite condition |
Date: |
Fri, 22 May 2015 10:02:10 +0100 |
From: Paolo Bonzini <address@hidden>
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>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/io.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/block/io.c b/block/io.c
index 284784e..e394d92 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) {
--
2.1.0
- [Qemu-devel] [PULL 28/38] configure: handle clang -nopie argument warning, (continued)
- [Qemu-devel] [PULL 28/38] configure: handle clang -nopie argument warning, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 27/38] block/parallels: improve image writing performance further, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 29/38] configure: factor out supported flag check, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 25/38] block/parallels: add prealloc-mode and prealloc-size open paramemets, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 30/38] configure: silence glib unknown attribute __alloc_size__, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 31/38] configure: Add workaround for ccache and clang, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 33/38] block: minimal bounce buffer alignment, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 34/38] block: align bounce buffers to page, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 35/38] Revert "block: Fix unaligned zero write", Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 32/38] block: return EPERM on writes or discards to read-only devices, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 38/38] block: get_block_status: use "else" when testing the opposite condition,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 37/38] qemu-iotests: Test unaligned sub-block zero write, Stefan Hajnoczi, 2015/05/22
- [Qemu-devel] [PULL 36/38] block: Fix NULL deference for unaligned write if qiov is NULL, Stefan Hajnoczi, 2015/05/22
- Re: [Qemu-devel] [PULL 00/38] Block patches, Peter Maydell, 2015/05/22