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: 4 additions & 0 deletions tools/lib/bpf/bpf_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
*/
#define __hidden __attribute__((visibility("hidden")))

#ifndef __must_check
#define __must_check __attribute__((__warn_unused_result__))
#endif

/* When utilizing vmlinux.h with BPF CO-RE, user BPF programs can't include
* any system-level headers (such as stddef.h, linux/version.h, etc), and
* commonly-used macros like NULL and KERNEL_VERSION aren't available through
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/bpf_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* A pointer to an object of the type corresponding to the passed in
* 'local_type_id', or NULL on failure.
*/
extern void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym;
extern __must_check void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym;

/* Convenience macro to wrap over bpf_obj_new_impl */
#define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL))
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val
* barriers.
*/
if (val & _Q_LOCKED_MASK)
smp_cond_load_acquire_label(&lock->locked, !VAL, release_err);
(void)smp_cond_load_acquire_label(&lock->locked, !VAL, release_err);

/*
* take ownership and clear the pending bit.
Expand Down Expand Up @@ -380,7 +380,7 @@ int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val
/* Link @node into the waitqueue. */
WRITE_ONCE(prev->next, node);

arch_mcs_spin_lock_contended_label(&node->locked, release_node_err);
(void)arch_mcs_spin_lock_contended_label(&node->locked, release_node_err);

/*
* While waiting for the MCS lock, the next pointer may have
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/progs/linked_list_fail.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ int map_compat_raw_tp_w(void *ctx)
SEC("?tc")
int obj_type_id_oor(void *ctx)
{
bpf_obj_new_impl(~0UL, NULL);
(void)bpf_obj_new_impl(~0UL, NULL);
return 0;
}

SEC("?tc")
int obj_new_no_composite(void *ctx)
{
bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42);
(void)bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42);
return 0;
}

SEC("?tc")
int obj_new_no_struct(void *ctx)
{

bpf_obj_new(union { int data; unsigned udata; });
(void)bpf_obj_new(union { int data; unsigned udata; });
return 0;
}

Expand All @@ -252,7 +252,7 @@ int new_null_ret(void *ctx)
SEC("?tc")
int obj_new_acq(void *ctx)
{
bpf_obj_new(struct foo);
(void)bpf_obj_new(struct foo);
return 0;
}

Expand Down
Loading