Thread (2 messages) 2 messages, 2 authors, 2021-12-09

[PATCH] samples/bpf: fix swap.cocci warning

flat view
STALE1767d

From: Yihao Han <hidden>
Date: 2021-12-08 11:34:29
Also in: bpf, lkml
Subsystem: bpf [general] (safe dynamic programs and tools), the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Linus Torvalds

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

Signed-off-by: Yihao Han <redacted>
---
 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 *)&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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help