From nobody Tue Feb 10 05:41:47 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1597725353; cv=none; d=zohomail.com; s=zohoarc; b=OUNHbRFzDkl5PtVOQ4fblqpspY+YUGYu0u5Sy6imBLMGWmfNhoFuneY+b3tKYxWkvhz+fEgWA2pZ+gZXXupB7cwk/3W0JDzlHUGzSH6wmKT+OCF5GF781S/kOkn1J3wsxHs2mwzv0Fkj3wONGULAyiljlay1DSKfRbCogSwKw7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597725353; 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; bh=8SiAh49sa/pZW5FKnlVgtSlFx/HnCO4G4Jbpa/uH/xc=; b=ZvdhrC/QvhQasK3cr/IQqXNh3kSf9uNASj5jsJzcgIHqpjRop523p3CPGcP0OOWQKI33AJ/C0MUXIZtFVtUmp9eZmEYjN6Q+oWPVMPI8XOxiywhfMXPbutIMN+PllUT0ZVBZH2b7UFMtgA6ijSf3t7547SJSxsGVYcZVWM7uvvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597725353307325.6825919142158; Mon, 17 Aug 2020 21:35:53 -0700 (PDT) Received: from localhost ([::1]:37262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k7tLk-0002Hq-4h for importer@patchew.org; Tue, 18 Aug 2020 00:35:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7t6d-00005a-56; Tue, 18 Aug 2020 00:20:15 -0400 Received: from ozlabs.org ([203.11.71.1]:58825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7t6a-0006Oh-AT; Tue, 18 Aug 2020 00:20:14 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4BVyNf0vsjz9sVl; Tue, 18 Aug 2020 14:19:29 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1597724370; bh=1da+r63XMtfDKfovfHV2ixQ8/lrIVVmvb8+ZRQhBjuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0v1hKrhYwcsiNQ+fm17n7pDcN14Qum9N/UtgU5n4cqMXgJVeZdDK6CTQ9XA6B/6w fGM7mYBc1V643oW7MBpJaPRyg8Qt0PbZOzBawmXxiY+lDloIHQaXQSqvkCMonP310m o3I4iCiT3ngeLO1w6byi45/5XTVnoImkBujak3IU= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 25/40] spapr: Simplify error handling in spapr_phb_realize() Date: Tue, 18 Aug 2020 14:19:07 +1000 Message-Id: <20200818041922.251708-26-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818041922.251708-1-david@gibson.dropbear.id.au> References: <20200818041922.251708-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/18 00:19:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz The spapr_phb_realize() function has a local_err variable which is used to: 1) check failures of spapr_irq_findone() and spapr_irq_claim() 2) prepend extra information to the error message Recent work from Markus Armbruster highlighted we get better code when testing the return value of a function, rather than setting up all the local_err boiler plate. For similar reasons, it is now preferred to use ERRP_GUARD() and error_prepend() rather than error_propagate_prepend(). Since spapr_irq_findone() and spapr_irq_claim() return negative values in case of failure, do both changes. This is just cleanup, no functional impact. Signed-off-by: Greg Kurz Reviewed-by: Markus Armbruster Reviewed-by: David Gibson Message-Id: <159707843851.1489912.6108405733810934642.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 363cdb3f7b..0a418f1e67 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1796,6 +1796,7 @@ static void spapr_phb_destroy_msi(gpointer opaque) =20 static void spapr_phb_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user * tries to add a sPAPR PHB to a non-pseries machine. */ @@ -1813,7 +1814,6 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) uint64_t msi_window_size =3D 4096; SpaprTceTable *tcet; const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); - Error *local_err =3D NULL; =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries mach= ine"); @@ -1964,13 +1964,12 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) =20 /* Initialize the LSI table */ for (i =3D 0; i < PCI_NUM_PINS; i++) { - uint32_t irq =3D SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + = i; + int irq =3D SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i; =20 if (smc->legacy_irq_allocation) { - irq =3D spapr_irq_findone(spapr, &local_err); - if (local_err) { - error_propagate_prepend(errp, local_err, - "can't allocate LSIs: "); + irq =3D spapr_irq_findone(spapr, errp); + if (irq < 0) { + error_prepend(errp, "can't allocate LSIs: "); /* * Older machines will never support PHB hotplug, ie, this= is an * init only path and QEMU will terminate. No need to roll= back. @@ -1979,9 +1978,8 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) } } =20 - spapr_irq_claim(spapr, irq, true, &local_err); - if (local_err) { - error_propagate_prepend(errp, local_err, "can't allocate LSIs:= "); + if (spapr_irq_claim(spapr, irq, true, errp) < 0) { + error_prepend(errp, "can't allocate LSIs: "); goto unrealize; } =20 --=20 2.26.2