Skip to content

Commit

Permalink
bpftool: replace return value PTR_ERR(NULL) with 0
Browse files Browse the repository at this point in the history
There is no reasons to keep PTR_ERR() when kern_btf=NULL, let's just
return 0.
This also cleans this part of code from using libbpf_get_error().

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Acked-by: Yonghong Song <yhs@fb.com>
Suggested-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20221120112515.38165-3-sahid.ferdjaoui@industrialdiscipline.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Sahid Orentino Ferdjaoui authored and Alexei Starovoitov committed Nov 21, 2022
1 parent 9b81075 commit 989f285
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tools/bpf/bpftool/struct_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ static __s32 get_map_info_type_id(void)
return map_info_type_id;

kern_btf = get_btf_vmlinux();
if (libbpf_get_error(kern_btf)) {
map_info_type_id = PTR_ERR(kern_btf);
return map_info_type_id;
}
if (!kern_btf)
return 0;

map_info_type_id = btf__find_by_name_kind(kern_btf, "bpf_map_info",
BTF_KIND_STRUCT);
Expand Down

0 comments on commit 989f285

Please sign in to comment.