[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/14] monitor: Simplify monitor_fd_param()'s error handling
From: |
Markus Armbruster |
Subject: |
[PULL 05/14] monitor: Simplify monitor_fd_param()'s error handling |
Date: |
Wed, 14 Dec 2022 17:46:20 +0100 |
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
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;
}
--
2.37.3
- [PULL 00/14] Miscellaneous patches for 2022-12-14, Markus Armbruster, 2022/12/14
- [PULL 01/14] Drop more useless casts from void * to pointer, Markus Armbruster, 2022/12/14
- [PULL 05/14] monitor: Simplify monitor_fd_param()'s error handling,
Markus Armbruster <=
- [PULL 09/14] sockets: Use ERRP_GUARD() where obviously appropriate, Markus Armbruster, 2022/12/14
- [PULL 10/14] qapi: Use returned bool to check for failure (again), Markus Armbruster, 2022/12/14
- [PULL 14/14] ppc4xx_sdram: Simplify sdram_ddr_size() to return, Markus Armbruster, 2022/12/14
- [PULL 12/14] cleanup: Tweak and re-run return_directly.cocci, Markus Armbruster, 2022/12/14
- [PULL 04/14] error: Move ERRP_GUARD() to the beginning of the function, Markus Armbruster, 2022/12/14
- [PULL 02/14] error: Drop some obviously superfluous error_propagate(), Markus Armbruster, 2022/12/14
- [PULL 03/14] error: Drop a few superfluous ERRP_GUARD(), Markus Armbruster, 2022/12/14
- [PULL 08/14] qemu-config: Use ERRP_GUARD() where obviously appropriate, Markus Armbruster, 2022/12/14
- [PULL 11/14] io: Tidy up fat-fingered parameter name, Markus Armbruster, 2022/12/14
- [PULL 07/14] qemu-config: Make config_parse_qdict() return bool, Markus Armbruster, 2022/12/14