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 <armbru@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 1490895797-29094-4-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
d2e49aad72
commit
a6c76285f2
@ -164,9 +164,12 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
|||||||
addrs,
|
addrs,
|
||||||
errp);
|
errp);
|
||||||
|
|
||||||
default:
|
case SOCKET_ADDRESS_KIND_FD:
|
||||||
error_setg(errp, "Unknown socket address kind");
|
error_setg(errp, "Unsupported socket address type 'fd'");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
ui/vnc.c
18
ui/vnc.c
@ -129,10 +129,13 @@ static void vnc_init_basic_info(SocketAddress *addr,
|
|||||||
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case SOCKET_ADDRESS_KIND_VSOCK:
|
||||||
error_setg(errp, "Unsupported socket kind %d",
|
case SOCKET_ADDRESS_KIND_FD:
|
||||||
addr->type);
|
error_setg(errp, "Unsupported socket address type %s",
|
||||||
|
SocketAddressKind_lookup[addr->type]);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -411,10 +414,13 @@ VncInfo *qmp_query_vnc(Error **errp)
|
|||||||
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case SOCKET_ADDRESS_KIND_VSOCK:
|
||||||
error_setg(errp, "Unsupported socket kind %d",
|
case SOCKET_ADDRESS_KIND_FD:
|
||||||
addr->type);
|
error_setg(errp, "Unsupported socket address type %s",
|
||||||
|
SocketAddressKind_lookup[addr->type]);
|
||||||
goto out_error;
|
goto out_error;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
info->has_host = true;
|
info->has_host = true;
|
||||||
|
@ -1337,9 +1337,7 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error_setg(errp, "socket family %d unsupported",
|
abort();
|
||||||
addr->type);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user