All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it
@ 2022-01-13 16:22 Jiapeng Chong
  2022-01-13 18:59 ` Song Liu
  2022-01-15  1:29 ` Andrii Nakryiko
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2022-01-13 16:22 UTC (permalink / raw)
  To: ast
  Cc: daniel, davem, kuba, hawk, john.fastabend, bjorn,
	magnus.karlsson, jonathan.lemon, andrii, kafai, songliubraving,
	yhs, kpsingh, netdev, bpf, linux-kernel, Jiapeng Chong,
	Abaci Robot

Clean the following coccicheck warning:

./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for swap().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 samples/bpf/xdpsock_user.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index aa50864e4415..30065c703c77 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -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 *)&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 hex_dump(void *pkt, size_t length, u64 addr)
-- 
2.20.1.7.g153144c


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

* Re: [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it
  2022-01-13 16:22 [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it Jiapeng Chong
@ 2022-01-13 18:59 ` Song Liu
  2022-01-15  1:29 ` Andrii Nakryiko
  1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2022-01-13 18:59 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend, bjorn,
	Magnus Karlsson, Jonathan Lemon, Andrii Nakryiko, Martin Lau,
	Yonghong Song, KP Singh, Networking, bpf, linux-kernel,
	Abaci Robot



> On Jan 13, 2022, at 8:22 AM, Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
> 
> Clean the following coccicheck warning:
> 
> ./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for swap().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Acked-by: Song Liu <songliubraving@fb.com>


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

* Re: [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it
  2022-01-13 16:22 [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it Jiapeng Chong
  2022-01-13 18:59 ` Song Liu
@ 2022-01-15  1:29 ` Andrii Nakryiko
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-01-15  1:29 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, Jesper Dangaard Brouer, john fastabend,
	Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	Andrii Nakryiko, Martin Lau, Song Liu, Yonghong Song, KP Singh,
	Networking, bpf, open list, Abaci Robot

On Thu, Jan 13, 2022 at 8:22 AM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> Clean the following coccicheck warning:
>
> ./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for swap().
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  samples/bpf/xdpsock_user.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> index aa50864e4415..30065c703c77 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -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 *)&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);

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


>  }
>
>  static void hex_dump(void *pkt, size_t length, u64 addr)
> --
> 2.20.1.7.g153144c
>

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

end of thread, other threads:[~2022-01-15  1:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 16:22 [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it Jiapeng Chong
2022-01-13 18:59 ` Song Liu
2022-01-15  1:29 ` Andrii Nakryiko

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.