[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/29] test-char: fix AddressSanitizer failure
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 08/29] test-char: fix AddressSanitizer failure |
Date: |
Mon, 16 Sep 2019 16:41:48 +0200 |
The CharSocketServerTestConfig and CharSocketClientTestConfig
objects escape after they are passed to g_test_add_data_func,
but they cease existing after the scope that defines them is
closed. Make them static to fix this issue.
Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
tests/test-char.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/tests/test-char.c b/tests/test-char.c
index f3ebdff..d62de1b 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -1355,6 +1355,18 @@ static void char_hotswap_test(void)
g_free(chr_args);
}
+static SocketAddress tcpaddr = {
+ .type = SOCKET_ADDRESS_TYPE_INET,
+ .u.inet.host = (char *)"127.0.0.1",
+ .u.inet.port = (char *)"0",
+};
+#ifndef WIN32
+static SocketAddress unixaddr = {
+ .type = SOCKET_ADDRESS_TYPE_UNIX,
+ .u.q_unix.path = (char *)"test-char.sock",
+};
+#endif
+
int main(int argc, char **argv)
{
bool has_ipv4, has_ipv6;
@@ -1390,26 +1402,14 @@ int main(int argc, char **argv)
g_test_add_func("/char/file-fifo", char_file_fifo_test);
#endif
- SocketAddress tcpaddr = {
- .type = SOCKET_ADDRESS_TYPE_INET,
- .u.inet.host = (char *)"127.0.0.1",
- .u.inet.port = (char *)"0",
- };
-#ifndef WIN32
- SocketAddress unixaddr = {
- .type = SOCKET_ADDRESS_TYPE_UNIX,
- .u.q_unix.path = (char *)"test-char.sock",
- };
-#endif
-
#define SOCKET_SERVER_TEST(name, addr) \
- CharSocketServerTestConfig server1 ## name = \
+ static CharSocketServerTestConfig server1 ## name = \
{ addr, false, false }; \
- CharSocketServerTestConfig server2 ## name = \
+ static CharSocketServerTestConfig server2 ## name = \
{ addr, true, false }; \
- CharSocketServerTestConfig server3 ## name = \
+ static CharSocketServerTestConfig server3 ## name = \
{ addr, false, true }; \
- CharSocketServerTestConfig server4 ## name = \
+ static CharSocketServerTestConfig server4 ## name = \
{ addr, true, true }; \
g_test_add_data_func("/char/socket/server/mainloop/" # name, \
&server1 ##name, char_socket_server_test); \
@@ -1421,17 +1421,17 @@ int main(int argc, char **argv)
&server4 ##name, char_socket_server_test)
#define SOCKET_CLIENT_TEST(name, addr) \
- CharSocketClientTestConfig client1 ## name = \
+ static CharSocketClientTestConfig client1 ## name = \
{ addr, NULL, false, false }; \
- CharSocketClientTestConfig client2 ## name = \
+ static CharSocketClientTestConfig client2 ## name = \
{ addr, NULL, true, false }; \
- CharSocketClientTestConfig client3 ## name = \
+ static CharSocketClientTestConfig client3 ## name = \
{ addr, ",reconnect=1", false }; \
- CharSocketClientTestConfig client4 ## name = \
+ static CharSocketClientTestConfig client4 ## name = \
{ addr, ",reconnect=1", true }; \
- CharSocketClientTestConfig client5 ## name = \
+ static CharSocketClientTestConfig client5 ## name = \
{ addr, NULL, false, true }; \
- CharSocketClientTestConfig client6 ## name = \
+ static CharSocketClientTestConfig client6 ## name = \
{ addr, NULL, true, true }; \
g_test_add_data_func("/char/socket/client/mainloop/" # name, \
&client1 ##name, char_socket_client_test); \
--
1.8.3.1
- [Qemu-devel] [PULL 00/29] Misc patches for 2019-09-16, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 01/29] i386/kvm: support guest access CORE cstate, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 02/29] exec.c: replace hwaddr with uint64_t for better understanding, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 03/29] exec.c: get nodes_nb_alloc with one MAX calculation, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 04/29] exec.c: subpage->sub_section is already initialized to 0, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 06/29] exec.c: add a check between constants to see whether we could skip, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 05/29] exec.c: correct the maximum skip value during compact, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 07/29] win32: fix README file in NSIS installer, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 08/29] test-char: fix AddressSanitizer failure,
Paolo Bonzini <=
- [Qemu-devel] [PULL 09/29] hw/i386: Move CONFIG_ACPI_PCI to CONFIG_PC, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 10/29] elf-ops.h: fix int overflow in load_elf(), Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 12/29] memory: inline and optimize devend_memop, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 11/29] memory: fetch pmem size in get_file_size(), Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 15/29] hw/i386/pc: Use e820_get_num_entries() to access e820_entries, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 14/29] cpus: Fix throttling during vm_stop, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 16/29] hw/i386/pc: Extract e820 memory layout code, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 20/29] hw/i386/pc: Pass the apic_id_limit value by argument, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 13/29] qemu-thread: Add qemu_cond_timedwait, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 21/29] hw/i386/pc: Pass the CPUArchIdList array by argument, Paolo Bonzini, 2019/09/16