]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf tests sw-clock: Mark the volatile tmp variable as __maybe_unused
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Jan 2026 20:47:09 +0000 (17:47 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Jan 2026 23:49:53 +0000 (20:49 -0300)
As it is just used to waste some cycles, not being used as all, to
silence some compilers.

Noticed with gcc version 16.0.1 20260115 on fedora 44:

    tests/sw-clock.c: In function '__test__sw_clock_freq':
    tests/sw-clock.c:31:22: error: variable 'tmp' set but not used [-Werror=unused-but-set-variable=]
       31 |         volatile int tmp = 0;
          |                      ^~~

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/sw-clock.c

index 4a2ad7176fa07be004823a948da5c7364a83d6ca..b6e46975379cd5ef3cab7819e7e6abc1420aaa99 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <sys/mman.h>
+#include <linux/compiler.h>
 #include <linux/string.h>
 
 #include "tests.h"
@@ -28,7 +29,7 @@
 static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
 {
        int i, err = -1;
-       volatile int tmp = 0;
+       volatile int tmp __maybe_unused = 0;
        u64 total_periods = 0;
        int nr_samples = 0;
        char sbuf[STRERR_BUFSIZE];