]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpftool: Print newline before '}' for struct with padding only fields
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 1 Oct 2022 10:44:24 +0000 (13:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Apr 2023 14:55:40 +0000 (16:55 +0200)
commit77e41187a3875ef747868ff19646a41375f2f508
treebc72df3701fb177b16b11ab1aafc98b5a2b07ae7
parent1c87a6f82a4e9bb8074a596c0acdc39ef9334473
bpftool: Print newline before '}' for struct with padding only fields

[ Upstream commit 44a726c3f23cf762ef4ce3c1709aefbcbe97f62c ]

btf_dump_emit_struct_def attempts to print empty structures at a
single line, e.g. `struct empty {}`. However, it has to account for a
case when there are no regular but some padding fields in the struct.
In such case `vlen` would be zero, but size would be non-zero.

E.g. here is struct bpf_timer from vmlinux.h before this patch:

 struct bpf_timer {
  long: 64;
long: 64;};

And after this patch:

 struct bpf_dynptr {
  long: 64;
long: 64;
 };

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221001104425.415768-1-eddyz87@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/btf_dump.c