Received: from eggs.gnu.org ([209.51.188.92]:40778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hC0ZS-0007HT-No for qemu-devel@nongnu.org; Thu, 04 Apr 2019 07:30:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hC0ZR-0002HS-RX for qemu-devel@nongnu.org; Thu, 04 Apr 2019 07:30:14 -0400 From: Alberto Garcia Date: Thu, 4 Apr 2019 14:29:53 +0300 Message-Id: <20190404112953.4058-1-berto@igalia.com> Subject: [Qemu-devel] [PATCH for-4.1] block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alberto Garcia , qemu-block@nongnu.org, Kevin Wolf , Max Reitz 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 --- block.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 3050854528..5f92565692 100644 --- a/block.c +++ b/block.c @@ -1742,11 +1742,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.11.0