Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: fix ptr to u64 conversion warning on 32-bit platforms

On 32-bit platforms compiler complains about conversion:

libbpf.c: In function ‘perf_event_open_probe’:
libbpf.c:4112:17: error: cast from pointer to integer of different
size [-Werror=pointer-to-int-cast]
attr.config1 = (uint64_t)(void *)name; /* kprobe_func or uprobe_path */
^

Reported-by: Matt Hart <matthew.hart@linaro.org>
Fixes: b26500274767 ("libbpf: add kprobe/uprobe attach API")
Tested-by: Matt Hart <matthew.hart@linaro.org>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
36db2a94 b3b50f05

+2 -2
+2 -2
tools/lib/bpf/libbpf.c
··· 4126 4126 } 4127 4127 attr.size = sizeof(attr); 4128 4128 attr.type = type; 4129 - attr.config1 = (uint64_t)(void *)name; /* kprobe_func or uprobe_path */ 4130 - attr.config2 = offset; /* kprobe_addr or probe_offset */ 4129 + attr.config1 = ptr_to_u64(name); /* kprobe_func or uprobe_path */ 4130 + attr.config2 = offset; /* kprobe_addr or probe_offset */ 4131 4131 4132 4132 /* pid filter is meaningful only for uprobes */ 4133 4133 pfd = syscall(__NR_perf_event_open, &attr,