For consistency of output, emit "name <anon>" for BTFs without the name. This
keeps output more consistent and obvious.

Suggested-by: Song Liu <songliubrav...@fb.com>
Signed-off-by: Andrii Nakryiko <and...@kernel.org>
---
 tools/bpf/bpftool/btf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index ed5e97157241..bd46af6a61cc 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -750,6 +750,8 @@ show_btf_plain(struct bpf_btf_info *info, int fd,
                printf("name [%s]  ", name);
        else if (name && name[0])
                printf("name %s  ", name);
+       else
+               printf("name <anon>  ");
        printf("size %uB", info->btf_size);
 
        n = 0;
-- 
2.24.1

Reply via email to