[PATCH] samples:bpf:remove unneeded variable

Subsystems: bpf [general] (safe dynamic programs and tools), the rest, xdp (express data path)

STALE1764d

5 messages, 3 authors, 2021-12-09 · open the first message on its own page

[PATCH] samples:bpf:remove unneeded variable

From: <hidden>
Date: 2021-12-09 01:55:19

From: chiminghao <redacted>

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

Reported-by: Zeal Robot <redacted>
Signed-off-by: chiminghao <redacted>
---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/samples/bpf/xdp_redirect_cpu.bpf.c b/samples/bpf/xdp_redirect_cpu.bpf.c
index f10fe3cf25f6..25e3a405375f 100644
--- 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 *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

Re: [PATCH] samples:bpf:remove unneeded variable

From: Andrii Nakryiko <hidden>
Date: 2021-12-09 07:13:32

On Wed, Dec 8, 2021 at 5:55 PM [off-list ref] wrote:
From: chiminghao <redacted>

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

Reported-by: Zeal Robot <redacted>
Signed-off-by: chiminghao <redacted>
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 hunk
---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/samples/bpf/xdp_redirect_cpu.bpf.c b/samples/bpf/xdp_redirect_cpu.bpf.c
index f10fe3cf25f6..25e3a405375f 100644
--- 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 *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

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

From: <hidden>
Date: 2021-12-09 08:01:21

From: Minghao Chi <redacted>

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

Reported-by: Zeal Robot <redacted>
Signed-off-by: Minghao Chi <redacted>
---
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/samples/bpf/xdp_redirect_cpu.bpf.c b/samples/bpf/xdp_redirect_cpu.bpf.c
index f10fe3cf25f6..25e3a405375f 100644
--- 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 *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

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

From: Andrii Nakryiko <hidden>
Date: 2021-12-09 17:27:46

On Thu, Dec 9, 2021 at 12:01 AM [off-list ref] wrote:
From: Minghao Chi <redacted>

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

Reported-by: Zeal Robot <redacted>
Signed-off-by: Minghao Chi <redacted>
---
Applied to bpf-next, thanks.
quoted hunk
 samples/bpf/xdp_redirect_cpu.bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/samples/bpf/xdp_redirect_cpu.bpf.c b/samples/bpf/xdp_redirect_cpu.bpf.c
index f10fe3cf25f6..25e3a405375f 100644
--- 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 *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

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

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-12-09 17:30:13

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko [off-list ref]:

On Thu,  9 Dec 2021 08:00:51 +0000 you wrote:
From: Minghao Chi <redacted>

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

Reported-by: Zeal Robot <redacted>
Signed-off-by: Minghao Chi <redacted>

[...]
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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help