netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftest/bpf: fix compilation warning in sockmap_parse_prog.c
@ 2020-03-13 23:07 Andrii Nakryiko
  2020-03-13 23:53 ` [Potential Spoof] " Martin KaFai Lau
  0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2020-03-13 23:07 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Cast void * to long before casting to 32-bit __u32 to avoid compilation
warning.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/testing/selftests/bpf/progs/sockmap_parse_prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
index a5c6d5903b22..a9c2bdbd841e 100644
--- a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
+++ b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
@@ -12,7 +12,7 @@ int bpf_prog1(struct __sk_buff *skb)
 	__u32 lport = skb->local_port;
 	__u32 rport = skb->remote_port;
 	__u8 *d = data;
-	__u32 len = (__u32) data_end - (__u32) data;
+	__u32 len = (__u32)(long)data_end - (__u32)(long)data;
 	int err;
 
 	if (data + 10 > data_end) {
-- 
2.17.1


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

* Re: [Potential Spoof] [PATCH bpf-next] selftest/bpf: fix compilation warning in sockmap_parse_prog.c
  2020-03-13 23:07 [PATCH bpf-next] selftest/bpf: fix compilation warning in sockmap_parse_prog.c Andrii Nakryiko
@ 2020-03-13 23:53 ` Martin KaFai Lau
  2020-03-13 23:58   ` Andrii Nakryiko
  0 siblings, 1 reply; 3+ messages in thread
From: Martin KaFai Lau @ 2020-03-13 23:53 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, ast, daniel, andrii.nakryiko, kernel-team

On Fri, Mar 13, 2020 at 04:07:15PM -0700, Andrii Nakryiko wrote:
> Cast void * to long before casting to 32-bit __u32 to avoid compilation
> warning.
> 
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
>  tools/testing/selftests/bpf/progs/sockmap_parse_prog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> index a5c6d5903b22..a9c2bdbd841e 100644
> --- a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> +++ b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> @@ -12,7 +12,7 @@ int bpf_prog1(struct __sk_buff *skb)
>  	__u32 lport = skb->local_port;
>  	__u32 rport = skb->remote_port;
>  	__u8 *d = data;
> -	__u32 len = (__u32) data_end - (__u32) data;
I think this line can be removed.  "len" is not used.

> +	__u32 len = (__u32)(long)data_end - (__u32)(long)data;

>  	int err;
>  
>  	if (data + 10 > data_end) {
> -- 
> 2.17.1
> 

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

* Re: [Potential Spoof] [PATCH bpf-next] selftest/bpf: fix compilation warning in sockmap_parse_prog.c
  2020-03-13 23:53 ` [Potential Spoof] " Martin KaFai Lau
@ 2020-03-13 23:58   ` Andrii Nakryiko
  0 siblings, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-03-13 23:58 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: Andrii Nakryiko, bpf, Networking, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

On Fri, Mar 13, 2020 at 4:53 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Fri, Mar 13, 2020 at 04:07:15PM -0700, Andrii Nakryiko wrote:
> > Cast void * to long before casting to 32-bit __u32 to avoid compilation
> > warning.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > ---
> >  tools/testing/selftests/bpf/progs/sockmap_parse_prog.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> > index a5c6d5903b22..a9c2bdbd841e 100644
> > --- a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> > +++ b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
> > @@ -12,7 +12,7 @@ int bpf_prog1(struct __sk_buff *skb)
> >       __u32 lport = skb->local_port;
> >       __u32 rport = skb->remote_port;
> >       __u8 *d = data;
> > -     __u32 len = (__u32) data_end - (__u32) data;
> I think this line can be removed.  "len" is not used.

hm... never checked that, I assumed compiler will emit warning about
unused variable... v2 without this line is coming...

>
> > +     __u32 len = (__u32)(long)data_end - (__u32)(long)data;
>
> >       int err;
> >
> >       if (data + 10 > data_end) {
> > --
> > 2.17.1
> >

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

end of thread, other threads:[~2020-03-13 23:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 23:07 [PATCH bpf-next] selftest/bpf: fix compilation warning in sockmap_parse_prog.c Andrii Nakryiko
2020-03-13 23:53 ` [Potential Spoof] " Martin KaFai Lau
2020-03-13 23:58   ` Andrii Nakryiko

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).