From 0c349b4b668804f6c034d1853fc9ee22da32b44c Mon Sep 17 00:00:00 2001 From: Leon Hwang Date: Sun, 22 Oct 2023 18:49:26 +0800 Subject: [PATCH] btf: correct printing size of Int type in bytes It seems OK that the printing size of Int type in bits. But while printing a struct, like 'struct sk_buff', it seems strange that the printing size units of Int type and Struct/Union type are different: : offset=1088 : Union[fields=2] size: 4 csum: offset=0 csum: Typedef:"__wsum"[Typedef:"__u32"] __wsum: Typedef:"__u32"[Int:"unsigned int"] __u32: Int:"unsigned int"[unsigned size=32] : offset=0 : Struct[fields=2] priority: offset=1120 priority: Typedef:"__u32"[Int:"unsigned int"] __u32: Int:"unsigned int"[unsigned size=32] So, it's better to make the printing size of Int type in bytes same as Struct/Union type. Signed-off-by: Leon Hwang --- btf/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/btf/types.go b/btf/types.go index 8fe329aa4..421cc387d 100644 --- a/btf/types.go +++ b/btf/types.go @@ -117,7 +117,7 @@ type Int struct { } func (i *Int) Format(fs fmt.State, verb rune) { - formatType(fs, verb, i, i.Encoding, "size=", i.Size*8) + formatType(fs, verb, i, i.Encoding, "size=", i.Size) } func (i *Int) TypeName() string { return i.Name }