From a6c76285f2e41535527a46edf4d158a2779545e1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 30 Mar 2017 19:43:11 +0200 Subject: io vnc sockets: Clean up SocketAddressKind switches We have quite a few switches over SocketAddressKind. Some have case labels for all enumeration values, others rely on a default label. Some abort when the value isn't a valid SocketAddressKind, others report an error then. Unify as follows. Always provide case labels for all enumeration values, to clarify intent. Abort when the value isn't a valid SocketAddressKind, because the program state is messed up then. Improve a few error messages while there. Signed-off-by: Markus Armbruster Reviewed-by: Max Reitz Message-id: 1490895797-29094-4-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- ui/vnc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/vnc.c b/ui/vnc.c index 1095f9de68..349cfc9d86 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -129,10 +129,13 @@ static void vnc_init_basic_info(SocketAddress *addr, info->family = NETWORK_ADDRESS_FAMILY_UNIX; break; - default: - error_setg(errp, "Unsupported socket kind %d", - addr->type); + case SOCKET_ADDRESS_KIND_VSOCK: + case SOCKET_ADDRESS_KIND_FD: + error_setg(errp, "Unsupported socket address type %s", + SocketAddressKind_lookup[addr->type]); break; + default: + abort(); } return; @@ -411,10 +414,13 @@ VncInfo *qmp_query_vnc(Error **errp) info->family = NETWORK_ADDRESS_FAMILY_UNIX; break; - default: - error_setg(errp, "Unsupported socket kind %d", - addr->type); + case SOCKET_ADDRESS_KIND_VSOCK: + case SOCKET_ADDRESS_KIND_FD: + error_setg(errp, "Unsupported socket address type %s", + SocketAddressKind_lookup[addr->type]); goto out_error; + default: + abort(); } info->has_host = true; -- cgit v1.2.3