]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm()
authorAlberto Garcia <berto@igalia.com>
Thu, 4 Apr 2019 11:29:53 +0000 (14:29 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 7 May 2019 15:14:21 +0000 (17:14 +0200)
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 <berto@igalia.com>
Message-id: 20190404112953.4058-1-berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index 9ae5c0ed2f2bf50fbf4c47e2e81077c1a5932302..7dc8fe289abcae700515aa556f30ea5ce2c54e0f 100644 (file)
--- 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;