diff mbox series

[bpf-next] bpf, selftests: Fix cast to smaller integer type 'int' warning in raw_tp

Message ID 160134424745.11199.13841922833336698133.stgit@john-Precision-5820-Tower
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] bpf, selftests: Fix cast to smaller integer type 'int' warning in raw_tp | expand

Commit Message

John Fastabend Sept. 29, 2020, 1:50 a.m. UTC
Fix warning in bpf selftests,

progs/test_raw_tp_test_run.c:18:10: warning: cast to smaller integer type 'int' from 'struct task_struct *' [-Wpointer-to-int-cast]

Change int type cast to long to fix. Discovered with gcc-9 and llvm-11+
where llvm was recent main branch.

Fixes: 09d8ad16885ee ("selftests/bpf: Add raw_tp_test_run")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 .../selftests/bpf/progs/test_raw_tp_test_run.c     |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexei Starovoitov Sept. 29, 2020, 4:34 a.m. UTC | #1
On Mon, Sep 28, 2020 at 6:51 PM John Fastabend <john.fastabend@gmail.com> wrote:
>
> Fix warning in bpf selftests,
>
> progs/test_raw_tp_test_run.c:18:10: warning: cast to smaller integer type 'int' from 'struct task_struct *' [-Wpointer-to-int-cast]
>
> Change int type cast to long to fix. Discovered with gcc-9 and llvm-11+
> where llvm was recent main branch.
>
> Fixes: 09d8ad16885ee ("selftests/bpf: Add raw_tp_test_run")
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Applied. Thanks
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c b/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
index 1521853597d7..4c63cc87b9d0 100644
--- a/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
+++ b/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
@@ -15,7 +15,7 @@  int BPF_PROG(rename, struct task_struct *task, char *comm)
 	count++;
 	if ((__u64) task == 0x1234ULL && (__u64) comm == 0x5678ULL) {
 		on_cpu = bpf_get_smp_processor_id();
-		return (int)task + (int)comm;
+		return (long)task + (long)comm;
 	}
 
 	return 0;