Skip to content

Commit 2ba5b41

Browse files
committed
Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus
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 <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Acked-by: Andrea Parri <[email protected]>
1 parent d372e20 commit 2ba5b41

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-1.litmus

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
2323
P1(int *x, int *y, int *z)
2424
{
2525
int r0;
26+
int r1;
2627

2728
WRITE_ONCE(*y, 1);
2829
r1 = cmpxchg(z, 1, 0);

Documentation/litmus-tests/atomic/cmpxchg-fail-ordered-2.litmus

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ C cmpxchg-fail-ordered-2
1111

1212
P0(int *x, int *y)
1313
{
14-
int r0;
1514
int r1;
1615

1716
WRITE_ONCE(*x, 1);
@@ -20,7 +19,8 @@ P0(int *x, int *y)
2019

2120
P1(int *x, int *y)
2221
{
23-
int r0;
22+
int r1;
23+
int r2;
2424

2525
r1 = cmpxchg(y, 0, 1);
2626
smp_mb__after_atomic();

Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-1.litmus

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ P0(int *x, int *y, int *z)
2323
P1(int *x, int *y, int *z)
2424
{
2525
int r0;
26+
int r1;
2627

2728
WRITE_ONCE(*y, 1);
2829
r1 = cmpxchg(z, 1, 0);

Documentation/litmus-tests/atomic/cmpxchg-fail-unordered-2.litmus

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ C cmpxchg-fail-unordered-2
1212

1313
P0(int *x, int *y)
1414
{
15-
int r0;
1615
int r1;
1716

1817
WRITE_ONCE(*x, 1);
@@ -21,7 +20,8 @@ P0(int *x, int *y)
2120

2221
P1(int *x, int *y)
2322
{
24-
int r0;
23+
int r1;
24+
int r2;
2525

2626
r1 = cmpxchg(y, 0, 1);
2727
r2 = READ_ONCE(*x);

0 commit comments

Comments
 (0)