Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus
authorPaul E. McKenney <paulmck@kernel.org>
Mon, 8 Apr 2024 20:41:22 +0000 (13:41 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 6 May 2024 21:29:21 +0000 (14:29 -0700)
The four litmus tests in Documentation/litmus-tests/atomic do not
declare all of their local variables.  Although this is just fine for LKMM
analysis by herd7, it causes build failures when run in-kernel by klitmus.
This commit therefore adjusts these tests to declare all local variables.

Reported-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Andrea Parri <parri.andrea@gmail.com>
Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-1.litmus
Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-2.litmus
Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-1.litmus
Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-2.litmus

index 3df1d140b189bb869e5c21052855493db07e15a2..c0f93dc07105e05622a41c40acaef59978698540 100644 (file)
@@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
 P1(int *x, int *y, int *z)
 {
        int r0;
+       int r1;
 
        WRITE_ONCE(*y, 1);
        r1 = cmpxchg(z, 1, 0);
index 54146044a16f6d1a8f2deaa6f1c71e2b1015072d..5c06054f4694765dc5eb7fd6b332571a8f3170d3 100644 (file)
@@ -11,7 +11,6 @@ C cmpxchg-fail-ordered-2
 
 P0(int *x, int *y)
 {
-       int r0;
        int r1;
 
        WRITE_ONCE(*x, 1);
@@ -20,7 +19,8 @@ P0(int *x, int *y)
 
 P1(int *x, int *y)
 {
-       int r0;
+       int r1;
+       int r2;
 
        r1 = cmpxchg(y, 0, 1);
        smp_mb__after_atomic();
index a727ce23b1a6ea8deb541f7706c9f93e704a6753..39ea1f56a28d284db9fff3ad082bf67ed7ddd737 100644 (file)
@@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
 P1(int *x, int *y, int *z)
 {
        int r0;
+       int r1;
 
        WRITE_ONCE(*y, 1);
        r1 = cmpxchg(z, 1, 0);
index a245bac55b578d9436f59771e100e3dadaf3dba7..61aab24a4a64387a604a3ed0489891d80fe19994 100644 (file)
@@ -12,7 +12,6 @@ C cmpxchg-fail-unordered-2
 
 P0(int *x, int *y)
 {
-       int r0;
        int r1;
 
        WRITE_ONCE(*x, 1);
@@ -21,7 +20,8 @@ P0(int *x, int *y)
 
 P1(int *x, int *y)
 {
-       int r0;
+       int r1;
+       int r2;
 
        r1 = cmpxchg(y, 0, 1);
        r2 = READ_ONCE(*x);