[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 27/31] spice: Clean up error reporting in add_channe
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 27/31] spice: Clean up error reporting in add_channel() |
Date: |
Mon, 8 Oct 2018 19:31:21 +0200 |
Calling error_report() in a function that takes an Error ** argument
is suspicious. add_channel() does that, and then exit()s. Its caller
main(), via qemu_opts_foreach(), is fine with it, but clean it up
anyway.
Cc: Gerd Hoffmann <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
ui/spice-core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/ui/spice-core.c b/ui/spice-core.c
index a4fbbc3898..ebaae24643 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -597,9 +597,9 @@ static int add_channel(void *opaque, const char *name,
const char *value,
if (strcmp(name, "tls-channel") == 0) {
int *tls_port = opaque;
if (!*tls_port) {
- error_report("spice: tried to setup tls-channel"
- " without specifying a TLS port");
- exit(1);
+ error_setg(errp, "spice: tried to setup tls-channel"
+ " without specifying a TLS port");
+ return -1;
}
security = SPICE_CHANNEL_SECURITY_SSL;
}
@@ -615,8 +615,9 @@ static int add_channel(void *opaque, const char *name,
const char *value,
rc = spice_server_set_channel_security(spice_server, value, security);
}
if (rc != 0) {
- error_report("spice: failed to set channel security for %s", value);
- exit(1);
+ error_setg(errp, "spice: failed to set channel security for %s",
+ value);
+ return -1;
}
return 0;
}
@@ -787,7 +788,7 @@ void qemu_spice_init(void)
spice_server_set_playback_compression
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
- qemu_opt_foreach(opts, add_channel, &tls_port, NULL);
+ qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal);
spice_server_set_name(spice_server, qemu_name);
spice_server_set_uuid(spice_server, (unsigned char *)&qemu_uuid);
--
2.17.1
- Re: [Qemu-devel] [PATCH 16/31] seccomp: Clean up error reporting in parse_sandbox(), (continued)
- [Qemu-devel] [PATCH 22/31] vl: Clean up error reporting in parse_fw_cfg(), Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 17/31] vl: Clean up error reporting in parse_add_fd(), Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 06/31] char: Use error_printf() to print help and such, Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 02/31] block: Use warn_report() & friends to report warnings, Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 27/31] spice: Clean up error reporting in add_channel(),
Markus Armbruster <=
- [Qemu-devel] [PATCH 10/31] smbios: Clean up error handling in smbios_add(), Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 13/31] net/socket: Fix invalid socket type error handling, Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 15/31] xen/pt: Fix incomplete conversion to realize(), Markus Armbruster, 2018/10/08
- [Qemu-devel] [PATCH 28/31] fsdev: Clean up error reporting in qemu_fsdev_add(), Markus Armbruster, 2018/10/08