Skip to content

Commit c451505

Browse files
MehdibenhadjkhelifaKernel Patches Daemon
authored andcommitted
selftests/bpf: Prepare to add -Wsign-compare for bpf tests
-Change only variable types for correct sign comparisons Signed-off-by: Mehdi Ben Hadj Khelifa <[email protected]>
1 parent 298af5d commit c451505

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp, struct bpf_dynptr *xd
8989
struct vip vip = {};
9090
int dport;
9191
__u32 csum = 0;
92-
int i;
92+
size_t i;
9393

9494
__builtin_memset(eth_buffer, 0, sizeof(eth_buffer));
9595
__builtin_memset(iph_buffer_tcp, 0, sizeof(iph_buffer_tcp));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp)
8585
struct vip vip = {};
8686
int dport;
8787
__u32 csum = 0;
88-
int i;
88+
size_t i;
8989

9090
if (iph + 1 > data_end)
9191
return XDP_DROP;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
372372

373373
next_iph_u16 = (__u16 *) iph;
374374
__pragma_loop_unroll_full
375-
for (int i = 0; i < sizeof(struct iphdr) >> 1; i++)
375+
for (size_t i = 0; i < sizeof(struct iphdr) >> 1; i++)
376376
csum += *next_iph_u16++;
377377
iph->check = ~((csum & 0xffff) + (csum >> 16));
378378
if (bpf_xdp_adjust_head(xdp, (int)sizeof(struct iphdr)))
@@ -423,7 +423,7 @@ int send_icmp_reply(void *data, void *data_end)
423423
iph->check = 0;
424424
next_iph_u16 = (__u16 *) iph;
425425
__pragma_loop_unroll_full
426-
for (int i = 0; i < sizeof(struct iphdr) >> 1; i++)
426+
for (size_t i = 0; i < sizeof(struct iphdr) >> 1; i++)
427427
csum += *next_iph_u16++;
428428
iph->check = ~((csum & 0xffff) + (csum >> 16));
429429
return swap_mac_and_send(data, data_end);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ __u64 uretprobe_multi_func_3_result = 0;
2020

2121
__u64 uprobe_multi_sleep_result = 0;
2222

23-
int pid = 0;
23+
__u32 pid = 0;
2424
int child_pid = 0;
2525
int child_tid = 0;
2626
int child_pid_usdt = 0;
2727
int child_tid_usdt = 0;
2828

29-
int expect_pid = 0;
29+
__u32 expect_pid = 0;
3030
bool bad_pid_seen = false;
3131
bool bad_pid_seen_usdt = false;
3232

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
#include <bpf/bpf_helpers.h>
44
#include <bpf/bpf_tracing.h>
55
#include <stdbool.h>
6+
#include <stddef.h>
67
#include "bpf_kfuncs.h"
78
#include "bpf_misc.h"
89

910
char _license[] SEC("license") = "GPL";
1011

1112
int pid = 0;
1213

13-
int idx_entry = 0;
14-
int idx_return = 0;
14+
size_t idx_entry = 0;
15+
size_t idx_return = 0;
1516

1617
__u64 test_uprobe_cookie_entry[6];
1718
__u64 test_uprobe_cookie_return[3];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ int loop_inside_iter_volatile_limit(const void *ctx)
593593
{
594594
struct bpf_iter_num it;
595595
int *v, sum = 0;
596-
__u64 i = 0;
596+
__s32 i = 0;
597597

598598
bpf_iter_num_new(&it, 0, ARR2_SZ);
599599
while ((v = bpf_iter_num_next(&it))) {

0 commit comments

Comments
 (0)