[PATCH] bpftool: Cast variable `var` to long long

Luo Yifan posted 1 patch 1 year, 1 month ago
tools/bpf/bpftool/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] bpftool: Cast variable `var` to long long
Posted by Luo Yifan 1 year, 1 month ago
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>
---
 tools/bpf/bpftool/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index 547c1ccdc..d005e4fd6 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -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);
-- 
2.27.0
Re: [PATCH] bpftool: Cast variable `var` to long long
Posted by Quentin Monnet 1 year, 1 month ago
2024-11-12 15:37 UTC+0800 ~ Luo Yifan <luoyifan@cmss.chinamobile.com>
> 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>

Looks good this time, thank you!

Reviewed-by: Quentin Monnet <qmo@kernel.org>