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: b265002747 ("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>
This commit is contained in:
Andrii Nakryiko 2019-07-08 21:00:07 -07:00 committed by Daniel Borkmann
parent b3b50f05dc
commit 36db2a94f1

View File

@ -4126,8 +4126,8 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name,
} }
attr.size = sizeof(attr); attr.size = sizeof(attr);
attr.type = type; attr.type = type;
attr.config1 = (uint64_t)(void *)name; /* kprobe_func or uprobe_path */ attr.config1 = ptr_to_u64(name); /* kprobe_func or uprobe_path */
attr.config2 = offset; /* kprobe_addr or probe_offset */ attr.config2 = offset; /* kprobe_addr or probe_offset */
/* pid filter is meaningful only for uprobes */ /* pid filter is meaningful only for uprobes */
pfd = syscall(__NR_perf_event_open, &attr, pfd = syscall(__NR_perf_event_open, &attr,