]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Always initialize an "out" parameter
authorSimon McVittie <smcv@collabora.com>
Wed, 25 Sep 2024 13:41:48 +0000 (14:41 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 25 Sep 2024 13:42:15 +0000 (14:42 +0100)
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 <smcv@collabora.com>
test/internals/sysdeps.c

index 3f920c73f093c36a82f36851b0cea9fd40f48130..7805ebd269a2f0f98626e3f578e2673c2e4eae23 100644 (file)
@@ -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);