[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 18/35] vl: Clean up error reporting in parse_add_
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v2 18/35] vl: Clean up error reporting in parse_add_fd() |
Date: |
Mon, 15 Oct 2018 13:52:52 +0200 |
Calling error_report() in a function that takes an Error ** argument
is suspicious. parse_add_fd() does that, and then fails without
setting an error. Its caller main(), via qemu_opts_foreach(), is fine
with it, but clean it up anyway.
Also change call of cleanup_add_fd(), which can't fail, for symmetry.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
vl.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/vl.c b/vl.c
index 643121e5d4..2ef066ad61 100644
--- a/vl.c
+++ b/vl.c
@@ -1059,12 +1059,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts,
Error **errp)
fd_opaque = qemu_opt_get(opts, "opaque");
if (fd < 0) {
- error_report("fd option is required and must be non-negative");
+ error_setg(errp, "fd option is required and must be non-negative");
return -1;
}
if (fd <= STDERR_FILENO) {
- error_report("fd cannot be a standard I/O stream");
+ error_setg(errp, "fd cannot be a standard I/O stream");
return -1;
}
@@ -1074,12 +1074,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts,
Error **errp)
*/
flags = fcntl(fd, F_GETFD);
if (flags == -1 || (flags & FD_CLOEXEC)) {
- error_report("fd is not valid or already in use");
+ error_setg(errp, "fd is not valid or already in use");
return -1;
}
if (fdset_id < 0) {
- error_report("set option is required and must be non-negative");
+ error_setg(errp, "set option is required and must be non-negative");
return -1;
}
@@ -1092,7 +1092,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts,
Error **errp)
}
#endif
if (dupfd == -1) {
- error_report("error duplicating fd: %s", strerror(errno));
+ error_setg(errp, "error duplicating fd: %s", strerror(errno));
return -1;
}
@@ -3983,15 +3983,11 @@ int main(int argc, char **argv, char **envp)
}
#ifndef _WIN32
- if (qemu_opts_foreach(qemu_find_opts("add-fd"),
- parse_add_fd, NULL, NULL)) {
- exit(1);
- }
+ qemu_opts_foreach(qemu_find_opts("add-fd"),
+ parse_add_fd, NULL, &error_fatal);
- if (qemu_opts_foreach(qemu_find_opts("add-fd"),
- cleanup_add_fd, NULL, NULL)) {
- exit(1);
- }
+ qemu_opts_foreach(qemu_find_opts("add-fd"),
+ cleanup_add_fd, NULL, &error_fatal);
#endif
current_machine = MACHINE(object_new(object_class_get_name(
--
2.17.1
- [Qemu-devel] [PATCH v2 00/35] Replace some unwise uses of error_report() & friends, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 08/35] 9pfs: Fix CLI parsing crash on error, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 12/35] migration: Fix !replay_can_snapshot() error handling, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 03/35] block: Use warn_report() & friends to report warnings, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 01/35] error: Fix use of error_prepend() with &error_fatal, &error_abort, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 02/35] Use error_fatal to simplify obvious fatal errors (again), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 22/35] vl: Clean up error reporting in mon_init_func(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 15/35] numa: Fix QMP command set-numa-node error handling, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 19/35] qom: Clean up error reporting in user_creatable_add_opts_foreach(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 20/35] vl: Clean up error reporting in chardev_init_func(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 18/35] vl: Clean up error reporting in parse_add_fd(),
Markus Armbruster <=
- [Qemu-devel] [PATCH v2 34/35] vl: Fix exit status for -drive format=help, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 11/35] smbios: Clean up error handling in smbios_add(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 21/35] vl: Clean up error reporting in machine_set_property(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 10/35] ioapic: Fix error handling in realize(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 35/35] vl: Simplify call of parse_name(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 32/35] vl: Assert drive_new() does not fail in default_drive(), Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 25/35] ui/keymaps: Fix handling of erroneous include files, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 14/35] net/socket: Fix invalid socket type error handling, Markus Armbruster, 2018/10/15
- [Qemu-devel] [PATCH v2 33/35] blockdev: Convert drive_new() to Error, Markus Armbruster, 2018/10/15