samples/bpf: xdpsock: Use swap() instead of open coding it
Subsystems (4)
PATCH 1/1 samples/bpf: xdpsock: Use swap() instead of open coding it
Clean the following coccicheck warning:
./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for swap().
--- samples/bpf/xdpsock_user.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
samples/bpf/xdpsock_user.c +1 -4
@@ -626,11 +626,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 hex_dump (void *pkt,size_t length,u64 addr)
Signature · 1 line
2.20.1.7.g153144c
Quoted 10 lines · Jiapeng Chong
Clean the following coccicheck warning:
./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for
swap().Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>
Quoted 16 lines · Jiapeng Chong
Clean the following coccicheck warning:
./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for
swap().Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- samples/bpf/xdpsock_user.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)samples/bpf/xdpsock_user.c +0
-0
samples/bpf/xdpsock_user.c static void swap_mac_addresses(void *data) · line 630
Quoted 9 lines
samples/bpf/xdpsock_user.c +1
-4@@ -626,11 +626,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);
Don't mindlessly apply any suggestion of any robot/script without at least compile-testing:
/data/users/andriin/linux/samples/bpf/xdpsock_user.c: In function ‘swap_mac_addresses’:
/data/users/andriin/linux/samples/bpf/xdpsock_user.c:630:2: warning:
implicit declaration of function ‘swap’; did you mean ‘mmap’? [-Wimplicit-function-declaration]
swap(*src_addr, *dst_addr);
^~~~
mmap
I think this exact change was accidentally applied recently and backed out. Please stop sending such "improvements".
Quoted 6 lines
samples/bpf/xdpsock_user.c +0
-1}static void hex_dump (void *pkt,size_t length,u64 addr) --2.20.1.7.g153144c