From nobody Fri Nov 14 02:15:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1584003672; cv=none; d=zohomail.com; s=zohoarc; b=cllvuMCyA20FJENo3eCNShoyRq8AoUt7HTyo+G0Nqpw2QK/8EV/Zweid27dtNT9ovrecaQLEim444+ju51Cpurqn3tscxXKJD9Z6sqpgsW08TzDmFxptc5xPCRiQl5/BZmJP7zBLODsauYvMlDz+PtErAvSHRC3PjN/KDfZQmo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584003672; h=Content-Type: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; bh=iZ5KSBMMchwQplb7Nasj1nIDPDK99nh5LVhMiQmxtcU=; b=Ploxhv/TzCNGDh/Ci4o++3xeCLzBuQa9W78VWkhK1XSgJLthmwuZlqdhivruVqD6cfEGNdrbXrG9QXqWjEMCsitx9G1mkP4lgKtQ1qh+rPOZ9UBnOZTRAK5XXv7x1gFP/1RVVELK61J9agOR8CwwJEHpnGFF65IPQYjB9zBlRC4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584003672294569.4054327233687; Thu, 12 Mar 2020 02:01:12 -0700 (PDT) Received: from localhost ([::1]:37934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJiJ-0000IF-5q for importer@patchew.org; Thu, 12 Mar 2020 05:01:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51515) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJh7-0006o8-23 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:59:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCJh5-0004ms-81 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:59:56 -0400 Received: from relay.sw.ru ([185.231.240.75]:48396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCJh5-0004ln-19 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:59:55 -0400 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jCJgv-0004Ve-FG; Thu, 12 Mar 2020 11:59:45 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v9 06/10] fw_cfg: introduce ERRP_AUTO_PROPAGATE Date: Thu, 12 Mar 2020 11:59:32 +0300 Message-Id: <20200312085936.9552-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200312085936.9552-1-vsementsov@virtuozzo.com> References: <20200312085936.9552-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , armbru@redhat.com, Greg Kurz , Gerd Hoffmann , Laszlo Ersek Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 179b302f01..22ff2be0c0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1142,12 +1142,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 @@ -1193,14 +1192,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.21.0