Skip to content

Commit 387be23

Browse files
author
Alexei Starovoitov
committed
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/[email protected]/ v3 -> v4: Go back to the original solution (Yonghong, Alexei). v2: https://lore.kernel.org/bpf/[email protected]/ 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/[email protected]/ 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/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents 3aa9b9a + 5d40c03 commit 387be23

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val
302302
* barriers.
303303
*/
304304
if (val & _Q_LOCKED_MASK)
305-
smp_cond_load_acquire_label(&lock->locked, !VAL, release_err);
305+
(void)smp_cond_load_acquire_label(&lock->locked, !VAL, release_err);
306306

307307
/*
308308
* 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
380380
/* Link @node into the waitqueue. */
381381
WRITE_ONCE(prev->next, node);
382382

383-
arch_mcs_spin_lock_contended_label(&node->locked, release_node_err);
383+
(void)arch_mcs_spin_lock_contended_label(&node->locked, release_node_err);
384384

385385
/*
386386
* While waiting for the MCS lock, the next pointer may have

tools/testing/selftests/bpf/progs/linked_list_fail.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ int obj_new_no_composite(void *ctx)
226226
SEC("?tc")
227227
int obj_new_no_struct(void *ctx)
228228
{
229-
230-
bpf_obj_new(union { int data; unsigned udata; });
229+
(void)bpf_obj_new(union { int data; unsigned udata; });
231230
return 0;
232231
}
233232

@@ -252,7 +251,7 @@ int new_null_ret(void *ctx)
252251
SEC("?tc")
253252
int obj_new_acq(void *ctx)
254253
{
255-
bpf_obj_new(struct foo);
254+
(void)bpf_obj_new(struct foo);
256255
return 0;
257256
}
258257

0 commit comments

Comments
 (0)