qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, vsementsov@yandex-team.ru,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [PATCH 04/10] monitor: Simplify monitor_fd_param()'s error handling
Date: Mon, 21 Nov 2022 09:50:48 +0100	[thread overview]
Message-ID: <20221121085054.683122-5-armbru@redhat.com> (raw)
In-Reply-To: <20221121085054.683122-1-armbru@redhat.com>

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor/misc.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/monitor/misc.c b/monitor/misc.c
index 205487e2b9..83d7f4ffde 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -1086,6 +1086,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
         }
 
         fd = monfd->fd;
+        assert(fd >= 0);
 
         /* caller takes ownership of fd */
         QLIST_REMOVE(monfd, next);
@@ -1403,23 +1404,16 @@ void monitor_fdset_dup_fd_remove(int dup_fd)
 int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp)
 {
     int fd;
-    Error *local_err = NULL;
 
     if (!qemu_isdigit(fdname[0]) && mon) {
-        fd = monitor_get_fd(mon, fdname, &local_err);
+        fd = monitor_get_fd(mon, fdname, errp);
     } else {
         fd = qemu_parse_fd(fdname);
-        if (fd == -1) {
-            error_setg(&local_err, "Invalid file descriptor number '%s'",
+        if (fd < 0) {
+            error_setg(errp, "Invalid file descriptor number '%s'",
                        fdname);
         }
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
-        assert(fd == -1);
-    } else {
-        assert(fd != -1);
-    }
 
     return fd;
 }
-- 
2.37.3



  parent reply	other threads:[~2022-11-21  8:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21  8:50 [PATCH 00/10] Cleanups around error_propagate() and ERRP_GUARD() Markus Armbruster
2022-11-21  8:50 ` [PATCH 01/10] error: Drop some obviously superfluous error_propagate() Markus Armbruster
2022-11-21 11:14   ` Philippe Mathieu-Daudé
2022-11-21  8:50 ` [PATCH 02/10] error: Drop a few superfluous ERRP_GUARD() Markus Armbruster
2022-11-21  8:50 ` [PATCH 03/10] error: Move ERRP_GUARD() to the beginning of the function Markus Armbruster
2022-11-21 11:19   ` Philippe Mathieu-Daudé
2022-11-21  8:50 ` Markus Armbruster [this message]
2022-11-21  8:50 ` [PATCH 05/10] monitor: Use ERRP_GUARD() in monitor_init() Markus Armbruster
2022-11-21  8:50 ` [PATCH 06/10] qemu-config: Make config_parse_qdict() return bool Markus Armbruster
2022-11-21  8:50 ` [PATCH 07/10] qemu-config: Use ERRP_GUARD() where obviously appropriate Markus Armbruster
2022-11-21  8:50 ` [PATCH 08/10] sockets: " Markus Armbruster
2022-11-21  8:50 ` [PATCH 09/10] qapi: Use returned bool to check for failure (again) Markus Armbruster
2022-11-21 11:19   ` Philippe Mathieu-Daudé
2022-11-21  8:50 ` [PATCH 10/10] io: Tidy up fat-fingered parameter name Markus Armbruster
2022-11-21 11:19   ` Philippe Mathieu-Daudé

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=20221121085054.683122-5-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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).