tests/rcutorture: Fix build error
PATCH 1/1 tests/rcutorture: Fix build error
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)) detects an unused variable error:
../tests/unit/rcutorture.c: In function ‘rcu_read_stress_test’:
../tests/unit/rcutorture.c:251:18: error: variable ‘garbage’ set but not used [-Werror=unused-but-set-variable=]
251 | volatile int garbage = 0;
| ^~~~~~~Since the 'garbage' variable is used to generate memory reads from the CPU while holding the RCU lock, it can not be removed. Tag it as ((unused)) instead to silence the compiler warnings/errors.
--- tests/unit/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/unit/rcutorture.c +1 -1
@@ -248,7 +248,7 @@ static void *rcu_read_stress_test(void *arg)int pc;long long n_reads_local =0 ;long long rcu_stress_local[RCU_STRESS_PIPE_LEN +1 ] = {0 }; -volatile int garbage =0 ; + volatile int garbage __attribute__ ((unused)) = 0;rcu_register_thread ();
Signature · 1 line
2.52.0
Quoted 11 lines · Cédric Le Goater
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)) detects an unused variable error:
../tests/unit/rcutorture.c: In function ‘rcu_read_stress_test’:../tests/unit/rcutorture.c:251:18: error: variable ‘garbage’ set but not used [-Werror=unused-but-set-variable=] 251 | volatile int garbage = 0; | ^~~~~~~Since the 'garbage' variable is used to generate memory reads from the CPU while holding the RCU lock, it can not be removed. Tag it as ((unused)) instead to silence the compiler warnings/errors.
That shouldn't happen for a volatile variable: please report this as a compiler bug.
That said, gcc-16 has been released, so
r~
Quoted 19 lines
Signed-off-by Cédric Le Goater <[email protected]>--- tests/unit/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/unit/rcutorture.c +1
-1@@ -248,7 +248,7 @@ static void *rcu_read_stress_test(void *arg)int pc;long long n_reads_local =0 ;long long rcu_stress_local[RCU_STRESS_PIPE_LEN +1 ] = {0 }; -volatile int garbage =0 ; + volatile int garbage __attribute__ ((unused)) = 0;rcu_register_thread ();
Cédric Le Goater
AppliedQuoted 9 lines · Richard Henderson
Quoted 8 lines · Cédric Le Goater
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)) detects an unused variable error:
../tests/unit/rcutorture.c: In function ‘rcu_read_stress_test’:
../tests/unit/rcutorture.c:251:18: error: variable ‘garbage’ set but not used [-Werror=unused-but-set-variable=] 251 | volatile int garbage = 0;
| ^~~~~~~
Quoted 5 lines
Quoted 3 lines
Since the 'garbage' variable is used to generate memory reads from the CPU while holding the RCU lock, it can not be removed. Tag it as ((unused)) instead to silence the compiler warnings/errors.
That shouldn't happen for a volatile variable: please report this as a compiler bug.
Yes. That seemed to defeat the purpose.
Quoted 3 lines
That said, gcc-16 has been released, so
Reviewed-by Richard Henderson <[email protected]>
Applied to vfio-next.
Thanks,
C.
Quoted 22 lines
r~
Quoted 17 lines
Signed-off-by Cédric Le Goater <[email protected]>---
tests/unit/rcutorture.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tests/unit/rcutorture.c +1
-1@@ -248,7 +248,7 @@ static void *rcu_read_stress_test(void *arg) int pc; long long n_reads_local = 0; long long rcu_stress_local[RCU_STRESS_PIPE_LEN + 1] = { 0 }; - volatile int garbage = 0; + volatile int garbage __attribute__ ((unused)) = 0; rcu_register_thread();
Cédric Le Goater
AppliedQuoted 22 lines · Cédric Le Goater
Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)) detects an unused variable error:
../tests/unit/rcutorture.c: In function ‘rcu_read_stress_test’:../tests/unit/rcutorture.c:251:18: error: variable ‘garbage’ set but not used [-Werror=unused-but-set-variable=] 251 | volatile int garbage = 0; | ^~~~~~~Since the 'garbage' variable is used to generate memory reads from the CPU while holding the RCU lock, it can not be removed. Tag it as ((unused)) instead to silence the compiler warnings/errors.
Signed-off-by Cédric Le Goater <[email protected]>--- tests/unit/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/unit/rcutorture.c +0
-0
tests/unit/rcutorture.c static void *rcu_read_stress_test(void *arg) · line 254
Quoted 8 lines
tests/unit/rcutorture.c +1
-1@@ -248,7 +248,7 @@ static void *rcu_read_stress_test(void *arg)int pc;long long n_reads_local =0 ;long long rcu_stress_local[RCU_STRESS_PIPE_LEN +1 ] = {0 }; -volatile int garbage =0 ; + volatile int garbage __attribute__ ((unused)) = 0;rcu_register_thread ();
Applied to vfio-next.
Thanks,
C.