From c2930ddf824da49f9856120786214d6889832d23 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 Sep 2024 14:41:48 +0100 Subject: [PATCH] test: Always initialize an "out" parameter check_valid_fd() does not touch its second parameter if the fd is not, in fact, a valid fd. Initialize the "out" parameter to the opposite of the value we are hoping for, so that both assertions will fail if there is a problem. Signed-off-by: Simon McVittie --- test/internals/sysdeps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/internals/sysdeps.c b/test/internals/sysdeps.c index 3f920c73f..7805ebd26 100644 --- a/test/internals/sysdeps.c +++ b/test/internals/sysdeps.c @@ -234,7 +234,7 @@ fixture_open_some_fds (Fixture *f) for (i = 0; i < n; i += 2) { - gboolean cloexec; + gboolean cloexec = TRUE; if (pipe (&f->fds[i]) < 0) g_error ("pipe: %s", g_strerror (errno)); @@ -281,7 +281,7 @@ test_set_all_close_on_exec (Fixture *f, for (i = 0; i < f->n_fds; i++) { - gboolean cloexec; + gboolean cloexec = TRUE; g_assert_true (check_valid_fd (f->fds[i], &cloexec)); g_assert_false (cloexec); @@ -291,7 +291,7 @@ test_set_all_close_on_exec (Fixture *f, for (i = 0; i < f->n_fds; i++) { - gboolean cloexec; + gboolean cloexec = FALSE; g_assert_true (check_valid_fd (f->fds[i], &cloexec)); g_assert_true (cloexec); -- 2.47.3