lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJjSNEuX=HJKrD=pefC4C9dQk2aqP+hnRscUEDTntVXyA@mail.gmail.com>
Date: Fri, 17 Oct 2025 10:20:19 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>, bpf <bpf@...r.kernel.org>, 
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf v1] selftests/bpf: Fix set but not used errors

On Fri, Oct 17, 2025 at 2:35 AM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> There are some set but not used errors under tools/testing/selftests/bpf
> when compiling with the latest upstream mainline GCC, add the compiler
> attribute __maybe_unused for the variables that may be used to fix the
> errors, compile tested only.
>
> Cc: stable@...r.kernel.org
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> ---
>  tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c | 3 ++-
>  tools/testing/selftests/bpf/prog_tests/bpf_cookie.c            | 3 ++-
>  tools/testing/selftests/bpf/prog_tests/find_vma.c              | 3 ++-
>  tools/testing/selftests/bpf/prog_tests/perf_branches.c         | 3 ++-
>  tools/testing/selftests/bpf/prog_tests/perf_link.c             | 3 ++-
>  tools/testing/selftests/bpf/test_maps.h                        | 1 +
>  tools/testing/selftests/bpf/test_progs.h                       | 1 +
>  7 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c b/tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c
> index d32e4edac930..2b8edf996126 100644
> --- a/tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c
> +++ b/tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c
> @@ -226,7 +226,8 @@ static void test_lpm_order(void)
>  static void test_lpm_map(int keysize)
>  {
>         LIBBPF_OPTS(bpf_map_create_opts, opts, .map_flags = BPF_F_NO_PREALLOC);
> -       volatile size_t n_matches, n_matches_after_delete;
> +       /* To avoid a -Wunused-but-set-variable warning. */
> +       __maybe_unused volatile size_t n_matches, n_matches_after_delete;

I think it's better to disable the warning instead of hacking the tests.
Arguably it's a grey zone whether n_matches++ qualifies as a "use".
It's certainly not a nop, since it's a volatile variable.

pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ