From 457552fc7d7ff2042e23884ab189ccc216778963 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 21 Nov 2022 09:50:48 +0100 Subject: [PATCH] monitor: Simplify monitor_fd_param()'s error handling Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Message-Id: <20221121085054.683122-5-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; }