qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [PULL v2 05/25] error: add global &error_warn destination
Date: Thu, 6 Apr 2023 16:04:29 +0100	[thread overview]
Message-ID: <CAFEAcA_auAxVC-U80j4LuDWEXEbQysPcFcx-zkLeP5WXP3s6eQ@mail.gmail.com> (raw)
In-Reply-To: <328a2ae2-ca27-0dee-6fae-7536128955bd@linux.ibm.com>

On Thu, 6 Apr 2023 at 16:00, Stefan Berger <stefanb@linux.ibm.com> wrote:
>
>
>
> On 4/6/23 10:36, Peter Maydell wrote:
> > On Thu, 6 Apr 2023 at 15:13, Stefan Berger <stefanb@linux.ibm.com> wrote:
> >> I'll be out starting tomorrow. I don't see Marc-André online.
> >>
> >> Would this be acceptable?
> >> It ensures that if error_handle() returns, err has been freed.
> >> In the other two cases a copy is being made of the Error that can then be used after the error_handle() call.
> >
> > "Not error_warn" is the common case, so it doesn't seem
> > great to copy the error around like that. My thoughts were
> > either:
> >   (1) error_handle() should handle all of the error cases,
> > like this:
> >
> >      if (errp == &error_abort) {
> >         ...
> >         abort();
> >      }
> >      if (errp == &error_fatal) {
> >         ...
> >         exit(1);
> >      }
> >      if (errp = &error_warn) {
> >          warn_report_err(err);
> >      } else if (errp && !*errp) {
> >          *errp = err;
> >      } else {
> >          error_free(err);
> >      }
> >
> > and delete the "set *errp" logic from the callers.
>
>
> Like this?
>
> diff --git a/util/error.c b/util/error.c
> index 5537245da6..e5e247209a 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -46,6 +46,10 @@ static void error_handle(Error **errp, Error *err)
>       }
>       if (errp == &error_warn) {
>           warn_report_err(err);
> +    } else if (errp && !*errp) {
> +        *errp = err;
> +    } else {
> +        error_free(err);
>       }
>   }
>
> @@ -76,7 +80,6 @@ static void error_setv(Error **errp,
>       err->func = func;
>
>       error_handle(errp, err);
> -    *errp = err;
>
>       errno = saved_errno;
>   }
> @@ -289,11 +292,6 @@ void error_propagate(Error **dst_errp, Error *local_err)
>           return;
>       }
>       error_handle(dst_errp, local_err);
> -    if (dst_errp && !*dst_errp) {
> -        *dst_errp = local_err;
> -    } else {
> -        error_free(local_err);
> -    }
>   }
>
>   void error_propagate_prepend(Error **dst_errp, Error *err,

Yes, that's what I had in mind.

-- PMM


  reply	other threads:[~2023-04-06 15:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 11:46 [PULL v2 00/25] Win socket patches marcandre.lureau
2023-03-13 11:46 ` [PULL v2 01/25] util: drop qemu_fork() marcandre.lureau
2023-03-13 11:46 ` [PULL v2 02/25] tests: use closesocket() marcandre.lureau
2023-03-13 11:46 ` [PULL v2 03/25] io: " marcandre.lureau
2023-03-13 11:46 ` [PULL v2 04/25] tests: add test-error-report marcandre.lureau
2023-03-13 11:46 ` [PULL v2 05/25] error: add global &error_warn destination marcandre.lureau
2023-04-06 13:16   ` Peter Maydell
2023-04-06 13:17     ` Peter Maydell
2023-04-06 14:13       ` Stefan Berger
2023-04-06 14:36         ` Peter Maydell
2023-04-06 15:00           ` Stefan Berger
2023-04-06 15:04             ` Peter Maydell [this message]
2023-04-06 15:30             ` Marc-André Lureau
2023-04-06 15:17         ` Markus Armbruster
2023-03-13 11:46 ` [PULL v2 06/25] win32/socket: introduce qemu_socket_select() helper marcandre.lureau
2023-03-13 11:46 ` [PULL v2 07/25] win32/socket: introduce qemu_socket_unselect() helper marcandre.lureau
2023-03-13 11:46 ` [PULL v2 08/25] aio: make aio_set_fd_poll() static to aio-posix.c marcandre.lureau
2023-03-13 11:46 ` [PULL v2 09/25] aio/win32: aio_set_fd_handler() only supports SOCKET marcandre.lureau
2023-03-13 11:46 ` [PULL v2 10/25] main-loop: remove qemu_fd_register(), win32/slirp/socket specific marcandre.lureau
2023-03-13 11:46 ` [PULL v2 11/25] slirp: unregister the win32 SOCKET marcandre.lureau
2023-03-13 11:46 ` [PULL v2 12/25] slirp: open-code qemu_socket_(un)select() marcandre.lureau
2023-03-13 11:46 ` [PULL v2 13/25] win32: avoid mixing SOCKET and file descriptor space marcandre.lureau
2023-03-13 11:46 ` [PULL v2 14/25] os-posix: remove useless ioctlsocket() define marcandre.lureau
2023-03-13 11:46 ` [PULL v2 15/25] win32: replace closesocket() with close() wrapper marcandre.lureau
2023-03-13 11:46 ` [PULL v2 16/25] tests: fix path separator, use g_build_filename() marcandre.lureau
2023-03-13 11:46 ` [PULL v2 17/25] char: do not double-close fd when failing to add client marcandre.lureau
2023-03-13 11:46 ` [PULL v2 18/25] tests/docker: fix a win32 error due to portability marcandre.lureau
2023-03-13 11:46 ` [PULL v2 19/25] osdep: implement qemu_socketpair() for win32 marcandre.lureau
2023-03-13 11:46 ` [PULL v2 20/25] qmp: 'add_client' actually expects sockets marcandre.lureau
2023-03-13 11:46 ` [PULL v2 21/25] monitor: release the lock before calling close() marcandre.lureau
2023-03-13 11:46 ` [PULL v2 22/25] qmp: add 'get-win32-socket' marcandre.lureau
2023-03-13 11:46 ` [PULL v2 23/25] libqtest: make qtest_qmp_add_client work on win32 marcandre.lureau
2023-03-13 11:46 ` [PULL v2 24/25] qtest: enable vnc-display test " marcandre.lureau
2023-03-13 11:46 ` [PULL v2 25/25] monitor: restrict command getfd to POSIX hosts marcandre.lureau
2023-03-13 17:09 ` [PULL v2 00/25] Win socket patches Peter Maydell

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=CAFEAcA_auAxVC-U80j4LuDWEXEbQysPcFcx-zkLeP5WXP3s6eQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.ibm.com \
    --cc=stefanb@linux.vnet.ibm.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 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).