Skip to content

Commit 4f36189

Browse files
Jianyun Gaoanakryiko
authored andcommitted
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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 23f852d commit 4f36189

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2996,7 +2996,7 @@ static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict,
29962996

29972997
scn = elf_sec_by_idx(obj, obj->efile.btf_maps_shndx);
29982998
data = elf_sec_data(obj, scn);
2999-
if (!scn || !data) {
2999+
if (!data) {
30003000
pr_warn("elf: failed to get %s map definitions for %s\n",
30013001
MAPS_ELF_SEC, obj->path);
30023002
return -EINVAL;

0 commit comments

Comments
 (0)