From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Markus Armbruster <armbru@redhat.com>
Cc: <qemu-devel@nongnu.org>, <odaki@rsg.ci.i.u-tokyo.ac.jp>,
<marcandre.lureau@redhat.com>
Subject: Re: [PATCH 03/12] hw/cxl: Convert cxl_fmws_link() to Error
Date: Fri, 8 Aug 2025 11:44:42 +0100 [thread overview]
Message-ID: <20250808114442.0000234d@huawei.com> (raw)
In-Reply-To: <20250808080823.2638861-4-armbru@redhat.com>
On Fri, 8 Aug 2025 10:08:14 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Functions that use an Error **errp parameter to return errors should
> not also report them to the user, because reporting is the caller's
> job. When the caller does, the error is reported twice. When it
> doesn't (because it recovered from the error), there is no error to
> report, i.e. the report is bogus.
>
> cxl_fmws_link_targets() violates this principle: it calls
> error_setg(&error_fatal, ...) via cxl_fmws_link(). Goes back to
> commit 584f722eb3ab (hw/cxl: Make the CXL fixed memory windows
> devices.) Currently harmless, because cxl_fmws_link_targets()'s
> callers always pass &error_fatal. Clean this up by converting
> cxl_fmws_link() to Error.
Patch is definitely an improvement though I'm no sure how
it is really a violation of the above principle given
it has no effect on being called twice for example.
>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
The -1 return is perhaps unrelated to the main thing here,
but does make more sense than return 1 so fair enough.
None of the above comments I've raised are that important to me though.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> ---
> hw/cxl/cxl-host.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
> index 5c2ce25a19..0d891c651d 100644
> --- a/hw/cxl/cxl-host.c
> +++ b/hw/cxl/cxl-host.c
> @@ -72,6 +72,7 @@ static void cxl_fixed_memory_window_config(CXLFixedMemoryWindowOptions *object,
>
> static int cxl_fmws_link(Object *obj, void *opaque)
> {
> + Error **errp = opaque;
> struct CXLFixedWindow *fw;
> int i;
>
> @@ -87,9 +88,9 @@ static int cxl_fmws_link(Object *obj, void *opaque)
> o = object_resolve_path_type(fw->targets[i], TYPE_PXB_CXL_DEV,
> &ambig);
> if (!o) {
> - error_setg(&error_fatal, "Could not resolve CXLFM target %s",
> + error_setg(errp, "Could not resolve CXLFM target %s",
> fw->targets[i]);
> - return 1;
> + return -1;
> }
> fw->target_hbs[i] = PXB_CXL_DEV(o);
> }
> @@ -99,7 +100,7 @@ static int cxl_fmws_link(Object *obj, void *opaque)
> void cxl_fmws_link_targets(Error **errp)
> {
> /* Order doesn't matter for this, so no need to build list */
> - object_child_foreach_recursive(object_get_root(), cxl_fmws_link, NULL);
> + object_child_foreach_recursive(object_get_root(), cxl_fmws_link, errp);
> }
>
> static bool cxl_hdm_find_target(uint32_t *cache_mem, hwaddr addr,
next prev parent reply other threads:[~2025-08-08 10:46 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 8:08 [PATCH 00/12] Error reporting cleanup, a fix, and &error_warn removal Markus Armbruster
2025-08-08 8:08 ` [PATCH 01/12] monitor: Clean up HMP gdbserver error reporting Markus Armbruster
2025-08-19 10:53 ` Daniel P. Berrangé
2025-09-09 11:22 ` Markus Armbruster
2025-08-08 8:08 ` [PATCH 02/12] tcg: Fix error reporting on mprotect() failure in tcg_region_init() Markus Armbruster
2025-08-08 14:00 ` Philippe Mathieu-Daudé
2025-08-19 10:56 ` Daniel P. Berrangé
2025-08-19 10:56 ` Daniel P. Berrangé
2025-08-08 8:08 ` [PATCH 03/12] hw/cxl: Convert cxl_fmws_link() to Error Markus Armbruster
2025-08-08 10:44 ` Jonathan Cameron via [this message]
2025-08-08 11:13 ` Markus Armbruster
2025-09-17 10:46 ` Markus Armbruster
2025-08-11 10:36 ` Philippe Mathieu-Daudé
2025-08-08 8:08 ` [PATCH 04/12] migration/cpr: Clean up error reporting in cpr_resave_fd() Markus Armbruster
2025-08-08 12:38 ` Steven Sistare
2025-08-08 13:55 ` Philippe Mathieu-Daudé
2025-08-08 14:08 ` Steven Sistare
2025-08-08 14:43 ` Markus Armbruster
2025-08-08 14:48 ` Steven Sistare
2025-08-08 15:04 ` Markus Armbruster
2025-08-08 8:08 ` [PATCH 05/12] hw/remote/vfio-user: Clean up error reporting Markus Armbruster
2025-08-08 8:08 ` [PATCH 06/12] net/slirp: " Markus Armbruster
2025-08-08 8:18 ` Marc-André Lureau
2025-08-19 11:10 ` Daniel P. Berrangé
2025-09-09 11:40 ` Markus Armbruster
2025-09-12 10:09 ` Daniel P. Berrangé
2025-08-08 8:08 ` [PATCH 07/12] ui/spice-core: " Markus Armbruster
2025-08-08 8:22 ` Marc-André Lureau
2025-08-19 11:15 ` Daniel P. Berrangé
2025-09-09 11:41 ` Markus Armbruster
2025-09-12 10:10 ` Daniel P. Berrangé
2025-08-08 8:08 ` [PATCH 08/12] util/oslib-win32: Revert warning on WSAEventSelect() failure Markus Armbruster
2025-08-08 8:22 ` Marc-André Lureau
2025-08-08 9:32 ` Markus Armbruster
2025-08-19 11:24 ` Daniel P. Berrangé
2025-09-09 11:50 ` Markus Armbruster
2025-09-12 10:13 ` Daniel P. Berrangé
2025-08-08 8:08 ` [PATCH 09/12] ui/pixman: Consistent error handling in qemu_pixman_shareable_free() Markus Armbruster
2025-08-08 8:16 ` Marc-André Lureau
2025-08-08 8:08 ` [PATCH 10/12] ui/dbus: Clean up dbus_update_gl_cb() error checking Markus Armbruster
2025-08-08 8:14 ` Marc-André Lureau
2025-08-08 8:08 ` [PATCH 11/12] ui/dbus: Consistent handling of texture mutex failure Markus Armbruster
2025-08-08 8:15 ` Marc-André Lureau
2025-08-08 8:08 ` [PATCH 12/12] error: Kill @error_warn Markus Armbruster
2025-08-08 14:02 ` Philippe Mathieu-Daudé
2025-08-08 14:45 ` Markus Armbruster
2025-08-09 7:07 ` Akihiko Odaki
2025-08-09 8:30 ` Markus Armbruster
2025-08-09 10:27 ` Akihiko Odaki
2025-08-09 14:42 ` Markus Armbruster
2025-08-19 11:26 ` Daniel P. Berrangé
2025-09-16 11:27 ` 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=20250808114442.0000234d@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
/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).