Skip to content

Commit 3319169

Browse files
iii-iKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix "expression result unused" warnings with icecc
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] llvm/llvm-project#142614 Signed-off-by: Ilya Leoshkevich <[email protected]>
1 parent 14aadb9 commit 3319169

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
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

0 commit comments

Comments
 (0)