Skip to contentSkip to conversation

libbpf: fix u64-to-pointer cast on 32-bit arches

PATCH Applied Andrii Nakryiko 2 participants 2 messages Mar 19, 2024 – Mar 20, 2024

Subsystems (2)
lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 libbpf: fix u64-to-pointer cast on 32-bit arches

It's been reported that (void *)map->map_extra is causing compilation warnings on 32-bit architectures. It's easy enough to fix this by casting to long first.

Fixes 79ff13e99169 ("libbpf: Add support for bpf_arena.")
---
 tools/lib/bpf/libbpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +2 -2
index 3a756d61c120..37c27be2449c 100644
@@ -5366,8 +5366,8 @@ bpf_object__create_maps(struct bpf_object *obj)
 					goto err_out;
 			}
 			if (map->def.type == BPF_MAP_TYPE_ARENA) {
-				map->mmaped = mmap((void *)map->map_extra, bpf_map_mmap_sz(map),
-						   PROT_READ | PROT_WRITE,
+				map->mmaped = mmap((void *)(long)map->map_extra,
+						   bpf_map_mmap_sz(map), PROT_READ | PROT_WRITE,
 						   map->map_extra ? MAP_SHARED | MAP_FIXED : MAP_SHARED,
 						   map->fd, 0);
 				if (map->mmaped == MAP_FAILED) {
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:

Quoted 9 lines · On Tue, 19 Mar 2024 14:51:43 -0700 you wrote:

It's been reported that (void *)map->map_extra is causing compilation warnings on 32-bit architectures. It's easy enough to fix this by casting to long first.

Fixes 79ff13e99169 ("libbpf: Add support for bpf_arena.")

[...]

Here is the summary with links:
- [bpf] libbpf: fix u64-to-pointer cast on 32-bit arches

    https://git.kernel.org/bpf/bpf/c/5ab8cb89dbb6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html