]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: simplify bdrv_child_user_desc()
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tue, 1 Jun 2021 07:52:17 +0000 (10:52 +0300)
committerKevin Wolf <kwolf@redhat.com>
Wed, 2 Jun 2021 12:23:20 +0000 (14:23 +0200)
All child classes have this callback. So, drop unreachable code.

Still add an assertion to bdrv_attach_child_common(), to early detect
bad classes.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210601075218.79249-6-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index 94cb7b663742e62f149a1797f580cc01aa714039..3c0c3964ecba1a77348397ffb84013ab5b428bda 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2026,11 +2026,7 @@ bool bdrv_is_writable(BlockDriverState *bs)
 
 static char *bdrv_child_user_desc(BdrvChild *c)
 {
-    if (c->klass->get_parent_desc) {
-        return c->klass->get_parent_desc(c);
-    }
-
-    return g_strdup("another user");
+    return c->klass->get_parent_desc(c);
 }
 
 static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b, Error **errp)
@@ -2772,6 +2768,7 @@ static int bdrv_attach_child_common(BlockDriverState *child_bs,
 
     assert(child);
     assert(*child == NULL);
+    assert(child_class->get_parent_desc);
 
     new_child = g_new(BdrvChild, 1);
     *new_child = (BdrvChild) {