From nobody Thu Dec 18 13:25:05 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557242787; cv=none; d=zoho.com; s=zohoarc; b=orRUChyY2D4z27hfVFqjMwSseB7pCZsve4r77G16rptOGLs8G/Ky3cPaVQW+zr87UX1Whh64vGtVC/1ZqMT/kiikR+Wvi34VOC1vgEsrdOnRjHl58+1L1FI2oBTZcdZClzl1d3AhJqe6GXgzMoxR4weH2fYseIj3WUCQYdAQwug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242787; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MjjpQ7el3gN1VULtrZUrThQgelzbs3gGZmsnx+u4AGU=; b=Dz7ZXZOtQThCSefMDHrUtU9pqPEIzfkeWjPbOHA/rvYJsrXHqCPGzMm6TLAOwXrcz0bTESE4kpivqWWFL2N9xCnUbpqJFJxTWhIQh2hI04xf2tshEG+KXItPmNzEnD5rxQIL5P7ECk2un7gAVb1BZEacd3fWV3zxul0XhG3WED0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557242787536509.92081401170935; Tue, 7 May 2019 08:26:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:48576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1z2-00068B-4y for importer@patchew.org; Tue, 07 May 2019 11:26:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO1rj-000857-Am for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO1ri-000440-E1 for qemu-devel@nongnu.org; Tue, 07 May 2019 11:18:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50236) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hO1rg-00042E-8P; Tue, 07 May 2019 11:18:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C086C05D3FD; Tue, 7 May 2019 15:18:43 +0000 (UTC) Received: from localhost (unknown [10.40.205.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24E5D3DA5; Tue, 7 May 2019 15:18:42 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 7 May 2019 17:18:17 +0200 Message-Id: <20190507151819.17401-10-mreitz@redhat.com> In-Reply-To: <20190507151819.17401-1-mreitz@redhat.com> References: <20190507151819.17401-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 May 2019 15:18:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/11] block: Assert that drv->bdrv_child_perm is set in bdrv_child_perm() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Alberto Garcia 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 Message-id: 20190404112953.4058-1-berto@igalia.com Signed-off-by: Max Reitz --- 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, B= lockDriverState *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 =3D BLK_PERM_ALL; --=20 2.20.1