linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] samples, bpf: suppress compiler warning
@ 2021-05-11 14:04 Hailong Liu
  2021-05-12 19:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Hailong Liu @ 2021-05-11 14:04 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Yonghong Song, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh, netdev,
	bpf, linux-kernel, Hailong Liu

From: Hailong Liu <liu.hailong6@zte.com.cn>

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>
---
 samples/bpf/task_fd_query_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/bpf/task_fd_query_user.c b/samples/bpf/task_fd_query_user.c
index a78025b0026b..c9a0ca8351fd 100644
--- a/samples/bpf/task_fd_query_user.c
+++ b/samples/bpf/task_fd_query_user.c
@@ -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,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] samples, bpf: suppress compiler warning
  2021-05-11 14:04 [PATCH] samples, bpf: suppress compiler warning Hailong Liu
@ 2021-05-12 19:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-12 19:40 UTC (permalink / raw)
  To: Hailong Liu
  Cc: ast, yhs, daniel, andrii, kafai, songliubraving, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel, liu.hailong6

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 11 May 2021 22:04:29 +0800 you wrote:
> From: Hailong Liu <liu.hailong6@zte.com.cn>
> 
> 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;
> 
> [...]

Here is the summary with links:
  - samples, bpf: suppress compiler warning
    https://git.kernel.org/bpf/bpf-next/c/0303ce17347a

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-12 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 14:04 [PATCH] samples, bpf: suppress compiler warning Hailong Liu
2021-05-12 19:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).