mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
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>
This commit is contained in:
parent
f194a1ae53
commit
0399293e5b
6 changed files with 88 additions and 68 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* QEMU I/O channel sockets test
|
||||
*
|
||||
* Copyright (c) 2015 Red Hat, Inc.
|
||||
* Copyright (c) 2015-2016 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -283,14 +283,18 @@ static void test_io_channel_ipv4(bool async)
|
|||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
||||
|
||||
listen_addr->type = SOCKET_ADDRESS_KIND_INET;
|
||||
listen_addr->u.inet = g_new0(InetSocketAddress, 1);
|
||||
listen_addr->u.inet->host = g_strdup("127.0.0.1");
|
||||
listen_addr->u.inet->port = NULL; /* Auto-select */
|
||||
listen_addr->u.inet = g_new(InetSocketAddress, 1);
|
||||
*listen_addr->u.inet = (InetSocketAddress) {
|
||||
.host = g_strdup("127.0.0.1"),
|
||||
.port = NULL, /* Auto-select */
|
||||
};
|
||||
|
||||
connect_addr->type = SOCKET_ADDRESS_KIND_INET;
|
||||
connect_addr->u.inet = g_new0(InetSocketAddress, 1);
|
||||
connect_addr->u.inet->host = g_strdup("127.0.0.1");
|
||||
connect_addr->u.inet->port = NULL; /* Filled in later */
|
||||
connect_addr->u.inet = g_new(InetSocketAddress, 1);
|
||||
*connect_addr->u.inet = (InetSocketAddress) {
|
||||
.host = g_strdup("127.0.0.1"),
|
||||
.port = NULL, /* Filled in later */
|
||||
};
|
||||
|
||||
test_io_channel(async, listen_addr, connect_addr, false);
|
||||
|
||||
|
@ -317,14 +321,18 @@ static void test_io_channel_ipv6(bool async)
|
|||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
||||
|
||||
listen_addr->type = SOCKET_ADDRESS_KIND_INET;
|
||||
listen_addr->u.inet = g_new0(InetSocketAddress, 1);
|
||||
listen_addr->u.inet->host = g_strdup("::1");
|
||||
listen_addr->u.inet->port = NULL; /* Auto-select */
|
||||
listen_addr->u.inet = g_new(InetSocketAddress, 1);
|
||||
*listen_addr->u.inet = (InetSocketAddress) {
|
||||
.host = g_strdup("::1"),
|
||||
.port = NULL, /* Auto-select */
|
||||
};
|
||||
|
||||
connect_addr->type = SOCKET_ADDRESS_KIND_INET;
|
||||
connect_addr->u.inet = g_new0(InetSocketAddress, 1);
|
||||
connect_addr->u.inet->host = g_strdup("::1");
|
||||
connect_addr->u.inet->port = NULL; /* Filled in later */
|
||||
connect_addr->u.inet = g_new(InetSocketAddress, 1);
|
||||
*connect_addr->u.inet = (InetSocketAddress) {
|
||||
.host = g_strdup("::1"),
|
||||
.port = NULL, /* Filled in later */
|
||||
};
|
||||
|
||||
test_io_channel(async, listen_addr, connect_addr, false);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue