mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
qapi net: Elide redundant has_FOO in generated C
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qapi/net.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Jason Wang <jasowang@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221104160712.3005652-19-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> [Fixes for MacOS squashed in]
This commit is contained in:
parent
9492718b7c
commit
7480874a69
14 changed files with 77 additions and 82 deletions
18
net/socket.c
18
net/socket.c
|
@ -705,19 +705,19 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
assert(netdev->type == NET_CLIENT_DRIVER_SOCKET);
|
||||
sock = &netdev->u.socket;
|
||||
|
||||
if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +
|
||||
sock->has_udp != 1) {
|
||||
if (!!sock->fd + !!sock->listen + !!sock->connect + !!sock->mcast +
|
||||
!!sock->udp != 1) {
|
||||
error_setg(errp, "exactly one of listen=, connect=, mcast= or udp="
|
||||
" is required");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {
|
||||
if (sock->localaddr && !sock->mcast && !sock->udp) {
|
||||
error_setg(errp, "localaddr= is only valid with mcast= or udp=");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sock->has_fd) {
|
||||
if (sock->fd) {
|
||||
int fd, ret;
|
||||
|
||||
fd = monitor_fd_param(monitor_cur(), sock->fd, errp);
|
||||
|
@ -737,7 +737,7 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sock->has_listen) {
|
||||
if (sock->listen) {
|
||||
if (net_socket_listen_init(peer, "socket", name, sock->listen, errp)
|
||||
< 0) {
|
||||
return -1;
|
||||
|
@ -745,7 +745,7 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sock->has_connect) {
|
||||
if (sock->connect) {
|
||||
if (net_socket_connect_init(peer, "socket", name, sock->connect, errp)
|
||||
< 0) {
|
||||
return -1;
|
||||
|
@ -753,7 +753,7 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sock->has_mcast) {
|
||||
if (sock->mcast) {
|
||||
/* if sock->localaddr is missing, it has been initialized to "all bits
|
||||
* zero" */
|
||||
if (net_socket_mcast_init(peer, "socket", name, sock->mcast,
|
||||
|
@ -763,8 +763,8 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
assert(sock->has_udp);
|
||||
if (!sock->has_localaddr) {
|
||||
assert(sock->udp);
|
||||
if (!sock->localaddr) {
|
||||
error_setg(errp, "localaddr= is mandatory with udp=");
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue