-
Notifications
You must be signed in to change notification settings - Fork 5
selftests/bpf: Change variable types for -Wsign-compare #6182
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: Change variable types for -Wsign-compare #6182
Conversation
|
Upstream branch: 7361c86 |
b7224b3 to
2b803ce
Compare
|
Upstream branch: 04a8995 |
6e8713c to
a6d4574
Compare
2b803ce to
9b33bf7
Compare
|
Upstream branch: 04a8995 |
a6d4574 to
cd70041
Compare
9b33bf7 to
33b4c7f
Compare
|
Upstream branch: 96d31df |
cd70041 to
a1e7ab7
Compare
33b4c7f to
e698de7
Compare
|
Upstream branch: e758657 |
a1e7ab7 to
93732f0
Compare
e698de7 to
ee5122f
Compare
|
Upstream branch: e758657 |
93732f0 to
ede9c3f
Compare
ee5122f to
d5592b9
Compare
|
Upstream branch: e758657 |
ede9c3f to
6c6c686
Compare
d5592b9 to
27d6d8b
Compare
|
Upstream branch: e758657 |
6c6c686 to
9e48726
Compare
27d6d8b to
4d1f3ab
Compare
|
Upstream branch: e758657 |
9e48726 to
6b58830
Compare
4d1f3ab to
7ba9a34
Compare
|
Upstream branch: ff88079 |
6b58830 to
afdf607
Compare
7ba9a34 to
2991dd5
Compare
|
Upstream branch: f9db3a3 |
afdf607 to
5abd5fd
Compare
2991dd5 to
583dec7
Compare
|
Upstream branch: 8842732 |
This is a follow up patch for commit 495d2d8("selftests/bpf: Attempt to build BPF programs with -Wsign-compare") from Alexei Starovoitov[1] to be able to enable -Wsign-compare C compilation flag for clang since -Wall doesn't add it and BPF programs are built with clang.This has the benefit to catch problematic comparisons in future tests as quoted from the commit message:" int i = -1; unsigned int j = 1; if (i < j) // this is false. long i = -1; unsigned int j = 1; if (i < j) // this is true. C standard for reference: - If either operand is unsigned long the other shall be converted to unsigned long. - Otherwise, if one operand is a long int and the other unsigned int, then if a long int can represent all the values of an unsigned int, the unsigned int shall be converted to a long int; otherwise both operands shall be converted to unsigned long int. - Otherwise, if either operand is long, the other shall be converted to long. - Otherwise, if either operand is unsigned, the other shall be converted to unsigned. Unfortunately clang's -Wsign-compare is very noisy. It complains about (s32)a == (u32)b which is safe and doen't have surprising behavior." This specific patch supresses the following warnings when -Wsign-compare is enabled: 1 warning generated. progs/bpf_iter_bpf_percpu_array_map.c:35:16: warning: comparison of integers of different signs: 'int' and 'const volatile __u32' (aka 'const volatile unsigned int') [-Wsign-compare] 35 | for (i = 0; i < num_cpus; i++) { | ~ ^ ~~~~~~~~ 1 warning generated. progs/bpf_qdisc_fifo.c:93:2: warning: comparison of integers of different signs: 'int' and '__u32' (aka 'unsigned int') [-Wsign-compare] 93 | bpf_for(i, 0, sch->q.qlen) { | ^ ~ ~~~~~~~~~~~ Should be noted that many more similar changes are still needed in order to be able to enable the -Wsign-compare flag since -Werror is enabled and would cause compilation of bpf selftests to fail. [1]. Link:torvalds/linux@495d2d8 Signed-off-by: Mehdi Ben Hadj Khelifa <[email protected]>
5abd5fd to
d8b76d3
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1013549 expired. Closing PR. |
Pull request for series with
subject: selftests/bpf: Change variable types for -Wsign-compare
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1013549