From: Minghao Chi <chi.minghao@zte.com.cn>
Date: Thu, 9 Dec 2021 08:00:51 +0000
Subject: samples/bpf: Remove unneeded variable
Patch-mainline: v5.17-rc1
Git-commit: ac55b3f00c323cf09d59a191e14bcf39b691078c
References: jsc#PED-1377
Return value directly instead of taking this in another redundant variable.
Reported-by: Zeal Robot <zealci@zte.com.cm>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211209080051.421844-1-chi.minghao@zte.com.cn
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
--- a/samples/bpf/xdp_redirect_cpu.bpf.c
+++ b/samples/bpf/xdp_redirect_cpu.bpf.c
@@ -100,7 +100,6 @@ u16 get_dest_port_ipv4_udp(struct xdp_md
void *data = (void *)(long)ctx->data;
struct iphdr *iph = data + nh_off;
struct udphdr *udph;
- u16 dport;
if (iph + 1 > data_end)
return 0;
@@ -111,8 +110,7 @@ u16 get_dest_port_ipv4_udp(struct xdp_md
if (udph + 1 > data_end)
return 0;
- dport = bpf_ntohs(udph->dest);
- return dport;
+ return bpf_ntohs(udph->dest);
}
static __always_inline