Skip to content

Commit b0222d1

Browse files
mykyta5borkmann
authored andcommitted
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: 94133cf ("bpftool: Introduce btf c dump sorting") Signed-off-by: Mykyta Yatsenko <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 5d2784e commit b0222d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/bpf/bpftool/btf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,10 @@ static const char *btf_type_sort_name(const struct btf *btf, __u32 index, bool f
561561
case BTF_KIND_ENUM64: {
562562
int name_off = t->name_off;
563563

564-
/* Use name of the first element for anonymous enums if allowed */
565-
if (!from_ref && !t->name_off && btf_vlen(t))
566-
name_off = btf_enum(t)->name_off;
564+
if (!from_ref && !name_off && btf_vlen(t))
565+
name_off = btf_kind(t) == BTF_KIND_ENUM64 ?
566+
btf_enum64(t)->name_off :
567+
btf_enum(t)->name_off;
567568

568569
return btf__name_by_offset(btf, name_off);
569570
}

0 commit comments

Comments
 (0)