All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
@ 2021-12-09  9:22 Yihao Han
  2021-12-09 20:11 ` John Fastabend
  2021-12-10 14:26 ` Toke Høiland-Jørgensen
  0 siblings, 2 replies; 7+ messages in thread
From: Yihao Han @ 2021-12-09  9:22 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, netdev, bpf, linux-kernel
  Cc: kernel, Yihao Han

Fix following swap.cocci warning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity for swap()

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
Change log:
v2:
- Remove temp variable.
---
 samples/bpf/xsk_fwd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/samples/bpf/xsk_fwd.c b/samples/bpf/xsk_fwd.c
index 1cd97c84c337..db15323728c0 100644
--- a/samples/bpf/xsk_fwd.c
+++ b/samples/bpf/xsk_fwd.c
@@ -651,11 +651,8 @@ static void swap_mac_addresses(void *data)
 	struct ether_header *eth = (struct ether_header *)data;
 	struct ether_addr *src_addr = (struct ether_addr *)&eth->ether_shost;
 	struct ether_addr *dst_addr = (struct ether_addr *)&eth->ether_dhost;
-	struct ether_addr tmp;
 
-	tmp = *src_addr;
-	*src_addr = *dst_addr;
-	*dst_addr = tmp;
+	swap(*src_addr, *dst_addr);
 }
 
 static void *
-- 
2.17.1


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

* RE: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-09  9:22 [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning Yihao Han
@ 2021-12-09 20:11 ` John Fastabend
  2021-12-10 14:26 ` Toke Høiland-Jørgensen
  1 sibling, 0 replies; 7+ messages in thread
From: John Fastabend @ 2021-12-09 20:11 UTC (permalink / raw)
  To: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, netdev, bpf, linux-kernel
  Cc: kernel, Yihao Han

Yihao Han wrote:
> Fix following swap.cocci warning:
> ./samples/bpf/xdpsock_user.c:528:22-23:
> WARNING opportunity for swap()
> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---

LGTM

Acked-by: John Fastabend <john.fastabend@gmail.com>

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

* Re: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-09  9:22 [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning Yihao Han
  2021-12-09 20:11 ` John Fastabend
@ 2021-12-10 14:26 ` Toke Høiland-Jørgensen
  2021-12-10 23:53   ` Andrii Nakryiko
  1 sibling, 1 reply; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-12-10 14:26 UTC (permalink / raw)
  To: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, netdev, bpf, linux-kernel
  Cc: kernel, Yihao Han

Yihao Han <hanyihao@vivo.com> writes:

> Fix following swap.cocci warning:
> ./samples/bpf/xdpsock_user.c:528:22-23:
> WARNING opportunity for swap()
>
> Signed-off-by: Yihao Han <hanyihao@vivo.com>

Erm, did this get applied without anyone actually trying to compile
samples? I'm getting build errors as:

  CC  /home/build/linux/samples/bpf/xsk_fwd.o
/home/build/linux/samples/bpf/xsk_fwd.c: In function ‘swap_mac_addresses’:
/home/build/linux/samples/bpf/xsk_fwd.c:658:9: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
  658 |         swap(*src_addr, *dst_addr);
      |         ^~~~
      |         swab

/usr/bin/ld: /home/build/linux/samples/bpf/xsk_fwd.o: in function `thread_func':
xsk_fwd.c:(.text+0x440): undefined reference to `swap'
collect2: error: ld returned 1 exit status


Could we maybe get samples/bpf added to the BPF CI builds? :)

-Toke


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

* Re: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-10 14:26 ` Toke Høiland-Jørgensen
@ 2021-12-10 23:53   ` Andrii Nakryiko
  2021-12-11 18:07     ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2021-12-10 23:53 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list, kernel

On Fri, Dec 10, 2021 at 6:26 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Yihao Han <hanyihao@vivo.com> writes:
>
> > Fix following swap.cocci warning:
> > ./samples/bpf/xdpsock_user.c:528:22-23:
> > WARNING opportunity for swap()
> >
> > Signed-off-by: Yihao Han <hanyihao@vivo.com>
>
> Erm, did this get applied without anyone actually trying to compile
> samples? I'm getting build errors as:

Good news: I actually do build samples/bpf nowadays after fixing a
bunch of compilation issues recently.

Bad news: seems like I didn't pay too much attention after building
samples/bpf for this particular patch, sorry about that. I've dropped
this patch, samples/bpf builds for me. We should be good now.


>
>   CC  /home/build/linux/samples/bpf/xsk_fwd.o
> /home/build/linux/samples/bpf/xsk_fwd.c: In function ‘swap_mac_addresses’:
> /home/build/linux/samples/bpf/xsk_fwd.c:658:9: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
>   658 |         swap(*src_addr, *dst_addr);
>       |         ^~~~
>       |         swab
>
> /usr/bin/ld: /home/build/linux/samples/bpf/xsk_fwd.o: in function `thread_func':
> xsk_fwd.c:(.text+0x440): undefined reference to `swap'
> collect2: error: ld returned 1 exit status
>
>
> Could we maybe get samples/bpf added to the BPF CI builds? :)

Maybe we could, if someone dedicated their effort towards making this happen.

>
> -Toke
>

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

* Re: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-10 23:53   ` Andrii Nakryiko
@ 2021-12-11 18:07     ` Toke Høiland-Jørgensen
  2021-12-12 19:46       ` Andrii Nakryiko
  0 siblings, 1 reply; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-12-11 18:07 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list, kernel

Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:

> On Fri, Dec 10, 2021 at 6:26 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>> Yihao Han <hanyihao@vivo.com> writes:
>>
>> > Fix following swap.cocci warning:
>> > ./samples/bpf/xdpsock_user.c:528:22-23:
>> > WARNING opportunity for swap()
>> >
>> > Signed-off-by: Yihao Han <hanyihao@vivo.com>
>>
>> Erm, did this get applied without anyone actually trying to compile
>> samples? I'm getting build errors as:
>
> Good news: I actually do build samples/bpf nowadays after fixing a
> bunch of compilation issues recently.

Awesome!

> Bad news: seems like I didn't pay too much attention after building
> samples/bpf for this particular patch, sorry about that. I've dropped
> this patch, samples/bpf builds for me. We should be good now.

Yup, looks good, thanks!

>>   CC  /home/build/linux/samples/bpf/xsk_fwd.o
>> /home/build/linux/samples/bpf/xsk_fwd.c: In function ‘swap_mac_addresses’:
>> /home/build/linux/samples/bpf/xsk_fwd.c:658:9: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
>>   658 |         swap(*src_addr, *dst_addr);
>>       |         ^~~~
>>       |         swab
>>
>> /usr/bin/ld: /home/build/linux/samples/bpf/xsk_fwd.o: in function `thread_func':
>> xsk_fwd.c:(.text+0x440): undefined reference to `swap'
>> collect2: error: ld returned 1 exit status
>>
>>
>> Could we maybe get samples/bpf added to the BPF CI builds? :)
>
> Maybe we could, if someone dedicated their effort towards making this
> happen.

Is it documented anywhere what that would entail? Is it just a matter of
submitting a change to https://github.com/kernel-patches/vmtest ?

-Toke


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

* Re: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-11 18:07     ` Toke Høiland-Jørgensen
@ 2021-12-12 19:46       ` Andrii Nakryiko
  2021-12-13 12:09         ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2021-12-12 19:46 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list, kernel

On Sat, Dec 11, 2021 at 10:07 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:
>
> > On Fri, Dec 10, 2021 at 6:26 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> >>
> >> Yihao Han <hanyihao@vivo.com> writes:
> >>
> >> > Fix following swap.cocci warning:
> >> > ./samples/bpf/xdpsock_user.c:528:22-23:
> >> > WARNING opportunity for swap()
> >> >
> >> > Signed-off-by: Yihao Han <hanyihao@vivo.com>
> >>
> >> Erm, did this get applied without anyone actually trying to compile
> >> samples? I'm getting build errors as:
> >
> > Good news: I actually do build samples/bpf nowadays after fixing a
> > bunch of compilation issues recently.
>
> Awesome!
>
> > Bad news: seems like I didn't pay too much attention after building
> > samples/bpf for this particular patch, sorry about that. I've dropped
> > this patch, samples/bpf builds for me. We should be good now.
>
> Yup, looks good, thanks!
>
> >>   CC  /home/build/linux/samples/bpf/xsk_fwd.o
> >> /home/build/linux/samples/bpf/xsk_fwd.c: In function ‘swap_mac_addresses’:
> >> /home/build/linux/samples/bpf/xsk_fwd.c:658:9: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
> >>   658 |         swap(*src_addr, *dst_addr);
> >>       |         ^~~~
> >>       |         swab
> >>
> >> /usr/bin/ld: /home/build/linux/samples/bpf/xsk_fwd.o: in function `thread_func':
> >> xsk_fwd.c:(.text+0x440): undefined reference to `swap'
> >> collect2: error: ld returned 1 exit status
> >>
> >>
> >> Could we maybe get samples/bpf added to the BPF CI builds? :)
> >
> > Maybe we could, if someone dedicated their effort towards making this
> > happen.
>
> Is it documented anywhere what that would entail? Is it just a matter of
> submitting a change to https://github.com/kernel-patches/vmtest ?

I think the right way would be to build samples/bpf from
selftests/bpf's Makefile. At the very least we should not require make
headers_install (I never understood that with samples/bpf, all those
up-to-date UAPI headers are right there in the same repo). Once that
is done, at the very least we'll build tests samples/bpf during CI
runs.

>
> -Toke
>

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

* Re: [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning
  2021-12-12 19:46       ` Andrii Nakryiko
@ 2021-12-13 12:09         ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-12-13 12:09 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Yihao Han, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Networking, bpf, open list, kernel

Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:

> On Sat, Dec 11, 2021 at 10:07 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>> Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:
>>
>> > On Fri, Dec 10, 2021 at 6:26 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> >>
>> >> Yihao Han <hanyihao@vivo.com> writes:
>> >>
>> >> > Fix following swap.cocci warning:
>> >> > ./samples/bpf/xdpsock_user.c:528:22-23:
>> >> > WARNING opportunity for swap()
>> >> >
>> >> > Signed-off-by: Yihao Han <hanyihao@vivo.com>
>> >>
>> >> Erm, did this get applied without anyone actually trying to compile
>> >> samples? I'm getting build errors as:
>> >
>> > Good news: I actually do build samples/bpf nowadays after fixing a
>> > bunch of compilation issues recently.
>>
>> Awesome!
>>
>> > Bad news: seems like I didn't pay too much attention after building
>> > samples/bpf for this particular patch, sorry about that. I've dropped
>> > this patch, samples/bpf builds for me. We should be good now.
>>
>> Yup, looks good, thanks!
>>
>> >>   CC  /home/build/linux/samples/bpf/xsk_fwd.o
>> >> /home/build/linux/samples/bpf/xsk_fwd.c: In function ‘swap_mac_addresses’:
>> >> /home/build/linux/samples/bpf/xsk_fwd.c:658:9: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
>> >>   658 |         swap(*src_addr, *dst_addr);
>> >>       |         ^~~~
>> >>       |         swab
>> >>
>> >> /usr/bin/ld: /home/build/linux/samples/bpf/xsk_fwd.o: in function `thread_func':
>> >> xsk_fwd.c:(.text+0x440): undefined reference to `swap'
>> >> collect2: error: ld returned 1 exit status
>> >>
>> >>
>> >> Could we maybe get samples/bpf added to the BPF CI builds? :)
>> >
>> > Maybe we could, if someone dedicated their effort towards making this
>> > happen.
>>
>> Is it documented anywhere what that would entail? Is it just a matter of
>> submitting a change to https://github.com/kernel-patches/vmtest ?
>
> I think the right way would be to build samples/bpf from
> selftests/bpf's Makefile. At the very least we should not require make
> headers_install (I never understood that with samples/bpf, all those
> up-to-date UAPI headers are right there in the same repo). Once that
> is done, at the very least we'll build tests samples/bpf during CI
> runs.

Alright, sounds fair. I'll look into that, but probably before the
holidays :)

-Toke


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

end of thread, other threads:[~2021-12-13 12:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09  9:22 [PATCH v2] samples/bpf: xdpsock: fix swap.cocci warning Yihao Han
2021-12-09 20:11 ` John Fastabend
2021-12-10 14:26 ` Toke Høiland-Jørgensen
2021-12-10 23:53   ` Andrii Nakryiko
2021-12-11 18:07     ` Toke Høiland-Jørgensen
2021-12-12 19:46       ` Andrii Nakryiko
2021-12-13 12:09         ` Toke Høiland-Jørgensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.