Commit b0222d1d authored by Mykyta Yatsenko's avatar Mykyta Yatsenko Committed by Daniel Borkmann

bpftool: Fix handling enum64 in btf dump sorting

Wrong function is used to access the first enum64 element. Substituting btf_enum(t)
with btf_enum64(t) for BTF_KIND_ENUM64.

Fixes: 94133cf2 ("bpftool: Introduce btf c dump sorting")
Signed-off-by: default avatarMykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarQuentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20240902171721.105253-1-mykyta.yatsenko5@gmail.com
parent 5d2784e2
...@@ -561,9 +561,10 @@ static const char *btf_type_sort_name(const struct btf *btf, __u32 index, bool f ...@@ -561,9 +561,10 @@ static const char *btf_type_sort_name(const struct btf *btf, __u32 index, bool f
case BTF_KIND_ENUM64: { case BTF_KIND_ENUM64: {
int name_off = t->name_off; int name_off = t->name_off;
/* Use name of the first element for anonymous enums if allowed */ if (!from_ref && !name_off && btf_vlen(t))
if (!from_ref && !t->name_off && btf_vlen(t)) name_off = btf_kind(t) == BTF_KIND_ENUM64 ?
name_off = btf_enum(t)->name_off; btf_enum64(t)->name_off :
btf_enum(t)->name_off;
return btf__name_by_offset(btf, name_off); return btf__name_by_offset(btf, name_off);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment