2021-12-09 01:55:19

by CGEL

[permalink] [raw]
Subject: [PATCH] samples:bpf:remove unneeded variable

From: chiminghao <[email protected]>

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

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: chiminghao <[email protected]>
---
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



2021-12-09 07:13:32

by Andrii Nakryiko

[permalink] [raw]
Subject: Re: [PATCH] samples:bpf:remove unneeded variable

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.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: chiminghao <[email protected]>

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.

> ---
> 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
>

2021-12-09 08:01:21

by CGEL

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

From: Minghao Chi <[email protected]>

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

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Minghao Chi <[email protected]>
---
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


2021-12-09 17:27:46

by Andrii Nakryiko

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

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.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Minghao Chi <[email protected]>
> ---

Applied to bpf-next, thanks.

> 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
>

2021-12-09 17:30:13

by patchwork-bot+netdevbpf

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

Hello:

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

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.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Minghao Chi <[email protected]>
>
> [...]

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