Skip to content

Conversation

@kernel-patches-daemon-bpf-rc
Copy link

Pull request for series with
subject: selftests/bpf: Fix "expression result unused" warnings with icecc
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 2465bb8
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 2660b9d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d3abefe
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 4c229f3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: bd27626
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 737433c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

iii-i added 2 commits August 28, 2025 09:54
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 <[email protected]>
Signed-off-by: Ilya Leoshkevich <[email protected]>
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]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 98857d1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996203
version: 3

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot deleted the series/996203=>bpf-next branch August 31, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants