From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: "Daniel Henrique Barboza" <danielhb@linux.ibm.com>,
qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH for-5.2 5/5] spapr: Simplify error handling in spapr_phb_realize()
Date: Thu, 6 Aug 2020 15:10:42 +1000 [thread overview]
Message-ID: <20200806051042.GE100968@yekko.fritz.box> (raw)
In-Reply-To: <159664895189.638781.16853044840437361763.stgit@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 3611 bytes --]
On Wed, Aug 05, 2020 at 07:35:51PM +0200, Greg Kurz wrote:
> 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 <groug@kaod.org>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> Note that the int32_t=>int followup change suggested by Markus was squashed
> into this patch.
> ---
> 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 363cdb3f7b8d..0a418f1e6711 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)
>
> 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 = 4096;
> SpaprTceTable *tcet;
> const unsigned windows_supported = spapr_phb_windows_supported(sphb);
> - Error *local_err = NULL;
>
> if (!spapr) {
> error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries machine");
> @@ -1964,13 +1964,12 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>
> /* Initialize the LSI table */
> for (i = 0; i < PCI_NUM_PINS; i++) {
> - uint32_t irq = SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i;
> + int irq = SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i;
>
> if (smc->legacy_irq_allocation) {
> - irq = spapr_irq_findone(spapr, &local_err);
> - if (local_err) {
> - error_propagate_prepend(errp, local_err,
> - "can't allocate LSIs: ");
> + irq = 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 rollback.
> @@ -1979,9 +1978,8 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> }
> }
>
> - 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;
> }
>
>
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-08-06 12:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 17:35 [PATCH for-5.2 0/5] spapr: Cleanups for XIVE and PHB Greg Kurz
2020-08-05 17:35 ` [PATCH for-5.2 1/5] spapr/xive: Fix xive->fd if kvm_create_device() fails Greg Kurz
2020-08-06 5:05 ` David Gibson
2020-08-05 17:35 ` [PATCH for-5.2 2/5] spapr/xive: Simplify kvmppc_xive_disconnect() Greg Kurz
2020-08-06 5:05 ` David Gibson
2020-08-05 17:35 ` [PATCH for-5.2 3/5] ppc/xive: Introduce dedicated kvm_irqchip_in_kernel() wrappers Greg Kurz
2020-08-06 5:08 ` David Gibson
2020-08-06 9:23 ` Greg Kurz
2020-08-05 17:35 ` [PATCH for-5.2 4/5] spapr/xive: Convert KVM device fd checks to assert() Greg Kurz
2020-08-06 5:09 ` David Gibson
2020-08-05 17:35 ` [PATCH for-5.2 5/5] spapr: Simplify error handling in spapr_phb_realize() Greg Kurz
2020-08-06 5:10 ` David Gibson [this message]
2020-08-05 17:43 ` [PATCH for-5.2 0/5] spapr: Cleanups for XIVE and PHB no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200806051042.GE100968@yekko.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=danielhb@linux.ibm.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).