samples/bpf: xdpsock: fix swap.cocci warning
Subsystems (3)
PATCH v2 1/1 samples/bpf: xdpsock: fix swap.cocci warning
Fix following swap.cocci warning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity for swap()
---
Change log:
v2:
- Remove temp variable.
--- samples/bpf/xsk_fwd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
samples/bpf/xsk_fwd.c +1 -4
@@ -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 *)ð->ether_shost;struct ether_addr *dst_addr = (struct ether_addr *)ð->ether_dhost; -struct ether_addr tmp; - tmp = *src_addr; - *src_addr = *dst_addr; - *dst_addr = tmp; +swap (*src_addr, *dst_addr); } static void *
Signature · 1 line
2.17.1
Quoted 6 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()Signed-off-by Yihao Han <[email protected]>---
LGTM
Quoted 5 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()Signed-off-by Yihao Han <[email protected]>
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
Quoted 11 lines · Toke Høiland-Jørgensen
Quoted 5 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()Signed-off-by Yihao Han <[email protected]>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.
Quoted 8 lines
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
Quoted 6 lines
/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 statusCould we maybe get
samples/bpfadded to the BPF CI builds? :)
Maybe we could, if someone dedicated their effort towards making this happen.
Quoted 3 lines
-Toke
Quoted 8 lines · Andrii Nakryiko
Quoted 7 lines · Toke Høiland-Jørgensen
Quoted 4 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Yihao Han <[email protected]>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/bpfnowadays after fixing a bunch of compilation issues recently.
Awesome!
Quoted 3 lines
Bad news: seems like I didn't pay too much attention after building
samples/bpffor this particular patch, sorry about that. I've dropped this patch,samples/bpfbuilds for me. We should be good now.
Yup, looks good, thanks!
Quoted 12 lines
Quoted 12 lines
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
Quoted 4 lines
Quoted 1 line
Could we maybe get
samples/bpfadded 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
Quoted 39 lines · Toke Høiland-Jørgensen
Quoted 8 lines · Andrii Nakryiko
Quoted 7 lines · Toke Høiland-Jørgensen
Quoted 4 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Yihao Han <[email protected]>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/bpfnowadays after fixing a bunch of compilation issues recently.Awesome!
Quoted 3 lines
Bad news: seems like I didn't pay too much attention after building
samples/bpffor this particular patch, sorry about that. I've dropped this patch,samples/bpfbuilds for me. We should be good now.Yup, looks good, thanks!
Quoted 12 lines
Quoted 12 lines
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
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Could we maybe get
samples/bpfadded 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.
Quoted 3 lines
-Toke
Quoted 48 lines · Andrii Nakryiko
Quoted 39 lines · Toke Høiland-Jørgensen
Quoted 8 lines · Andrii Nakryiko
Quoted 7 lines · Toke Høiland-Jørgensen
Quoted 4 lines · Yihao Han
Fix following
swap.cocciwarning:
./samples/bpf/xdpsock_user.c:528:22-23:
WARNING opportunity forswap()Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Yihao Han <[email protected]>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/bpfnowadays after fixing a bunch of compilation issues recently.Awesome!
Quoted 3 lines
Bad news: seems like I didn't pay too much attention after building
samples/bpffor this particular patch, sorry about that. I've dropped this patch,samples/bpfbuilds for me. We should be good now.Yup, looks good, thanks!
Quoted 12 lines
Quoted 12 lines
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 statusQuoted 7 lines
Quoted 4 lines
Quoted 1 line
Could we maybe get
samples/bpfadded 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 ?
Quoted 6 lines
I think the right way would be to build
samples/bpffrom selftests/bpf'sMakefile. At the very least we should not require makeheaders_install(I never understood that withsamples/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 testssamples/bpfduring CI runs.
Alright, sounds fair. I'll look into that, but probably before the holidays :)
-Toke