bpftool: Cast variable `var` to long long
authorLuo Yifan <luoyifan@cmss.chinamobile.com>
Tue, 12 Nov 2024 07:37:01 +0000 (15:37 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 13 Nov 2024 20:17:12 +0000 (12:17 -0800)
When the SIGNED condition is met, the variable `var` should be cast to
`long long` instead of `unsigned long long`.

Signed-off-by: Luo Yifan <luoyifan@cmss.chinamobile.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20241112073701.283362-1-luoyifan@cmss.chinamobile.com
tools/bpf/bpftool/btf.c

index 547c1cc..d005e4f 100644 (file)
@@ -289,7 +289,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
                        } else {
                                if (btf_kflag(t))
                                        printf("\n\t'%s' val=%lldLL", name,
-                                              (unsigned long long)val);
+                                              (long long)val);
                                else
                                        printf("\n\t'%s' val=%lluULL", name,
                                               (unsigned long long)val);