[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211112032704.4658-1-hanyihao@vivo.com>
Date: Thu, 11 Nov 2021 19:27:04 -0800
From: Yihao Han <hanyihao@...o.com>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Shuah Khan <shuah@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: kernel@...o.com, Yihao Han <hanyihao@...o.com>
Subject: [PATCH] selftests/bpf: use swap() to make code cleaner
Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.
Signed-off-by: Yihao Han <hanyihao@...o.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
Powered by blists - more mailing lists