* [PATCH bpf-next v4 1/1] selftests/bpf: Fix "expression result unused" warnings with icecc
2025-08-29 2:53 [PATCH bpf-next v4 0/1] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich
@ 2025-08-29 2:53 ` Ilya Leoshkevich
2025-08-29 4:47 ` Yonghong Song
2025-08-29 18:30 ` [PATCH bpf-next v4 0/1] " patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Ilya Leoshkevich @ 2025-08-29 2:53 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.
obj_new_no_struct() and obj_new_acq() use the bpf_obj_new() macro and
discard the result. arena_spin_lock_slowpath() uses two macros that
produce values and ignores the results. Add (void) casts 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 for the arena_spin_lock_slowpath() issue, 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 ++--
tools/testing/selftests/bpf/progs/linked_list_fail.c | 5 ++---
2 files changed, 4 insertions(+), 5 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
diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c
index 6438982b928b..ddd26d1a083f 100644
--- a/tools/testing/selftests/bpf/progs/linked_list_fail.c
+++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c
@@ -226,8 +226,7 @@ int obj_new_no_composite(void *ctx)
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 +251,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;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v4 0/1] selftests/bpf: Fix "expression result unused" warnings with icecc
2025-08-29 2:53 [PATCH bpf-next v4 0/1] selftests/bpf: Fix "expression result unused" warnings with icecc Ilya Leoshkevich
2025-08-29 2:53 ` [PATCH bpf-next v4 1/1] " Ilya Leoshkevich
@ 2025-08-29 18:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-29 18:30 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: ast, daniel, andrii, bpf, hca, gor, agordeev
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Fri, 29 Aug 2025 04:53:56 +0200 you wrote:
> v3: https://lore.kernel.org/bpf/20250827194929.416969-1-iii@linux.ibm.com/
> v3 -> v4: Go back to the original solution (Yonghong, Alexei).
>
> 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).
>
> [...]
Here is the summary with links:
- [bpf-next,v4,1/1] selftests/bpf: Fix "expression result unused" warnings with icecc
https://git.kernel.org/bpf/bpf/c/90336fe5fb6a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread