* [PATCH bpf-next v3 0/2] selftests/bpf: Fix "expression result unused" warnings with icecc @ 2025-08-27 19:46 Ilya Leoshkevich 2025-08-27 19:46 ` [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check Ilya Leoshkevich 2025-08-27 19:46 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich 0 siblings, 2 replies; 6+ messages in thread From: Ilya Leoshkevich @ 2025-08-27 19:46 UTC (permalink / raw) To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Ilya Leoshkevich v2: https://lore.kernel.org/bpf/20250827130519.411700-1-iii@linux.ibm.com/ v2 -> v3: Do not touch libbpf, explain how having two function declarations works (Andrii). Fix bpf-gcc build (CI). v1: https://lore.kernel.org/bpf/20250508113804.304665-1-iii@linux.ibm.com/ v1 -> v2: Annotate bpf_obj_new_impl() with __must_check (Alexei). Add an explanation about icecc. Hi, I took another look at the "expression result unused" warnings I've been seeing, and it turned out that the root cause was the icecc compiler wrapper and what I consider a clang bug. Back then I've reported that the problem was reproducible with plain clang, but now I see that it was clearly a mixup, sorry about that. In this series I implement Alexei's suggestion to annotate bpf_obj_new_impl() with __must_check and add (void) casts to the respective testcase. There remain two awkward (void) casts and I'm not sure if I can somehow make them look nicer. But I've added a detailed explanation how they are helpful to the commit message. Best regards, Ilya Ilya Leoshkevich (2): selftests/bpf: Annotate bpf_obj_new_impl() with __must_check selftests/bpf: Fix "expression result unused" warnings with icecc .../testing/selftests/bpf/bpf_experimental.h | 6 ++++- .../selftests/bpf/progs/bpf_arena_spin_lock.h | 4 ++-- .../selftests/bpf/progs/linked_list_fail.c | 23 +++++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) -- 2.50.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check 2025-08-27 19:46 [PATCH bpf-next v3 0/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich @ 2025-08-27 19:46 ` Ilya Leoshkevich 2025-08-27 21:37 ` Yonghong Song 2025-08-27 19:46 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich 1 sibling, 1 reply; 6+ messages in thread From: Ilya Leoshkevich @ 2025-08-27 19:46 UTC (permalink / raw) To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Ilya Leoshkevich The verifier requires that pointers returned by bpf_obj_new_impl() are either dropped or stored in a map. Therefore programs that do not use its return values will fail to load. Make the compiler point out these issues. Adjust selftests that check that the verifier does indeed spot these bugs. Note that now there two different bpf_obj_new_impl() declarations: one with __must_check from bpf_experimental.h, and one without from vmlinux.h. According to the GCC doc [1] this is fine and has the desired effect: Compatible attribute specifications on distinct declarations of the same function are merged. [1] https://gcc.gnu.org/onlinedocs/gcc-12.4.0/gcc/Function-Attributes.html Link: https://lore.kernel.org/bpf/CAADnVQL6Q+QRv3_JwEd26biwGpFYcwD_=BjBJWLAtpgOP9CKRw@mail.gmail.com/ Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- .../testing/selftests/bpf/bpf_experimental.h | 6 ++++- .../selftests/bpf/progs/linked_list_fail.c | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h index da7e230f2781..a8f206f4fdb9 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -8,6 +8,10 @@ #define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node))) +#ifndef __must_check +#define __must_check __attribute__((__warn_unused_result__)) +#endif + /* Description * Allocates an object of the type represented by 'local_type_id' in * program BTF. User may use the bpf_core_type_id_local macro to pass the @@ -20,7 +24,7 @@ * A pointer to an object of the type corresponding to the passed in * 'local_type_id', or NULL on failure. */ -extern void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym; +extern __must_check void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym; /* Convenience macro to wrap over bpf_obj_new_impl */ #define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL)) diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c index 6438982b928b..1e30d103e1c7 100644 --- a/tools/testing/selftests/bpf/progs/linked_list_fail.c +++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c @@ -212,22 +212,33 @@ int map_compat_raw_tp_w(void *ctx) SEC("?tc") int obj_type_id_oor(void *ctx) { - bpf_obj_new_impl(~0UL, NULL); + void *f; + + f = bpf_obj_new_impl(~0UL, NULL); + (void)f; + return 0; } SEC("?tc") int obj_new_no_composite(void *ctx) { - bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42); + void *f; + + f = bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42); + (void)f; + return 0; } SEC("?tc") int obj_new_no_struct(void *ctx) { + void *f; + + f = bpf_obj_new(union { int data; unsigned udata; }); + (void)f; - bpf_obj_new(union { int data; unsigned udata; }); return 0; } @@ -252,7 +263,11 @@ int new_null_ret(void *ctx) SEC("?tc") int obj_new_acq(void *ctx) { - bpf_obj_new(struct foo); + void *f; + + f = bpf_obj_new(struct foo); + (void)f; + return 0; } -- 2.50.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check 2025-08-27 19:46 ` [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check Ilya Leoshkevich @ 2025-08-27 21:37 ` Yonghong Song 2025-08-28 0:50 ` Alexei Starovoitov 0 siblings, 1 reply; 6+ messages in thread From: Yonghong Song @ 2025-08-27 21:37 UTC (permalink / raw) To: Ilya Leoshkevich, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev On 8/27/25 12:46 PM, Ilya Leoshkevich wrote: > The verifier requires that pointers returned by bpf_obj_new_impl() are > either dropped or stored in a map. Therefore programs that do not use > its return values will fail to load. Make the compiler point out these > issues. Adjust selftests that check that the verifier does indeed spot > these bugs. > > Note that now there two different bpf_obj_new_impl() declarations: one > with __must_check from bpf_experimental.h, and one without from > vmlinux.h. According to the GCC doc [1] this is fine and has the > desired effect: > > Compatible attribute specifications on distinct declarations of the > same function are merged. > > [1] https://gcc.gnu.org/onlinedocs/gcc-12.4.0/gcc/Function-Attributes.html > > Link: https://lore.kernel.org/bpf/CAADnVQL6Q+QRv3_JwEd26biwGpFYcwD_=BjBJWLAtpgOP9CKRw@mail.gmail.com/ > Suggested-by: Alexei Starovoitov <ast@kernel.org> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> > --- > .../testing/selftests/bpf/bpf_experimental.h | 6 ++++- > .../selftests/bpf/progs/linked_list_fail.c | 23 +++++++++++++++---- > 2 files changed, 24 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h > index da7e230f2781..a8f206f4fdb9 100644 > --- a/tools/testing/selftests/bpf/bpf_experimental.h > +++ b/tools/testing/selftests/bpf/bpf_experimental.h > @@ -8,6 +8,10 @@ > > #define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node))) > > +#ifndef __must_check > +#define __must_check __attribute__((__warn_unused_result__)) > +#endif As you mentioned in Patch 2, we definitely has an issue with clang. I tried the following experiments with latest master branch. $ cat run3.sh echo ".c => .i => .o" clang -g -Wall -Werror -D__TARGET_ARCH_x86 -mlittle-endian \ -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include \ -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf \ -I/home/yhs/work/bpf-next/tools/include/uapi \ -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include \ -std=gnu11 -fno-strict-aliasing -Wno-compare-distinct-pointer-types \ -idirafter /home/yhs/work/llvm-project/llvm/build.21/Release/lib/clang/21/include \ -idirafter /usr/local/include -idirafter /usr/include -DENABLE_ATOMICS_TESTS \ -O2 --target=bpfel -E progs/linked_list_fail.c -mcpu=v4 \ -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/linked_list_fail.i clang -g -Wall -Werror -mlittle-endian -std=gnu11 -fno-strict-aliasing \ -Wno-compare-distinct-pointer-types -O2 --target=bpfel -c linked_list_fail.i \ -mcpu=v4 \ -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/cpuv4/linked_list_fail.bpf.o echo ".c => .o" clang -g -Wall -Werror -D__TARGET_ARCH_x86 -mlittle-endian \ -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include \ -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf \ -I/home/yhs/work/bpf-next/tools/include/uapi \ -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include \ -std=gnu11 -fno-strict-aliasing -Wno-compare-distinct-pointer-types \ -idirafter /home/yhs/work/llvm-project/llvm/build.21/Release/lib/clang/21/include \ -idirafter /usr/local/include -idirafter /usr/include -DENABLE_ATOMICS_TESTS \ -O2 --target=bpfel -c progs/linked_list_fail.c -mcpu=v4 \ -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/cpuv4/linked_list_fail.bpf.o $ ./run3.sh .c => .i => .o progs/linked_list_fail.c:230:3: error: expression result unused [-Werror,-Wunused-value] 230 | ((union { int data; unsigned udata; } *)bpf_obj_new_impl(__builtin_btf_type_id(*((typeof(union { int data; unsigned udata; }) *) 0), BPF_TYPE_ID_LOCAL), ((void *)0))); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ progs/linked_list_fail.c:255:3: error: expression result unused [-Werror,-Wunused-value] 255 | ((struct foo *)bpf_obj_new_impl(__builtin_btf_type_id(*((typeof(struct foo) *) 0), BPF_TYPE_ID_LOCAL), ((void *)0))); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. .c => .o $ The clang compilation command line is from selftest build with V=1. Compiling from .c to .o is okay, but from .c => .i => .o will have errors due to unused value. I think you do not need __must_check here. '-Wall -Werror' seems already covered this. You can also mention the clang bug in the commit message. The fix will be below: diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c index 6438982b928b..35616b5c9b9e 100644 --- a/tools/testing/selftests/bpf/progs/linked_list_fail.c +++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c @@ -227,7 +227,7 @@ SEC("?tc") int obj_new_no_struct(void *ctx) { - bpf_obj_new(union { int data; unsigned udata; }); + (void)bpf_obj_new(union { int data; unsigned udata; }); return 0; } @@ -252,7 +252,7 @@ int new_null_ret(void *ctx) SEC("?tc") int obj_new_acq(void *ctx) { - bpf_obj_new(struct foo); + (void)bpf_obj_new(struct foo); return 0; } I think this probably will address your icecc issue. > + > /* Description > * Allocates an object of the type represented by 'local_type_id' in > * program BTF. User may use the bpf_core_type_id_local macro to pass the > @@ -20,7 +24,7 @@ > * A pointer to an object of the type corresponding to the passed in > * 'local_type_id', or NULL on failure. > */ > -extern void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym; > +extern __must_check void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym; > > /* Convenience macro to wrap over bpf_obj_new_impl */ > #define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL)) > diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c > index 6438982b928b..1e30d103e1c7 100644 > --- a/tools/testing/selftests/bpf/progs/linked_list_fail.c > +++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c > @@ -212,22 +212,33 @@ int map_compat_raw_tp_w(void *ctx) > SEC("?tc") > int obj_type_id_oor(void *ctx) > { > - bpf_obj_new_impl(~0UL, NULL); > + void *f; > + > + f = bpf_obj_new_impl(~0UL, NULL); > + (void)f; > + > return 0; > } > > SEC("?tc") > int obj_new_no_composite(void *ctx) > { > - bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42); > + void *f; > + > + f = bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42); > + (void)f; > + > return 0; > } > > SEC("?tc") > int obj_new_no_struct(void *ctx) > { > + void *f; > + > + f = bpf_obj_new(union { int data; unsigned udata; }); > + (void)f; > > - bpf_obj_new(union { int data; unsigned udata; }); > return 0; > } > > @@ -252,7 +263,11 @@ int new_null_ret(void *ctx) > SEC("?tc") > int obj_new_acq(void *ctx) > { > - bpf_obj_new(struct foo); > + void *f; > + > + f = bpf_obj_new(struct foo); > + (void)f; > + > return 0; > } > ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check 2025-08-27 21:37 ` Yonghong Song @ 2025-08-28 0:50 ` Alexei Starovoitov 0 siblings, 0 replies; 6+ messages in thread From: Alexei Starovoitov @ 2025-08-28 0:50 UTC (permalink / raw) To: Yonghong Song Cc: Ilya Leoshkevich, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev On Wed, Aug 27, 2025 at 2:38 PM Yonghong Song <yonghong.song@linux.dev> wrote: > > > diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c > index 6438982b928b..35616b5c9b9e 100644 > --- a/tools/testing/selftests/bpf/progs/linked_list_fail.c > +++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c > @@ -227,7 +227,7 @@ SEC("?tc") > int obj_new_no_struct(void *ctx) > { > > - bpf_obj_new(union { int data; unsigned udata; }); > + (void)bpf_obj_new(union { int data; unsigned udata; }); > return 0; > } > > @@ -252,7 +252,7 @@ int new_null_ret(void *ctx) > SEC("?tc") > int obj_new_acq(void *ctx) > { > - bpf_obj_new(struct foo); > + (void)bpf_obj_new(struct foo); > return 0; > } > > I think this probably will address your icecc issue. Ilya, does above fix it ? If so we should probably do that and hold on __must_check, since if we're getting pedantic __alloc_size__ is a better tag than __must_check, but it will be even harder to get through pahole. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc 2025-08-27 19:46 [PATCH bpf-next v3 0/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich 2025-08-27 19:46 ` [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check Ilya Leoshkevich @ 2025-08-27 19:46 ` Ilya Leoshkevich 2025-08-27 21:46 ` Yonghong Song 1 sibling, 1 reply; 6+ messages in thread From: Ilya Leoshkevich @ 2025-08-27 19:46 UTC (permalink / raw) To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Ilya Leoshkevich icecc is a compiler wrapper that distributes compile jobs over a build farm [1]. It works by sending toolchain binaries and preprocessed source code to remote machines. Unfortunately using it with BPF selftests causes build failures due to a clang bug [2]. The problem is that clang suppresses the -Wunused-value warning if the unused expression comes from a macro expansion. Since icecc compiles preprocessed source code, this information is not available. This leads to -Wunused-value false positives. arena_spin_lock_slowpath() uses two macros that produce values and ignores the results. Add (void) cast to explicitly indicate that this is intentional and suppress the warning. An alternative solution is to change the macros to not produce values. This would work today, but in the future there may appear users who need them. Another potential solution is to replace these macros with functions. Unfortunately this would not work, because these macros work with unknown types and control flow. [1] https://github.com/icecc/icecream [2] https://github.com/llvm/llvm-project/issues/142614 Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h index d67466c1ff77..f90531cf3ee5 100644 --- a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h +++ b/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h @@ -302,7 +302,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val * barriers. */ if (val & _Q_LOCKED_MASK) - smp_cond_load_acquire_label(&lock->locked, !VAL, release_err); + (void)smp_cond_load_acquire_label(&lock->locked, !VAL, release_err); /* * take ownership and clear the pending bit. @@ -380,7 +380,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val /* Link @node into the waitqueue. */ WRITE_ONCE(prev->next, node); - arch_mcs_spin_lock_contended_label(&node->locked, release_node_err); + (void)arch_mcs_spin_lock_contended_label(&node->locked, release_node_err); /* * While waiting for the MCS lock, the next pointer may have -- 2.50.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc 2025-08-27 19:46 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich @ 2025-08-27 21:46 ` Yonghong Song 0 siblings, 0 replies; 6+ messages in thread From: Yonghong Song @ 2025-08-27 21:46 UTC (permalink / raw) To: Ilya Leoshkevich, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev On 8/27/25 12:46 PM, Ilya Leoshkevich wrote: > icecc is a compiler wrapper that distributes compile jobs over a build > farm [1]. It works by sending toolchain binaries and preprocessed > source code to remote machines. > > Unfortunately using it with BPF selftests causes build failures due to > a clang bug [2]. The problem is that clang suppresses the > -Wunused-value warning if the unused expression comes from a macro > expansion. Since icecc compiles preprocessed source code, this > information is not available. This leads to -Wunused-value false > positives. > > arena_spin_lock_slowpath() uses two macros that produce values and > ignores the results. Add (void) cast to explicitly indicate that this > is intentional and suppress the warning. > > An alternative solution is to change the macros to not produce values. > This would work today, but in the future there may appear users who > need them. Another potential solution is to replace these macros with > functions. Unfortunately this would not work, because these macros > work with unknown types and control flow. > > [1] https://github.com/icecc/icecream > [2] https://github.com/llvm/llvm-project/issues/142614 As you described in [1] and [2]. The failure is due to the compilation from .i file to .o file. $ cat run2.sh echo '.c -> .i -> .o' clang -g -Wall -Werror -D__TARGET_ARCH_x86 -mlittle-endian -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf -I/home/yhs/work/bpf-next/tools/include/uapi -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include -std=gnu11 -fno-strict-aliasing -Wno-compare-distinct-pointer-types -idirafter /home/yhs/work/llvm-project/llvm/build.21/Release/lib/clang/21/include -idirafter /usr/local/include -idirafter /usr/include -DENABLE_ATOMICS_TESTS -O2 --target=bpfel -E progs/arena_spin_lock.c -mcpu=v4 -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/arena_spin_lock.i clang -g -Wall -Werror -mlittle-endian -std=gnu11 -fno-strict-aliasing -Wno-compare-distinct-pointer-types -O2 --target=bpfel -c arena_spin_lock.i -mcpu=v4 -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/cpuv4/arena_spin_lock.bpf.o echo '.c -> .o' clang -g -Wall -Werror -D__TARGET_ARCH_x86 -mlittle-endian -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf -I/home/yhs/work/bpf-next/tools/include/uapi -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include -std=gnu11 -fno-strict-aliasing -Wno-compare-distinct-pointer-types -idirafter /home/yhs/work/llvm-project/llvm/build.21/Release/lib/clang/21/include -idirafter /usr/local/include -idirafter /usr/include -DENABLE_ATOMICS_TESTS -O2 --target=bpfel -c progs/arena_spin_lock.c -mcpu=v4 -o /home/yhs/work/bpf-next/tools/testing/selftests/bpf/cpuv4/arena_spin_lock.bpf.o $ ./run2.sh .c -> .i -> .o In file included from progs/arena_spin_lock.c:7: progs/bpf_arena_spin_lock.h:305:1765: error: expression result unused [-Werror,-Wunused-value] 305 | ...unsigned long __val; __sync_fetch_and_add(&__val, 0); }); else asm volatile("" ::: "memory"); }); }); (typeof(*(&lock->locked)))__val; }); | ^ ~~~~~ progs/bpf_arena_spin_lock.h:383:1769: error: expression result unused [-Werror,-Wunused-value] 383 | ...unsigned long __val; __sync_fetch_and_add(&__val, 0); }); else asm volatile("" ::: "memory"); }); }); (typeof(*(&node->locked)))__val; }); | ^ ~~~~~ 2 errors generated. .c -> .o $ I am not sure whether we should do anything with pahole or libbpf. Essentially this is a clang bug. We should push clang community to fix the problem. > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> > --- > tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h > index d67466c1ff77..f90531cf3ee5 100644 > --- a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h > +++ b/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h > @@ -302,7 +302,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val > * barriers. > */ > if (val & _Q_LOCKED_MASK) > - smp_cond_load_acquire_label(&lock->locked, !VAL, release_err); > + (void)smp_cond_load_acquire_label(&lock->locked, !VAL, release_err); > > /* > * take ownership and clear the pending bit. > @@ -380,7 +380,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val > /* Link @node into the waitqueue. */ > WRITE_ONCE(prev->next, node); > > - arch_mcs_spin_lock_contended_label(&node->locked, release_node_err); > + (void)arch_mcs_spin_lock_contended_label(&node->locked, release_node_err); > > /* > * While waiting for the MCS lock, the next pointer may have ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-28 0:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-08-27 19:46 [PATCH bpf-next v3 0/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich 2025-08-27 19:46 ` [PATCH bpf-next v3 1/2] selftests/bpf: Annotate bpf_obj_new_impl() with __must_check Ilya Leoshkevich 2025-08-27 21:37 ` Yonghong Song 2025-08-28 0:50 ` Alexei Starovoitov 2025-08-27 19:46 ` [PATCH bpf-next v3 2/2] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich 2025-08-27 21:46 ` Yonghong Song
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).