[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 09/11] block: Assert that drv->bdrv_child_perm is set
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 09/11] block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm() |
Date: |
Tue, 7 May 2019 17:18:17 +0200 |
From: Alberto Garcia <address@hidden>
There is no need to check for this because all block drivers that have
children implement bdrv_child_perm and all callers already ensure that
bs->drv is set.
Furthermore, if this check would fail then the callers would end up
with uninitialized values for nperm and nshared.
This patch replaces the check with an assertion.
Signed-off-by: Alberto Garcia <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 9ae5c0ed2f..7dc8fe289a 100644
--- a/block.c
+++ b/block.c
@@ -1743,11 +1743,10 @@ static void bdrv_child_perm(BlockDriverState *bs,
BlockDriverState *child_bs,
uint64_t parent_perm, uint64_t parent_shared,
uint64_t *nperm, uint64_t *nshared)
{
- if (bs->drv && bs->drv->bdrv_child_perm) {
- bs->drv->bdrv_child_perm(bs, c, role, reopen_queue,
- parent_perm, parent_shared,
- nperm, nshared);
- }
+ assert(bs->drv && bs->drv->bdrv_child_perm);
+ bs->drv->bdrv_child_perm(bs, c, role, reopen_queue,
+ parent_perm, parent_shared,
+ nperm, nshared);
/* TODO Take force_share from reopen_queue */
if (child_bs && child_bs->force_share) {
*nshared = BLK_PERM_ALL;
--
2.20.1
- [Qemu-block] [PULL 00/11] Block patches, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 01/11] qcow2-refcount: fix check_oflag_copied, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 02/11] qcow2-refcount: avoid eating RAM, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 04/11] qcow2-refcount: check_refcounts_l2: don't count fixed cluster as allocated, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 05/11] qcow2-refcount: don't mask corruptions under internal errors, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 03/11] qcow2-refcount: check_refcounts_l2: reduce ignored overlaps, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 06/11] qcow2: discard bitmap when removed, Max Reitz, 2019/05/07
- [Qemu-block] [PULL 07/11] block/ssh: Implement .bdrv_refresh_filename(), Max Reitz, 2019/05/07
- [Qemu-block] [PULL 08/11] block/ssh: Implement .bdrv_dirname(), Max Reitz, 2019/05/07
- [Qemu-block] [PULL 09/11] block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm(),
Max Reitz <=
- [Qemu-block] [PULL 10/11] commit: Use bdrv_append() in commit_start(), Max Reitz, 2019/05/07
- [Qemu-block] [PULL 11/11] iotests: Fix iotests 110 and 126, Max Reitz, 2019/05/07
- Re: [Qemu-block] [PULL 00/11] Block patches, Peter Maydell, 2019/05/09