From nobody Tue Feb 10 05:44:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594140682; cv=none; d=zohomail.com; s=zohoarc; b=NPV9t3QYVQ1R0Y6X++6TlkwqUdv9osmr360CBINOee5f4J4eGfnCGQCxfQ4mvbhW43qWtRt4Bsvt0sljSp59j96Ov9hZlq9bH6GMSYs8pOvhwIpyHmzPyilihk88kIjw8Cr9GA95gCKLewu4S5ZpUTHMc3xJjf0ckQOvF6YWtwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594140682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XdaTtnXzRdmtkraOf3fJnKW205wPYgtaTPC/KbxTb9A=; b=JPpECKPrXTYZBNrW4zHDrzrZZ5Adh3KGUQWeXyh9+kY5BdUPzILTcX9EpypnKhBSX8I87jdnkclS2hZnGHDXQXuece3U2kFCQ+cjVClOGSEfqkOFA5rhjG/5X8b9gFi1V1WLdSVD+tEZU/KUITiR+l2wYnnTfxPdgRQAukg5npI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1594140682936855.6776872158329; Tue, 7 Jul 2020 09:51:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jsqoI-0000La-JJ; Tue, 07 Jul 2020 16:51:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jsqoI-0000Dr-2X for xen-devel@lists.xenproject.org; Tue, 07 Jul 2020 16:51:10 +0000 Received: from us-smtp-delivery-1.mimecast.com (unknown [207.211.31.81]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 0d763faa-c072-11ea-bca7-bc764e2007e4; Tue, 07 Jul 2020 16:51:07 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-CKUKUa5lMlaT6ynxi7hKYw-1; Tue, 07 Jul 2020 12:51:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5205D804001; Tue, 7 Jul 2020 16:51:00 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-143.ams2.redhat.com [10.36.112.143]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8857B512FE; Tue, 7 Jul 2020 16:50:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2D1D711326EC; Tue, 7 Jul 2020 18:50:37 +0200 (CEST) X-Inumbo-ID: 0d763faa-c072-11ea-bca7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594140667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XdaTtnXzRdmtkraOf3fJnKW205wPYgtaTPC/KbxTb9A=; b=Fq3QyNnWigSpK4O9xGqOTT18QL3trFM8gGVZmNqJq6lMxkPZw0YwVEkCWIs8hduFBd5vuP tJZ0tvlx30FriOcF7LQ6Z4Q9t6/viBz80ReAqmzEuHYUUSo/bsDorgAVirWPQNO80smXhy mCPOCLXEknHjGgt7M5xTEQLpOExN+FE= X-MC-Unique: CKUKUa5lMlaT6ynxi7hKYw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v12 5/8] fw_cfg: Use ERRP_AUTO_PROPAGATE() Date: Tue, 7 Jul 2020 18:50:34 +0200 Message-Id: <20200707165037.1026246-6-armbru@redhat.com> In-Reply-To: <20200707165037.1026246-1-armbru@redhat.com> References: <20200707165037.1026246-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Michael Roth , qemu-block@nongnu.org, Paul Durrant , Laszlo Ersek , Christian Schoenebeck , groug@kaod.org, Max Reitz , Stefano Stabellini , Gerd Hoffmann , Stefan Hajnoczi , Anthony Perard , xen-devel@lists.xenproject.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Vladimir Sementsov-Ogievskiy If we want to add some info to errp (by error_prepend() or error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro. Otherwise, this info will not be added when errp =3D=3D &error_fatal (the program will exit prior to the error_append_hint() or error_prepend() call). Fix such cases. If we want to check error after errp-function call, we need to introduce local_err and then propagate it to errp. Instead, use ERRP_AUTO_PROPAGATE macro, benefits are: 1. No need of explicit error_propagate call 2. No need of explicit local_err variable: use errp directly 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or &error_fatal, this means that we don't break error_abort (we'll abort on error_set, not on error_propagate) This commit is generated by command sed -n '/^Firmware configuration (fw_cfg)$/,/^$/{s/^F: //p}' \ MAINTAINERS | \ xargs git ls-files | grep '\.[hc]$' | \ xargs spatch \ --sp-file scripts/coccinelle/auto-propagated-errp.cocci \ --macro-file scripts/cocci-macro-file.h \ --in-place --no-show-diff --max-width 80 Reported-by: Kevin Wolf Reported-by: Greg Kurz Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Philippe Mathieu-Daud=C3=A9 [Commit message tweaked] Signed-off-by: Markus Armbruster --- hw/nvram/fw_cfg.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 0408a31f8e..d5386c3235 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1231,12 +1231,11 @@ static Property fw_cfg_io_properties[] =3D { =20 static void fw_cfg_io_realize(DeviceState *dev, Error **errp) { + ERRP_AUTO_PROPAGATE(); FWCfgIoState *s =3D FW_CFG_IO(dev); - Error *local_err =3D NULL; =20 - fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); - if (local_err) { - error_propagate(errp, local_err); + fw_cfg_file_slots_allocate(FW_CFG(s), errp); + if (*errp) { return; } =20 @@ -1282,14 +1281,13 @@ static Property fw_cfg_mem_properties[] =3D { =20 static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) { + ERRP_AUTO_PROPAGATE(); FWCfgMemState *s =3D FW_CFG_MEM(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); const MemoryRegionOps *data_ops =3D &fw_cfg_data_mem_ops; - Error *local_err =3D NULL; =20 - fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); - if (local_err) { - error_propagate(errp, local_err); + fw_cfg_file_slots_allocate(FW_CFG(s), errp); + if (*errp) { return; } =20 --=20 2.26.2