* [PATCH] samples/bpf: fix swap.cocci warning
@ 2021-12-08 11:34 Yihao Han
2021-12-09 7:10 ` Andrii Nakryiko
0 siblings, 1 reply; 2+ messages in thread
From: Yihao Han @ 2021-12-08 11:34 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/xsk_fwd.c:660:22-23:
WARNING opportunity for swap()
Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
samples/bpf/xsk_fwd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/samples/bpf/xsk_fwd.c b/samples/bpf/xsk_fwd.c
index 1cd97c84c337..e82582b225d3 100644
--- a/samples/bpf/xsk_fwd.c
+++ b/samples/bpf/xsk_fwd.c
@@ -653,9 +653,7 @@ static void swap_mac_addresses(void *data)
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 *
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] samples/bpf: fix swap.cocci warning
2021-12-08 11:34 [PATCH] samples/bpf: fix swap.cocci warning Yihao Han
@ 2021-12-09 7:10 ` Andrii Nakryiko
0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2021-12-09 7:10 UTC (permalink / raw)
To: Yihao Han
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Networking, bpf, open list, kernel
On Wed, Dec 8, 2021 at 3:34 AM Yihao Han <hanyihao@vivo.com> wrote:
>
> Fix following swap.cocci warning:
> ./samples/bpf/xsk_fwd.c:660:22-23:
> WARNING opportunity for swap()
>
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
> samples/bpf/xsk_fwd.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/samples/bpf/xsk_fwd.c b/samples/bpf/xsk_fwd.c
> index 1cd97c84c337..e82582b225d3 100644
> --- a/samples/bpf/xsk_fwd.c
> +++ b/samples/bpf/xsk_fwd.c
> @@ -653,9 +653,7 @@ static void swap_mac_addresses(void *data)
> struct ether_addr *dst_addr = (struct ether_addr *)ð->ether_dhost;
> struct ether_addr tmp;
this variable needs to be removed as well then
>
> - tmp = *src_addr;
> - *src_addr = *dst_addr;
> - *dst_addr = tmp;
> + swap(*src_addr, *dst_addr);
> }
>
> static void *
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-09 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 11:34 [PATCH] samples/bpf: fix swap.cocci warning Yihao Han
2021-12-09 7:10 ` Andrii Nakryiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®