]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Fix bdrv_is_allocated() return value
authorKevin Wolf <kwolf@redhat.com>
Mon, 7 Jul 2014 15:00:37 +0000 (17:00 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 9 Jul 2014 13:50:11 +0000 (15:50 +0200)
bdrv_is_allocated() should return either 0 or 1 in successful cases.
We're lucky that currently, the callers that rely on this (e.g. because
they check for ret == 1) don't seem to break badly. They just might skip
some optimisation or in the case of qemu-io 'map' print separate lines
where a single line would suffice. In theory, a wrong allocation status
could lead to image corruption with certain operations, so let's fix
this quickly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block.c

diff --git a/block.c b/block.c
index 8800a6b5b37215f8c264676dce5857e2d206a8b4..c9629a44b99c8adf0de3c58e879c73118e8559f8 100644 (file)
--- a/block.c
+++ b/block.c
@@ -4040,7 +4040,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
     if (ret < 0) {
         return ret;
     }
-    return (ret & BDRV_BLOCK_ALLOCATED);
+    return !!(ret & BDRV_BLOCK_ALLOCATED);
 }
 
 /*