libbpf: fix ptr to u64 conversion warning on 32-bit platforms
Subsystems (4)
PATCH 1/1 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 */
^
--- tools/lib/bpf/libbpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +2 -2
@@ -4126,8 +4126,8 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name, } attr.size =sizeof (attr); attr.type = type; - attr.config1 = (uint64_t )(void *)name;/* kprobe_func or uprobe_path */ - attr.config2 = offset;/* kprobe_addr or probe_offset */ + attr.config1 =ptr_to_u64 (name);/* kprobe_func or uprobe_path */ + attr.config2 = offset;/* kprobe_addr or probe_offset */ /* pid filter is meaningful only for uprobes */ pfd = syscall(__NR_perf_event_open, &attr,
Signature · 1 line
2.17.1
Quoted 6 lines · Andrii Nakryiko
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_funcoruprobe_path*/
Quoted 6 lines
^Reported-by Matt Hart <[email protected]>Fixes b26500274767 ("libbpf: add kprobe/uprobe attach API")Tested-by Matt Hart <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Quoted 20 lines
--- tools/lib/bpf/libbpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/lib/bpf/libbpf.c +2
-2@@ -4126,8 +4126,8 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name, } attr.size =sizeof (attr); attr.type = type; - attr.config1 = (uint64_t )(void *)name;/* kprobe_func or uprobe_path */ - attr.config2 = offset;/* kprobe_addr or probe_offset */ + attr.config1 =ptr_to_u64 (name);/* kprobe_func or uprobe_path */ + attr.config2 = offset;/* kprobe_addr or probe_offset */ /* pid filter is meaningful only for uprobes */ pfd = syscall(__NR_perf_event_open, &attr,
Quoted 12 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko
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_funcoruprobe_path*/^
Quoted 7 lines
Quoted 4 lines
Reported-by Matt Hart <[email protected]>Fixes b26500274767 ("libbpf: add kprobe/uprobe attach API")Tested-by Matt Hart <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Acked-by Yonghong Song <[email protected]>
How do we get this merged? I see the build failure has now propagated up to mainline :(
Quoted 20 lines
Quoted 20 lines
--- tools/lib/bpf/libbpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/lib/bpf/libbpf.c +2
-2@@ -4126,8 +4126,8 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name, } attr.size =sizeof (attr); attr.type = type; - attr.config1 = (uint64_t )(void *)name;/* kprobe_func or uprobe_path */ - attr.config2 = offset;/* kprobe_addr or probe_offset */ + attr.config1 =ptr_to_u64 (name);/* kprobe_func or uprobe_path */ + attr.config2 = offset;/* kprobe_addr or probe_offset */ /* pid filter is meaningful only for uprobes */ pfd = syscall(__NR_perf_event_open, &attr,
Daniel Borkmann
maintainerQuoted 15 lines · Matt Hart
Quoted 14 lines · Yonghong Song
Quoted 12 lines · Andrii Nakryiko
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_funcoruprobe_path*/^Reported-by Matt Hart <[email protected]>Fixes b26500274767 ("libbpf: add kprobe/uprobe attach API")Tested-by Matt Hart <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Quoted 4 lines
Quoted 1 line
Acked-by Yonghong Song <[email protected]>How do we get this merged? I see the build failure has now propagated up to mainline :(
I just applied the fix to bpf tree, will go its usual route to mainline.