summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2025-08-29 11:22:15 -0700
committerAlexei Starovoitov <ast@kernel.org>2025-09-09 15:07:58 -0700
commit387be23a95b14705a804900c3a0db5a12bf19636 (patch)
treecaab466f0bbe843f9bc2316599f442948d868d91
parent3aa9b9a165d5e9afc7d8b5dbcd508810c05c8e89 (diff)
parent5d40c038c879eeb910039adeaf6102e1c4dda807 (diff)
Merge branch 'selftests-bpf-fix-expression-result-unused-warnings-with-icecc'
Ilya Leoshkevich says: ==================== selftests/bpf: Fix "expression result unused" warnings with icecc 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). 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. 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. The solution is to add a few awkward (void) casts. I've added a detailed explanation of why they are helpful to the commit message. ==================== Link: https://patch.msgid.link/20250829030017.102615-1-iii@linux.ibm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r--tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h4
-rw-r--r--tools/testing/selftests/bpf/progs/linked_list_fail.c5
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 @@ queue:
/* 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;
}