gio/tests/cancellable: Actually init atomic values with atomic functions

This is to make thread sanitizer happy, even those aren't really issues.
This commit is contained in:
Marco Trevisan (Treviño) 2025-02-19 05:34:13 +01:00
parent ee836d7723
commit 14da9d459c

View File

@ -755,8 +755,11 @@ repeatedly_connecting_thread (gpointer data)
for (guint i = 0; i < iterations; ++i) for (guint i = 0; i < iterations; ++i)
{ {
gboolean callback_called = FALSE; /* (atomic) */ gboolean callback_called; /* (atomic) */
gboolean called; gboolean called;
g_atomic_int_set (&callback_called, FALSE);
gulong id = g_cancellable_connect (cancellable, gulong id = g_cancellable_connect (cancellable,
G_CALLBACK (on_racy_cancellable_cancelled), G_CALLBACK (on_racy_cancellable_cancelled),
&callback_called, NULL); &callback_called, NULL);
@ -780,13 +783,14 @@ test_cancellable_cancel_reset_connect_races (void)
GThread *resetting_thread = NULL; GThread *resetting_thread = NULL;
GThread *cancelling_thread = NULL; GThread *cancelling_thread = NULL;
GThread *connecting_thread = NULL; GThread *connecting_thread = NULL;
gboolean callback_called = FALSE; /* (atomic) */ gboolean callback_called; /* (atomic) */
g_test_summary ("Tests threads racing for cancelling, connecting and disconnecting " g_test_summary ("Tests threads racing for cancelling, connecting and disconnecting "
" and resetting a GCancellable"); " and resetting a GCancellable");
cancellable = g_cancellable_new (); cancellable = g_cancellable_new ();
g_atomic_int_set (&callback_called, FALSE);
g_cancellable_connect (cancellable, G_CALLBACK (on_racy_cancellable_cancelled), g_cancellable_connect (cancellable, G_CALLBACK (on_racy_cancellable_cancelled),
&callback_called, NULL); &callback_called, NULL);
g_assert_false (g_atomic_int_get (&callback_called)); g_assert_false (g_atomic_int_get (&callback_called));