Re: [RFC PATCH bpf-next] bpftool: avoid sign extension in unsigned enum JSON dumps
From: Quentin Monnet
Date: Fri Oct 30 2026 - 06:27:24 EST
2026-10-30 09:09 UTC+0000 ~ Hungyu Lin <dennylin0707@xxxxxxxxx>
> The BTF enum value is stored in a signed 32-bit field even when the
> enum is unsigned. Passing it directly to jsonw_uint_field(), which
> takes a uint64_t, sign-extends values with bit 31 set. For example,
> 0xffffffffU is printed as 18446744073709551615 instead of 4294967295
> by bpftool -j btf dump.
>
> Cast the value to __u32 before widening it, matching the conversion
> already used for plain-text output.
>
> Fixes: c93cc69004df ("bpftool: add ability to dump BTF types")
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
Looks correct, thank you.
Acked-by: Quentin Monnet <qmo@xxxxxxxxxx>