-
Notifications
You must be signed in to change notification settings - Fork 5
selftests/bpf: Fix "expression result unused" warnings with icecc #5840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selftests/bpf: Fix "expression result unused" warnings with icecc #5840
Conversation
|
Upstream branch: 2465bb8 |
8f9c214 to
c9c941d
Compare
|
Upstream branch: 2660b9d |
43f9df6 to
6103a47
Compare
c9c941d to
c640618
Compare
|
Upstream branch: d3abefe |
6103a47 to
4631fb3
Compare
c640618 to
721f1da
Compare
|
Upstream branch: 4c229f3 |
4631fb3 to
21374b6
Compare
721f1da to
c2e9835
Compare
|
Upstream branch: bd27626 |
21374b6 to
80abfe1
Compare
c2e9835 to
83124e1
Compare
|
Upstream branch: 737433c |
80abfe1 to
18028ae
Compare
83124e1 to
27199db
Compare
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]>
|
Upstream branch: 98857d1 |
18028ae to
3319169
Compare
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