From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
qemu-block@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Ani Sinha" <ani@anisinha.ca>,
"Jean-Philippe Brucker" <jean-philippe@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Shannon Zhao" <shannon.zhaosl@gmail.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Peter Xu" <peterx@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Xiao Guangrong" <xiaoguangrong.eric@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Cédric Le Goater" <clg@kaod.org>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Greg Kurz" <groug@kaod.org>,
"Yuval Shaia" <yuval.shaia.ml@gmail.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Fam Zheng" <fam@euphon.net>, "Alexander Bulekov" <alxndr@bu.edu>,
"Bandan Das" <bsd@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH 3/5] bulk: Have object_child_foreach() take Error* and return boolean
Date: Thu, 23 Feb 2023 16:40:17 +0100 [thread overview]
Message-ID: <875ybss84e.fsf@pond.sub.org> (raw)
In-Reply-To: <20230216122524.67212-4-philmd@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Thu, 16 Feb 2023 13:25:22 +0100")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Following the Error API best practices documented in commit
> e3fe3988d7 ("error: Document Error API usage rules"), have the
> object_child_foreach[_recursive]() handler take a Error* argument
> and return a boolean indicating whether this error is set or not.
> Convert all handler implementations.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This patch does several things (no, I'm not going to ask to split it):
* Convert object_child_foreach() and object_child_foreach_recursive() to
the Error API: add parameter Error **errp, change return type from int
to bool.
Straightforward.
* Adjust the callers: pass the new argument.
Looks like you pass NULL, which makes sense for a conversion such as
this. Always NULL?
* Convert object_child_foreach()'s and
object_child_foreach_recursive()'s callback parameter to the Error
API: add parameter Error **errp, change return type from int to bool.
Straightforward.
* Adjust the actual callbacks: take the new parameter and use it
properly, return bool instead of int.
Either don't touch @errp and return true, or store an error to @errp
and return false.
You're not doing this at least in bmc_find(), see right below.
I don't have the time for checking all the callbacks today. Mind
doing that yourself?
[...]
> diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
> index 99f1e8d7f9..05acc88a55 100644
> --- a/hw/ppc/pnv_bmc.c
> +++ b/hw/ppc/pnv_bmc.c
> @@ -283,17 +283,17 @@ typedef struct ForeachArgs {
> Object *obj;
> } ForeachArgs;
>
> -static int bmc_find(Object *child, void *opaque)
> +static bool bmc_find(Object *child, void *opaque, Error **errp)
> {
> ForeachArgs *args = opaque;
>
> if (object_dynamic_cast(child, args->name)) {
> if (args->obj) {
> - return 1;
> + return false;
No error set here.
> }
> args->obj = child;
> }
> - return 0;
> + return true;
> }
>
> IPMIBmc *pnv_bmc_find(Error **errp)
[...]
next prev parent reply other threads:[~2023-02-23 15:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 12:25 [PATCH 0/5] bulk: Have object_child_foreach() take Error* and return boolean Philippe Mathieu-Daudé
2023-02-16 12:25 ` [PATCH 1/5] hw/nmi: Have nmi_monitor_handler() return a boolean indicating error Philippe Mathieu-Daudé
2023-02-23 15:26 ` Markus Armbruster
2023-02-16 12:25 ` [PATCH 2/5] spapr/ddw: Remove confuse return value in spapr_phb_get_free_liobn() Philippe Mathieu-Daudé
2023-02-17 10:31 ` Daniel Henrique Barboza
2023-02-16 12:25 ` [PATCH 3/5] bulk: Have object_child_foreach() take Error* and return boolean Philippe Mathieu-Daudé
2023-02-16 12:30 ` Michael S. Tsirkin
2023-02-23 15:40 ` Markus Armbruster [this message]
2023-02-16 12:25 ` [RFC PATCH 4/5] hw/nmi: Simplify nmi_monitor_handle() and do_nmi() Philippe Mathieu-Daudé
2023-02-16 12:25 ` [RFC PATCH 5/5] hw/ppc/pnv_bmc: Simplify pnv_bmc_find() Philippe Mathieu-Daudé
2023-02-16 18:12 ` Cédric Le Goater
2023-02-16 19:16 ` Philippe Mathieu-Daudé
2023-02-17 8:04 ` Cédric Le Goater
2023-02-23 15:42 ` Markus Armbruster
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=875ybss84e.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=alex.bennee@linaro.org \
--cc=alxndr@bu.edu \
--cc=ani@anisinha.ca \
--cc=berrange@redhat.com \
--cc=bsd@redhat.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=darren.kenny@oracle.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eduardo@habkost.net \
--cc=fam@euphon.net \
--cc=groug@kaod.org \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=kraxel@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shannon.zhaosl@gmail.com \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=xiaoguangrong.eric@gmail.com \
--cc=yuval.shaia.ml@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.