Add bpf_core_cast(<ptr>, <type>) macro wrapper around bpf_rdonly_cast() kfunc to make it easier to use this functionality in BPF code. See patch #2 for BPF selftests conversions demonstrating improvements in code succinctness. Andrii Nakryiko (2): libbpf: add bpf_core_cast() macro selftests/bpf: convert bpf_rdonly_cast() uses to bpf_core_cast() macro tools/lib/bpf/bpf_core_read.h | 13 +++++++++++++ tools/testing/selftests/bpf/bpf_kfuncs.h | 2 +- .../testing/selftests/bpf/progs/connect_unix_prog.c | 3 +-- .../selftests/bpf/progs/getpeername_unix_prog.c | 3 +-- .../selftests/bpf/progs/getsockname_unix_prog.c | 3 +-- .../testing/selftests/bpf/progs/recvmsg_unix_prog.c | 3 +-- .../testing/selftests/bpf/progs/sendmsg_unix_prog.c | 3 +-- .../selftests/bpf/progs/sk_storage_omem_uncharge.c | 4 +--- tools/testing/selftests/bpf/progs/sock_iter_batch.c | 4 ++-- tools/testing/selftests/bpf/progs/type_cast.c | 13 +++++-------- 10 files changed, 27 insertions(+), 24 deletions(-) -- 2.34.1