Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/lib/bpf/usdt.bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int bpf_usdt_arg_size(struct pt_regs *ctx, __u64 arg_num)
if (arg_num >= BPF_USDT_MAX_ARG_CNT)
return -ENOENT;
barrier_var(arg_num);
if (arg_num >= spec->arg_cnt)
if (arg_num >= (__u64)spec->arg_cnt)
return -ENOENT;

arg_spec = &spec->args[arg_num];
Expand Down Expand Up @@ -184,7 +184,7 @@ int bpf_usdt_arg(struct pt_regs *ctx, __u64 arg_num, long *res)
if (arg_num >= BPF_USDT_MAX_ARG_CNT)
return -ENOENT;
barrier_var(arg_num);
if (arg_num >= spec->arg_cnt)
if (arg_num >= (__u64)spec->arg_cnt)
return -ENOENT;

arg_spec = &spec->args[arg_num];
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ BPF_CFLAGS = -g -Wall -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \
-I$(abspath $(OUTPUT)/../usr/include) \
-std=gnu11 \
-fno-strict-aliasing \
-Wno-compare-distinct-pointer-types
# TODO: enable me -Wsign-compare
-Wno-compare-distinct-pointer-types \
-Wsign-compare

CLANG_CFLAGS = $(CLANG_SYS_INCLUDES)

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/bpf_arena_htab.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static hashtab_elem_t *lookup_elem_raw(arena_list_head_t *head, __u32 hash, int
hashtab_elem_t *l;

list_for_each_entry(l, head, hash_node)
if (l->hash == hash && l->key == key)
if ((__u32)l->hash == hash && l->key == key)
return l;

return NULL;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/arena_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int arena_list_add(void *ctx)

list_head = &global_head;

for (i = zero; i < cnt && can_loop; i++) {
for (i = zero; i < (__u64)cnt && can_loop; i++) {
struct elem __arena *n = bpf_alloc(sizeof(*n));

test_val++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int BPF_PROG(sched_process_fork, struct task_struct *parent, struct task_struct
{
struct storage *stg;

if (parent->tgid != bench_pid)
if ((__u32)parent->tgid != bench_pid)
return 0;

stg = bpf_task_storage_get(&task_storage_map, child, NULL,
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/bind_perm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

static __always_inline int bind_prog(struct bpf_sock_addr *ctx, int family)
static __always_inline int bind_prog(struct bpf_sock_addr *ctx, __u32 family)
{
struct bpf_sock *sk;

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/bpf_cc_cubic.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked,
(__u64)tp->snd_ssthresh * prr_delivered + tp->prior_cwnd - 1;
sndcnt = (__u32)div64_u64(dividend, (__u64)tp->prior_cwnd) - tp->prr_out;
} else {
sndcnt = max(prr_delivered - tp->prr_out, newly_acked_sacked);
sndcnt = max(prr_delivered - tp->prr_out, (__u32)newly_acked_sacked);
if (flag & FLAG_SND_UNA_ADVANCED && !newly_lost)
sndcnt++;
sndcnt = min(delta, sndcnt);
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/progs/bpf_cubic.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static void bictcp_update(struct bpf_bictcp *ca, __u32 cwnd, __u32 acked)
ca->ack_cnt += acked; /* count the number of ACKed packets */

if (ca->last_cwnd == cwnd &&
(__s32)(tcp_jiffies32 - ca->last_time) <= HZ / 32)
(__s32)(tcp_jiffies32 - ca->last_time) <= (__s32)HZ / 32)
return;

/* The CUBIC function can update ca->cnt at most once per jiffy.
Expand Down Expand Up @@ -474,7 +474,7 @@ static void hystart_update(struct sock *sk, __u32 delay)
if (sk->sk_pacing_status == SK_PACING_NONE)
threshold >>= 1;

if ((__s32)(now - ca->round_start) > threshold) {
if ((__s32)(now - ca->round_start) > (__s32)threshold) {
ca->found = 1;
tp->snd_ssthresh = tp->snd_cwnd;
}
Expand Down Expand Up @@ -512,7 +512,7 @@ void BPF_PROG(bpf_cubic_acked, struct sock *sk, const struct ack_sample *sample)
return;

/* Discard delay samples right after fast recovery */
if (ca->epoch_start && (__s32)(tcp_jiffies32 - ca->epoch_start) < HZ)
if (ca->epoch_start && (__s32)(tcp_jiffies32 - ca->epoch_start) < (__s32)HZ)
return;

delay = sample->rtt_us;
Expand All @@ -525,7 +525,7 @@ void BPF_PROG(bpf_cubic_acked, struct sock *sk, const struct ack_sample *sample)

/* hystart triggers when cwnd is larger than some threshold */
if (!ca->found && tcp_in_slow_start(tp) && hystart &&
tp->snd_cwnd >= hystart_low_window)
tp->snd_cwnd >= (__u32)hystart_low_window)
hystart_update(sk, delay);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int dump_bpf_percpu_array_map(struct bpf_iter__bpf_map_elem *ctx)
__u32 *key = ctx->key;
void *pptr = ctx->value;
__u32 step;
int i;
__u32 i;

if (key == (void *)0 || pptr == (void *)0)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int dump_task_stack(struct bpf_iter__task *ctx)
BPF_SEQ_PRINTF(seq, "pid: %8u num_entries: %8u\n", task->pid,
retlen / SIZE_OF_ULONG);
for (i = 0; i < MAX_STACK_TRACE_DEPTH; i++) {
if (retlen > i * SIZE_OF_ULONG)
if ((__u32)retlen > i * SIZE_OF_ULONG)
BPF_SEQ_PRINTF(seq, "[<0>] %pB\n", (void *)entries[i]);
}
BPF_SEQ_PRINTF(seq, "\n");
Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/bpf/progs/bpf_iter_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ int dump_task_sleepable(struct bpf_iter__task *ctx)
/* Same length as the string */
ret = bpf_copy_from_user_task_str((char *)task_str2, 10, user_ptr, task, 0);
/* only need to do the task pid check once */
if (bpf_strncmp(task_str2, 10, "test_data\0") != 0 || ret != 10 || task->tgid != pid) {
if (bpf_strncmp(task_str2, 10, "test_data\0") != 0 || ret != 10 ||
(__u32)task->tgid != pid) {
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/progs/bpf_iter_vma_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ int get_vma_offset(struct bpf_iter__task_vma *ctx)
if (task == NULL || vma == NULL)
return 0;

if (last_tgid != task->tgid)
if (last_tgid != (__u32)task->tgid)
unique_tgid_cnt++;
last_tgid = task->tgid;

if (task->tgid != pid)
if ((__u32)task->tgid != pid)
return 0;

if (vma->vm_start <= address && vma->vm_end > address) {
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/bpf_qdisc_fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void BPF_PROG(bpf_fifo_reset, struct Qdisc *sch)
{
struct bpf_list_node *node;
struct skb_node *skbn;
int i;
__u32 i;

bpf_for(i, 0, sch->q.qlen) {
struct sk_buff *skb = NULL;
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int BPF_PROG(bpf_fq_enqueue, struct sk_buff *skb, struct Qdisc *sch,

jiffies = bpf_jiffies64();
if ((s64)(jiffies - (flow_copy->age + q.flow_refill_delay)) > 0) {
if (flow_copy->credit < q.quantum)
if ((__u32)flow_copy->credit < q.quantum)
flow_copy->credit = q.quantum;
}
flow_copy->age = 0;
Expand Down Expand Up @@ -590,7 +590,7 @@ struct sk_buff *BPF_PROG(bpf_fq_dequeue, struct Qdisc *sch)
{
struct dequeue_nonprio_ctx cb_ctx = {};
struct sk_buff *skb = NULL;
int i;
__u32 i;

if (!sch->q.qlen)
goto out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int get_retval(struct bpf_sockopt *ctx)
__sync_fetch_and_add(&invocations, 1);

/* optval larger than PAGE_SIZE use kernel's buffer. */
if (ctx->optlen > page_size)
if ((__u32)ctx->optlen > page_size)
ctx->optlen = 0;

return 1;
Expand All @@ -37,7 +37,7 @@ int set_eisconn(struct bpf_sockopt *ctx)
assertion_error = 1;

/* optval larger than PAGE_SIZE use kernel's buffer. */
if (ctx->optlen > page_size)
if ((__u32)ctx->optlen > page_size)
ctx->optlen = 0;

return 1;
Expand All @@ -51,7 +51,7 @@ int clear_retval(struct bpf_sockopt *ctx)
ctx->retval = 0;

/* optval larger than PAGE_SIZE use kernel's buffer. */
if (ctx->optlen > page_size)
if ((__u32)ctx->optlen > page_size)
ctx->optlen = 0;

return 1;
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/progs/cpumask_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int BPF_PROG(test_first_firstzero_cpu, struct task_struct *task, u64 clone_flags
if (!cpumask)
return 0;

if (bpf_cpumask_first(cast(cpumask)) < nr_cpus) {
if (bpf_cpumask_first(cast(cpumask)) < (__u32)nr_cpus) {
err = 3;
goto release_exit;
}
Expand Down Expand Up @@ -866,7 +866,7 @@ int BPF_PROG(test_populate, struct task_struct *task, u64 clone_flags)
* access NR_CPUS, the upper bound for nr_cpus, so we infer
* it from the size of cpumask_t.
*/
if (nr_cpus < 0 || nr_cpus >= CPUMASK_TEST_MASKLEN * 8) {
if (nr_cpus < 0 || (__u32)nr_cpus >= CPUMASK_TEST_MASKLEN * 8) {
err = 3;
goto out;
}
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/progs/dynptr_success.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int test_read_write(void *ctx)
char write_data[64] = "hello there, world!!";
char read_data[64] = {};
struct bpf_dynptr ptr;
int i;
__u32 i;

if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
Expand Down Expand Up @@ -114,7 +114,7 @@ int test_dynptr_data(void *ctx)
if (err)
return 0;

if (val != *(int *)data)
if ((int)val != *(int *)data)
err = 5;

return 0;
Expand Down Expand Up @@ -626,7 +626,7 @@ int BPF_PROG(test_dynptr_skb_tp_btf, void *skb, void *location)

static inline int bpf_memcmp(const char *a, const char *b, u32 size)
{
int i;
__u32 i;

bpf_for(i, 0, size) {
if (a[i] != b[i])
Expand Down Expand Up @@ -937,7 +937,7 @@ static __always_inline void test_dynptr_probe(void *ptr, bpf_read_dynptr_fn_t bp
{
char buf[sizeof(expected_str)];
struct bpf_dynptr ptr_buf;
int i;
__u32 i;

if (bpf_get_current_pid_tgid() >> 32 != pid)
return;
Expand Down
16 changes: 8 additions & 8 deletions tools/testing/selftests/bpf/progs/iters.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ SEC("raw_tp")
__success
int iter_array_fill(const void *ctx)
{
int sum, i;
__u32 sum, i;

MY_PID_GUARD();

Expand All @@ -395,7 +395,7 @@ SEC("raw_tp")
__success
int iter_nested_iters(const void *ctx)
{
int sum, row, col;
__u64 sum, row, col;

MY_PID_GUARD();

Expand Down Expand Up @@ -463,7 +463,7 @@ int iter_nested_deeply_iters(const void *ctx)

static __noinline void fill_inner_dimension(int row)
{
int col;
__u64 col;

bpf_for(col, 0, ARRAY_SIZE(arr2d[0])) {
arr2d[row][col] = row * col;
Expand All @@ -472,7 +472,7 @@ static __noinline void fill_inner_dimension(int row)

static __noinline int sum_inner_dimension(int row)
{
int sum = 0, col;
__u64 sum = 0, col;

bpf_for(col, 0, ARRAY_SIZE(arr2d[0])) {
sum += arr2d[row][col];
Expand All @@ -487,7 +487,7 @@ SEC("raw_tp")
__success
int iter_subprog_iters(const void *ctx)
{
int sum, row, col;
__u64 sum, row, col;

MY_PID_GUARD();

Expand Down Expand Up @@ -626,7 +626,7 @@ __success
int iter_stack_array_loop(const void *ctx)
{
long arr1[16], arr2[16], sum = 0;
int i;
__u32 i;

MY_PID_GUARD();

Expand Down Expand Up @@ -663,7 +663,7 @@ static __noinline void fill(struct bpf_iter_num *it, int *arr, __u32 n, int mul)

while ((t = bpf_iter_num_next(it))) {
i = *t;
if (i >= n)
if ((__u32)i >= n)
break;
arr[i] = i * mul;
}
Expand Down Expand Up @@ -1537,7 +1537,7 @@ int iter_arr_with_actual_elem_count(const void *ctx)
{
int i, n = loop_data.n, sum = 0;

if (n > ARRAY_SIZE(loop_data.data))
if ((__u64)n > ARRAY_SIZE(loop_data.data))
return 0;

bpf_for(i, 0, n) {
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/kfunc_call_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int kfunc_syscall_test(struct syscall_test_args *args)
{
const long size = args->size;

if (size > sizeof(args->data))
if ((__u64)size > sizeof(args->data))
return -7; /* -E2BIG */

bpf_kfunc_call_test_mem_len_pass1(&args->data, sizeof(args->data));
Expand Down
10 changes: 5 additions & 5 deletions tools/testing/selftests/bpf/progs/linked_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int list_push_pop_multiple(struct bpf_spin_lock *lock, struct bpf_list_head *hea
{
struct bpf_list_node *n;
struct foo *f[200], *pf;
int i;
__u64 i;

/* Loop following this check adds nodes 2-at-a-time in order to
* validate multiple release_on_unlock release logic
Expand Down Expand Up @@ -144,7 +144,7 @@ int list_push_pop_multiple(struct bpf_spin_lock *lock, struct bpf_list_head *hea
if (!n)
return 3;
pf = container_of(n, struct foo, node2);
if (pf->data != (ARRAY_SIZE(f) - i - 1)) {
if ((__u64)pf->data != (ARRAY_SIZE(f) - i - 1)) {
bpf_obj_drop(pf);
return 4;
}
Expand All @@ -163,7 +163,7 @@ int list_push_pop_multiple(struct bpf_spin_lock *lock, struct bpf_list_head *hea
if (!n)
return 5;
pf = container_of(n, struct foo, node2);
if (pf->data != i) {
if ((__u64)pf->data != i) {
bpf_obj_drop(pf);
return 6;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ int list_in_list(struct bpf_spin_lock *lock, struct bpf_list_head *head, bool le
struct bpf_list_node *n;
struct bar *ba[8], *b;
struct foo *f;
int i;
__u64 i;

f = bpf_obj_new(typeof(*f));
if (!f)
Expand Down Expand Up @@ -238,7 +238,7 @@ int list_in_list(struct bpf_spin_lock *lock, struct bpf_list_head *head, bool le
return 6;
}
b = container_of(n, struct bar, node);
if (b->data != i) {
if ((__u64)b->data != i) {
bpf_obj_drop(f);
bpf_obj_drop(b);
return 7;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int BPF_PROG(test_void_hook, struct linux_binprm *bprm)
__u32 key = 0;
__u64 *value;

if (monitored_pid == pid)
if ((__u32)monitored_pid == pid)
bprm_count++;

bpf_copy_from_user(args, sizeof(args), (void *)bprm->vma->vm_mm->arg_start);
Expand Down
Loading
Loading