btf_dump_type_data_check_zero() returns -ENODATA when a datum is all zero (nothing to dump). In the BTF_KIND_STRUCT case the per-member result is compared with ENODATA (no minus sign), unlike every other branch which uses -ENODATA. The function only ever returns -ENODATA, so the comparison `err != ENODATA` is always true and the loop bails out on the first all-zero member: a struct that still has non-zero members is reported as empty and skipped by the dumper. Use -ENODATA so non-zero members are handled correctly. Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data") Signed-off-by: Gu Bin --- tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index 7dedd3975c39..ea9a34db4c00 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -2567,7 +2567,7 @@ static int btf_dump_type_data_check_zero(struct btf_dump *d, bit_sz = btf_member_bitfield_size(t, i); err = btf_dump_type_data_check_zero(d, mtype, m->type, data + moffset / 8, moffset % 8, bit_sz); - if (err != ENODATA) + if (err != -ENODATA) return err; } return -ENODATA; -- 2.55.0.windows.3