Skip to contentSkip to conversation

samples:bpf:remove unneeded variable

PATCH Superseded [email protected] 3 participants 5 messages Dec 9, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samples:bpf:remove unneeded variable

From: chiminghao <[email protected]>

return value form directly instead of
taking this in another redundant variable.

---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
samples/bpf/xdp_redirect_cpu.bpf.c +1 -3
index f10fe3cf25f6..25e3a405375f 100644
@@ -100,7 +100,6 @@ u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off)
 	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 *ctx, u64 nh_off)
 	if (udph + 1 > data_end)
 		return 0;
 
-	dport = bpf_ntohs(udph->dest);
-	return dport;
+	return bpf_ntohs(udph->dest);
 }
 
 static __always_inline
Signature · 1 line
2.25.1
#1 lore raw
Quoted 8 lines · On Wed, Dec 8, 2021 at 5:55 PM <[email protected]> wrote:

From: chiminghao <[email protected]>

return value form directly instead of
taking this in another redundant variable.

Signed-off-by should contain properly capitalized full name, please update.

Also please use "samples/bpf: " patch prefix and use [PATCH bpf-next] to designate the destination kernel tree. Thanks.

Quoted 29 lines
---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
samples/bpf/xdp_redirect_cpu.bpf.c +1 -4
index f10fe3cf25f6..25e3a405375f 100644
@@ -100,7 +100,6 @@ u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off)
        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 *ctx, u64 nh_off)
        if (udph + 1 > data_end)
                return 0;
 
-       dport = bpf_ntohs(udph->dest);
-       return dport;
+       return bpf_ntohs(udph->dest);
 }
 
 static __always_inline
--

2.25.1

#2 lore raw

PATCH v2 1/1 samples/bpf:remove unneeded variable

From: Minghao Chi <[email protected]>

return value form directly instead of
taking this in another redundant variable.

---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
samples/bpf/xdp_redirect_cpu.bpf.c +1 -3
index f10fe3cf25f6..25e3a405375f 100644
@@ -100,7 +100,6 @@ u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off)
 	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 *ctx, u64 nh_off)
 	if (udph + 1 > data_end)
 		return 0;
 
-	dport = bpf_ntohs(udph->dest);
-	return dport;
+	return bpf_ntohs(udph->dest);
 }
 
 static __always_inline
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCHv2 bpf-next] samples/bpf:remove unneeded variable

Quoted 9 lines · On Thu, Dec 9, 2021 at 12:01 AM <[email protected]> wrote:

From: Minghao Chi <[email protected]>

return value form directly instead of
taking this in another redundant variable.

---

Applied to bpf-next, thanks.

Quoted 28 lines
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
samples/bpf/xdp_redirect_cpu.bpf.c +1 -4
index f10fe3cf25f6..25e3a405375f 100644
@@ -100,7 +100,6 @@ u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off)
        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 *ctx, u64 nh_off)
        if (udph + 1 > data_end)
                return 0;
 
-       dport = bpf_ntohs(udph->dest);
-       return dport;
+       return bpf_ntohs(udph->dest);
 }
 
 static __always_inline
--

2.25.1

#4 lore raw

Re: [PATCHv2 bpf-next] samples/bpf:remove unneeded variable

In reply to [email protected]
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 9 lines · On Thu, 9 Dec 2021 08:00:51 +0000 you wrote:

From: Minghao Chi <[email protected]>

return value form directly instead of
taking this in another redundant variable.

[...]

Here is the summary with links:
- [PATCHv2,bpf-next] samples/bpf:remove unneeded variable

    https://git.kernel.org/bpf/bpf-next/c/ac55b3f00c32

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html