test: sctest: fix warnings
authorBrian Norris <banorris@uci.edu>
Fri, 26 Apr 2013 22:29:26 +0000 (15:29 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 26 Apr 2013 22:29:26 +0000 (15:29 -0700)
Perhaps we wanted to print these variables? Anyway, just make them
global, so the warnings will go away:

  gcc -o sctest.o sctest.c -Wall -g -O3 -I.. -I../include -L.. -lmodel
  sctest.c: In function ‘b’:
  sctest.c:20:6: warning: unused variable ‘r1’ [-Wunused-variable]
  sctest.c: In function ‘c’:
  sctest.c:26:6: warning: unused variable ‘r2’ [-Wunused-variable]
  sctest.c: In function ‘d’:
  sctest.c:33:6: warning: unused variable ‘r3’ [-Wunused-variable]

test/sctest.c

index 7aa4805e81e7ce2c07eb2abb7f967508e254e81a..2ddb953b338f14d27d4958865a9a1ebe919e0206 100644 (file)
@@ -8,6 +8,8 @@ atomic_int x;
 atomic_int y;
 atomic_int z;
 
+static int r1, r2, r3;
+
 static void a(void *obj)
 {
        atomic_store_explicit(&z, 1, memory_order_relaxed);
@@ -17,20 +19,20 @@ static void b(void *obj)
 {
        atomic_store_explicit(&x, 1, memory_order_relaxed);
        atomic_store_explicit(&y, 1, memory_order_relaxed);
-       int r1=atomic_load_explicit(&z, memory_order_relaxed);
+       r1=atomic_load_explicit(&z, memory_order_relaxed);
 }
 static void c(void *obj)
 {
        atomic_store_explicit(&z, 2, memory_order_relaxed);
        atomic_store_explicit(&x, 2, memory_order_relaxed);
-       int r2=atomic_load_explicit(&y, memory_order_relaxed);
+       r2=atomic_load_explicit(&y, memory_order_relaxed);
 }
 
 static void d(void *obj)
 {
        atomic_store_explicit(&z, 3, memory_order_relaxed);
        atomic_store_explicit(&y, 2, memory_order_relaxed);
-       int r3=atomic_load_explicit(&x, memory_order_relaxed);
+       r3=atomic_load_explicit(&x, memory_order_relaxed);
 }
 
 int user_main(int argc, char **argv)
@@ -51,5 +53,7 @@ int user_main(int argc, char **argv)
        thrd_join(t3);
        thrd_join(t4);
 
+       /* Check and/or print r1, r2, r3? */
+
        return 0;
 }