[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v6 1/9] block: Always set *file in get_block_status
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v6 1/9] block: Always set *file in get_block_status |
Date: |
Fri, 13 Jan 2017 21:52:29 +0100 |
*file should always be set (to NULL, if nothing else) instead of leaving
it dangling sometimes. This should also be documented so callers can
rely on this behavior.
Signed-off-by: Max Reitz <address@hidden>
---
block/io.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index 4f005623f7..ff693d7f73 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1709,7 +1709,8 @@ typedef struct BdrvCoGetBlockStatusData {
* beyond the end of the disk image it will be clamped.
*
* If returned value is positive and BDRV_BLOCK_OFFSET_VALID bit is set, 'file'
- * points to the BDS which the sector range is allocated in.
+ * points to the BDS which the sector range is allocated in. If the block
driver
+ * does not set 'file', it will be set to NULL.
*/
static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
@@ -1720,6 +1721,8 @@ static int64_t coroutine_fn
bdrv_co_get_block_status(BlockDriverState *bs,
int64_t n;
int64_t ret, ret2;
+ *file = NULL;
+
total_sectors = bdrv_nb_sectors(bs);
if (total_sectors < 0) {
return total_sectors;
@@ -1744,7 +1747,6 @@ static int64_t coroutine_fn
bdrv_co_get_block_status(BlockDriverState *bs,
return ret;
}
- *file = NULL;
bdrv_inc_in_flight(bs);
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
file);
--
2.11.0
- [Qemu-block] [PATCH v6 0/9] block: Drop BDS.filename, Max Reitz, 2017/01/13
- [Qemu-block] [PATCH v6 1/9] block: Always set *file in get_block_status,
Max Reitz <=
- [Qemu-block] [PATCH v6 2/9] block: Change bdrv_get_encrypted_filename(), Max Reitz, 2017/01/13
- [Qemu-block] [PATCH v6 3/9] block: Avoid BlockDriverState.filename, Max Reitz, 2017/01/13
- [Qemu-block] [PATCH v6 4/9] block: Do not blindly copy filename from file, Max Reitz, 2017/01/13
- [Qemu-block] [PATCH v6 5/9] block: Add bdrv_filename(), Max Reitz, 2017/01/13
- [Qemu-block] [PATCH v6 9/9] iotests: Test changed Quorum filename, Max Reitz, 2017/01/16
- [Qemu-block] [PATCH v6 8/9] block: Complete move to pull filename updates, Max Reitz, 2017/01/16