mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/powerpc: Fix set-but-not-used errors with GCC v16.2
@ 2026-11-16 10:37 Thomas Huth
  2026-11-16 11:07 ` Christophe Leroy (CS GROUP)
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2026-11-16 10:37 UTC (permalink / raw)
  To: Madhavan Srinivasan, Shuah Khan
  Cc: Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Ritesh Harjani (IBM),
	Shrikanth Hegde, linuxppc-dev, linux-kselftest, linux-kernel

When compiling the powerpc selftests with GCC v16.2, the compilation
fails with:

 ../pmu/lib.c: In function ‘eat_cpu_child’:
 ../pmu/lib.c:86:22: error: variable ‘i’ set but not used [-Werror=unused-but-set-variable=]
    86 |         volatile int i = 0;
       |                      ^

and:

 ebb.c: In function ‘ebb_child’:
 ebb.c:352:18: error: variable ‘val’ set but not used [-Werror=unused-but-set-variable=]
   352 |         uint64_t val;
       |                  ^~~
 cc1: all warnings being treated as errors

Add some "asm volatile" statements here to make to mark the variables
as used and to avoid that the compiler might optimize the code away.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 1 +
 tools/testing/selftests/powerpc/pmu/lib.c     | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
index 21537d6eb6b7d..f4ef92bacd9ab 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
+++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
@@ -391,6 +391,7 @@ int ebb_child(union pipe read_pipe, union pipe write_pipe)
 		val  = mfspr(SPRN_MMCRA);
 		val |= mfspr(SPRN_MMCR2);
 		val |= mfspr(SPRN_MMCR0);
+		asm volatile("" :: "r"(val) : "memory");
 	}
 
 	ebb_global_disable();
diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c
index 3213579874084..32cafd40d2c56 100644
--- a/tools/testing/selftests/powerpc/pmu/lib.c
+++ b/tools/testing/selftests/powerpc/pmu/lib.c
@@ -95,7 +95,10 @@ static int eat_cpu_child(union pipe read_pipe, union pipe write_pipe)
 	wait_for_parent(read_pipe);
 
 	/* Soak up cpu forever */
-	while (1) i++;
+	while (1) {
+		i++;
+		asm volatile("" :: "r"(i) : "memory");
+	}
 
 	return 0;
 }
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 10:37 [PATCH] selftests/powerpc: Fix set-but-not-used errors with GCC v16.2 Thomas Huth
2026-11-16 11:07 ` Christophe Leroy (CS GROUP)
2026-11-16 12:27   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®