summaryrefslogtreecommitdiffstats
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-03-03 09:16:48 -0700
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:49:12 -0600
commit6bfa9411dc89d590dee8dcdc1e689d5dc48de76c (patch)
treec343158e48c28c92c75452d6d3ecddf734b074c2 /util/qemu-sockets.c
parent8a198c0dfd8422af7d029dab95d852e208890ba2 (diff)
downloadhqemu-6bfa9411dc89d590dee8dcdc1e689d5dc48de76c.zip
hqemu-6bfa9411dc89d590dee8dcdc1e689d5dc48de76c.tar.gz
util: Shorten references into SocketAddress
An upcoming patch will alter how simple unions, like SocketAddress, are laid out, which will impact all lines of the form 'addr->u.XXX' (expanding it to the longer 'addr->u.XXX.data'). For better legibility in that patch, and less need for line wrapping, it's better to use a temporary variable to reduce the effect of a layout change to just the variable initializations, rather than every reference within a SocketAddress. Also, take advantage of some C99 initialization where it makes sense (simplifying g_new0() to g_new()). Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1457021813-10704-7-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 557da20..ad7c00c 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1003,6 +1003,7 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
SocketAddress *addr;
+ InetSocketAddress *inet;
int ret;
ret = getnameinfo((struct sockaddr *)sa, salen,
@@ -1017,13 +1018,13 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
addr = g_new0(SocketAddress, 1);
addr->type = SOCKET_ADDRESS_KIND_INET;
- addr->u.inet = g_new0(InetSocketAddress, 1);
- addr->u.inet->host = g_strdup(host);
- addr->u.inet->port = g_strdup(serv);
+ inet = addr->u.inet = g_new0(InetSocketAddress, 1);
+ inet->host = g_strdup(host);
+ inet->port = g_strdup(serv);
if (sa->ss_family == AF_INET) {
- addr->u.inet->has_ipv4 = addr->u.inet->ipv4 = true;
+ inet->has_ipv4 = inet->ipv4 = true;
} else {
- addr->u.inet->has_ipv6 = addr->u.inet->ipv6 = true;
+ inet->has_ipv6 = inet->ipv6 = true;
}
return addr;
OpenPOWER on IntegriCloud