]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
samples, bpf: Suppress compiler warning
authorHailong Liu <liu.hailong6@zte.com.cn>
Tue, 11 May 2021 14:04:29 +0000 (22:04 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 12 May 2021 19:29:43 +0000 (12:29 -0700)
While cross compiling on ARM32 , the casting from pointer to __u64 will
cause warnings:

samples/bpf/task_fd_query_user.c: In function 'main':
samples/bpf/task_fd_query_user.c:399:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
399 | uprobe_file_offset = (__u64)main - (__u64)&__executable_start;
| ^
samples/bpf/task_fd_query_user.c:399:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
399 | uprobe_file_offset = (__u64)main - (__u64)&__executable_start;

Workaround this by using "unsigned long" to adapt to different ARCHs.

Signed-off-by: Hailong Liu <liu.hailong6@zte.com.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210511140429.89426-1-liuhailongg6@163.com
samples/bpf/task_fd_query_user.c

index a78025b0026b94f0e18825c187de8da63cef6e7b..c9a0ca8351fd631df991d197f98b412049b6c611 100644 (file)
@@ -396,7 +396,7 @@ int main(int argc, char **argv)
         * on different systems with different compilers. The right way is
         * to parse the ELF file. We took a shortcut here.
         */
-       uprobe_file_offset = (__u64)main - (__u64)&__executable_start;
+       uprobe_file_offset = (unsigned long)main - (unsigned long)&__executable_start;
        CHECK_AND_RET(test_nondebug_fs_probe("uprobe", (char *)argv[0],
                                             uprobe_file_offset, 0x0, false,
                                             BPF_FD_TYPE_UPROBE,