BPF List
 help / color / mirror / Atom feed
* [PATCH] libpf: Fix for the compiler sanity checking
@ 2026-08-24 14:15 Tw
  2026-08-24 14:24 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Tw @ 2026-08-24 14:15 UTC (permalink / raw)
  To: bpf; +Cc: Tw

When compiling libbpf with sanitation, ubsan will report the following:
```
left shift of 1 by 31 places cannot be represented in type 'int'
```
let's fix it by casting int to u32 before shifting.

Signed-off-by: Tan Wei <tw19881113@gmail.com>
---
 tools/lib/bpf/libbpf_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 4c46d34fc..222d2f1c0 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -259,7 +259,7 @@ static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t)
 
 static inline __u32 btf_type_info(int kind, int vlen, int kflag)
 {
-	return (kflag << 31) | (kind << 24) | vlen;
+	return ((__u32)kflag << 31) | (kind << 24) | vlen;
 }
 
 enum map_def_parts {
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-25 20:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 14:15 [PATCH] libpf: Fix for the compiler sanity checking Tw
2026-08-24 14:24 ` sashiko-bot
2026-08-25 20:17   ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox