aboutsummaryrefslogtreecommitdiff
path: root/ui/vnc.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-03-03 09:16:48 -0700
committerMarkus Armbruster <armbru@redhat.com>2016-03-05 10:41:52 +0100
commit0399293e5b9e5443b82103fa8e2c97deadef9825 (patch)
tree51743f16ff479c5e1ff013f7d4a9176b4a9609b8 /ui/vnc.c
parentf194a1ae530e232b994d23aa8651696dd6664b5d (diff)
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 'ui/vnc.c')
-rw-r--r--ui/vnc.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/ui/vnc.c b/ui/vnc.c
index ce4c669ec9..6cd63141c4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3530,12 +3530,13 @@ void vnc_display_open(const char *id, Error **errp)
}
} else {
unsigned long long baseport;
+ InetSocketAddress *inet;
saddr->type = SOCKET_ADDRESS_KIND_INET;
- saddr->u.inet = g_new0(InetSocketAddress, 1);
+ inet = saddr->u.inet = g_new0(InetSocketAddress, 1);
if (vnc[0] == '[' && vnc[hlen - 1] == ']') {
- saddr->u.inet->host = g_strndup(vnc + 1, hlen - 2);
+ inet->host = g_strndup(vnc + 1, hlen - 2);
} else {
- saddr->u.inet->host = g_strndup(vnc, hlen);
+ inet->host = g_strndup(vnc, hlen);
}
if (parse_uint_full(h + 1, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", h + 1);
@@ -3546,32 +3547,32 @@ void vnc_display_open(const char *id, Error **errp)
error_setg(errp, "port %s out of range", h + 1);
goto fail;
}
- saddr->u.inet->port = g_strdup_printf(
+ inet->port = g_strdup_printf(
"%d", (int)baseport + 5900);
if (to) {
- saddr->u.inet->has_to = true;
- saddr->u.inet->to = to + 5900;
+ inet->has_to = true;
+ inet->to = to + 5900;
}
- saddr->u.inet->ipv4 = ipv4;
- saddr->u.inet->has_ipv4 = has_ipv4;
- saddr->u.inet->ipv6 = ipv6;
- saddr->u.inet->has_ipv6 = has_ipv6;
+ inet->ipv4 = ipv4;
+ inet->has_ipv4 = has_ipv4;
+ inet->ipv6 = ipv6;
+ inet->has_ipv6 = has_ipv6;
if (vs->ws_enabled) {
wsaddr->type = SOCKET_ADDRESS_KIND_INET;
- wsaddr->u.inet = g_new0(InetSocketAddress, 1);
- wsaddr->u.inet->host = g_strdup(saddr->u.inet->host);
- wsaddr->u.inet->port = g_strdup(websocket);
+ inet = wsaddr->u.inet = g_new0(InetSocketAddress, 1);
+ inet->host = g_strdup(saddr->u.inet->host);
+ inet->port = g_strdup(websocket);
if (to) {
- wsaddr->u.inet->has_to = true;
- wsaddr->u.inet->to = to;
+ inet->has_to = true;
+ inet->to = to;
}
- wsaddr->u.inet->ipv4 = ipv4;
- wsaddr->u.inet->has_ipv4 = has_ipv4;
- wsaddr->u.inet->ipv6 = ipv6;
- wsaddr->u.inet->has_ipv6 = has_ipv6;
+ inet->ipv4 = ipv4;
+ inet->has_ipv4 = has_ipv4;
+ inet->ipv6 = ipv6;
+ inet->has_ipv6 = has_ipv6;
}
}
} else {