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
6 changes: 5 additions & 1 deletion tools/testing/selftests/bpf/bpf_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

#define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node)))

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

/* Description
* Allocates an object of the type represented by 'local_type_id' in
* program BTF. User may use the bpf_core_type_id_local macro to pass the
Expand All @@ -20,7 +24,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
23 changes: 19 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,33 @@ int map_compat_raw_tp_w(void *ctx)
SEC("?tc")
int obj_type_id_oor(void *ctx)
{
bpf_obj_new_impl(~0UL, NULL);
void *f;

f = bpf_obj_new_impl(~0UL, NULL);
(void)f;

return 0;
}

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

f = bpf_obj_new_impl(bpf_core_type_id_local(int), (void *)42);
(void)f;

return 0;
}

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

f = bpf_obj_new(union { int data; unsigned udata; });
(void)f;

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

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

f = bpf_obj_new(struct foo);
(void)f;

return 0;
}

Expand Down
Loading