[glib/wip/pwithnall/1940-atomic-types: 1/3] tests: Use pointers in calls to g_atomic_pointer_compare_and_exchange()



commit 844332ef3177c2b00ccec4fb4eb23b8e29bf0091
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Nov 20 12:07:45 2019 +0000

    tests: Use pointers in calls to g_atomic_pointer_compare_and_exchange()
    
    Don’t pass integers; it’s not type-safe. The macro version of
    `g_atomic_pointer_compare_and_exchange()` used to erroneously accept
    integers, but they would have the wrong width on some platforms.
    
    Changes originally investigated and suggested by Ting-Wei Lan.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes: #1940

 glib/tests/atomic.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c
index 5926e3135..3ba7d553f 100644
--- a/glib/tests/atomic.c
+++ b/glib/tests/atomic.c
@@ -83,14 +83,14 @@ test_types (void)
   res = g_atomic_pointer_compare_and_exchange (&vp, &s, &s);
   g_assert_false (res);
   g_assert_true (vp == 0);
-  res = g_atomic_pointer_compare_and_exchange (&vp, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&vp, NULL, NULL);
   g_assert_true (res);
   g_assert_true (vp == 0);
 
   g_atomic_pointer_set (&ip, 0);
   ip2 = g_atomic_pointer_get (&ip);
   g_assert_true (ip2 == 0);
-  res = g_atomic_pointer_compare_and_exchange (&ip, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&ip, NULL, NULL);
   g_assert_true (res);
   g_assert_true (ip == 0);
 
@@ -98,7 +98,7 @@ test_types (void)
   vp2 = (gpointer) g_atomic_pointer_get (&gs);
   gs2 = (gsize) vp2;
   g_assert_cmpuint (gs2, ==, 0);
-  res = g_atomic_pointer_compare_and_exchange (&gs, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&gs, NULL, NULL);
   g_assert_true (res);
   g_assert_cmpuint (gs, ==, 0);
   gs2 = (gsize) g_atomic_pointer_add (&gs, 5);
@@ -191,14 +191,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   res = g_atomic_pointer_compare_and_exchange (&vp, &s, &s);
   g_assert_false (res);
   g_assert_true (vp == 0);
-  res = g_atomic_pointer_compare_and_exchange (&vp, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&vp, NULL, NULL);
   g_assert_true (res);
   g_assert_true (vp == 0);
 
   g_atomic_pointer_set (&ip, 0);
   ip2 = g_atomic_pointer_get (&ip);
   g_assert_true (ip2 == 0);
-  res = g_atomic_pointer_compare_and_exchange (&ip, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&ip, NULL, NULL);
   g_assert_true (res);
   g_assert_true (ip == 0);
 
@@ -206,7 +206,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   vp = g_atomic_pointer_get (&gs);
   gs2 = (gsize) vp;
   g_assert_cmpuint (gs2, ==, 0);
-  res = g_atomic_pointer_compare_and_exchange (&gs, 0, 0);
+  res = g_atomic_pointer_compare_and_exchange (&gs, NULL, NULL);
   g_assert_true (res);
   g_assert_cmpuint (gs, ==, 0);
   gs2 = (gsize) g_atomic_pointer_add (&gs, 5);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]