diff options
author | Eric Blake <eblake@redhat.com> | 2016-03-03 09:16:48 -0700 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-03-05 10:41:52 +0100 |
commit | 0399293e5b9e5443b82103fa8e2c97deadef9825 (patch) | |
tree | 51743f16ff479c5e1ff013f7d4a9176b4a9609b8 /qemu-nbd.c | |
parent | f194a1ae530e232b994d23aa8651696dd6664b5d (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 'qemu-nbd.c')
-rw-r--r-- | qemu-nbd.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 5fe94d0e7b..a5c1d95344 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -380,13 +380,14 @@ static SocketAddress *nbd_build_socket_address(const char *sockpath, saddr->u.q_unix = g_new0(UnixSocketAddress, 1); saddr->u.q_unix->path = g_strdup(sockpath); } else { + InetSocketAddress *inet; saddr->type = SOCKET_ADDRESS_KIND_INET; - saddr->u.inet = g_new0(InetSocketAddress, 1); - saddr->u.inet->host = g_strdup(bindto); + inet = saddr->u.inet = g_new0(InetSocketAddress, 1); + inet->host = g_strdup(bindto); if (port) { - saddr->u.inet->port = g_strdup(port); + inet->port = g_strdup(port); } else { - saddr->u.inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); + inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); } } |