linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: use swap() to make code cleaner
@ 2021-11-12  3:27 Yihao Han
  2021-11-12  5:06 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Yihao Han @ 2021-11-12  3:27 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
	Shuah Khan, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, KP Singh, netdev, bpf, linux-kselftest,
	linux-kernel
  Cc: kernel, Yihao Han

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 tools/testing/selftests/bpf/progs/test_xdp_noinline.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c
index 596c4e71bf3a..6d9972168a7c 100644
--- a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c
+++ b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c
@@ -428,7 +428,6 @@ int send_icmp_reply(void *data, void *data_end)
 {
 	struct icmphdr *icmp_hdr;
 	__u16 *next_iph_u16;
-	__u32 tmp_addr = 0;
 	struct iphdr *iph;
 	__u32 csum1 = 0;
 	__u32 csum = 0;
@@ -444,9 +443,7 @@ int send_icmp_reply(void *data, void *data_end)
 	icmp_hdr->type = 0;
 	icmp_hdr->checksum += 0x0007;
 	iph->ttl = 4;
-	tmp_addr = iph->daddr;
-	iph->daddr = iph->saddr;
-	iph->saddr = tmp_addr;
+	swap(iph->daddr, iph->saddr);
 	iph->check = 0;
 	next_iph_u16 = (__u16 *) iph;
 #pragma clang loop unroll(full)
-- 
2.17.1


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

end of thread, other threads:[~2021-11-12  5:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12  3:27 [PATCH] selftests/bpf: use swap() to make code cleaner Yihao Han
2021-11-12  5:06 ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).