Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Optimize the redundant code in the bpf_object__init_user_btf_maps() function.

In the elf_sec_data() function, the input parameter 'scn' will be
evaluated. If it is NULL, then it will directly return NULL. Therefore,
the return value of the elf_sec_data() function already takes into
account the case where the input parameter scn is NULL. Therefore,
subsequently, the code only needs to check whether the return value of
the elf_sec_data() function is NULL.

Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20251024080802.642189-1-jianyungao89@gmail.com

authored by

Jianyun Gao and committed by
Andrii Nakryiko
4f361895 23f852da

+1 -1
+1 -1
tools/lib/bpf/libbpf.c
··· 2996 2996 2997 2997 scn = elf_sec_by_idx(obj, obj->efile.btf_maps_shndx); 2998 2998 data = elf_sec_data(obj, scn); 2999 - if (!scn || !data) { 2999 + if (!data) { 3000 3000 pr_warn("elf: failed to get %s map definitions for %s\n", 3001 3001 MAPS_ELF_SEC, obj->path); 3002 3002 return -EINVAL;