From b3197f274010e3cd7fa2f370e8f9198603340523 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 2 Dec 2019 17:34:03 +0100 Subject: [PATCH 1/2] tests: Fix incomplete failure check in socket test For the check "if (error != NULL)" to work as expected, the create_server() (and create_server_full()) functions need to make sure to return an error for all the possible failures, but this might not always be the case. Catch all the failures by testing for a non-NULL return value if there was no error. --- gio/tests/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index f1651972f..aea71dd45 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -342,6 +342,7 @@ test_ip_async (GSocketFamily family) g_clear_error (&error); return; } + g_assert_nonnull (data); addr = g_socket_get_local_address (data->server, &error); g_assert_no_error (error); From e537716540ead22d30216a9367180482896acd18 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 2 Dec 2019 17:38:25 +0100 Subject: [PATCH 2/2] tests: Fix error path not setting an error This failure path should have set the GError but did not. --- gio/tests/socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index aea71dd45..e095d0195 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -140,7 +140,11 @@ create_server_full (GSocketFamily family, { g_socket_set_option (data->server, IPPROTO_IPV6, IPV6_V6ONLY, FALSE, NULL); if (!g_socket_speaks_ipv4 (data->server)) - goto error; + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + "IPv6-only server cannot speak IPv4"); + goto error; + } } #endif