netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: bpf_struct_ops: Remove unnecessary ‘0’ values from err
@ 2023-08-02  1:23 Li kunyu
  2023-08-03  0:51 ` Martin KaFai Lau
  0 siblings, 1 reply; 2+ messages in thread
From: Li kunyu @ 2023-08-02  1:23 UTC (permalink / raw)
  To: martin.lau, ast, daniel, andrii, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa
  Cc: bpf, netdev, linux-kernel, Li kunyu

err is assigned first, so it does not need to initialize the assignment.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/bpf/bpf_struct_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index d3f0a4825fa6..5b591fda5d62 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -376,7 +376,7 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
 	const struct btf_type *t = st_ops->type;
 	struct bpf_tramp_links *tlinks = NULL;
 	void *udata, *kdata;
-	int prog_fd, err = 0;
+	int prog_fd, err;
 	void *image, *image_end;
 	u32 i;
 
@@ -818,7 +818,7 @@ static int bpf_struct_ops_map_link_update(struct bpf_link *link, struct bpf_map
 	struct bpf_struct_ops_map *st_map, *old_st_map;
 	struct bpf_map *old_map;
 	struct bpf_struct_ops_link *st_link;
-	int err = 0;
+	int err;
 
 	st_link = container_of(link, struct bpf_struct_ops_link, link);
 	st_map = container_of(new_map, struct bpf_struct_ops_map, map);
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bpf: bpf_struct_ops: Remove unnecessary ‘0’ values from err
  2023-08-02  1:23 [PATCH] bpf: bpf_struct_ops: Remove unnecessary ‘0’ values from err Li kunyu
@ 2023-08-03  0:51 ` Martin KaFai Lau
  0 siblings, 0 replies; 2+ messages in thread
From: Martin KaFai Lau @ 2023-08-03  0:51 UTC (permalink / raw)
  To: Li kunyu
  Cc: bpf, netdev, linux-kernel, ast, daniel, andrii, song, yhs,
	john.fastabend, kpsingh, sdf, haoluo, jolsa

On 8/1/23 6:23 PM, Li kunyu wrote:
> err is assigned first, so it does not need to initialize the assignment.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>   kernel/bpf/bpf_struct_ops.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
> index d3f0a4825fa6..5b591fda5d62 100644
> --- a/kernel/bpf/bpf_struct_ops.c
> +++ b/kernel/bpf/bpf_struct_ops.c
> @@ -376,7 +376,7 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
>   	const struct btf_type *t = st_ops->type;
>   	struct bpf_tramp_links *tlinks = NULL;
>   	void *udata, *kdata;
> -	int prog_fd, err = 0;
> +	int prog_fd, err;

The "tlinks" init in two lines above is also not needed. While at the same 
function, please take this chance to remove it together.

Please tag the subject with "bpf-next v2" in the next respin.

>   	void *image, *image_end;
>   	u32 i;
>   
> @@ -818,7 +818,7 @@ static int bpf_struct_ops_map_link_update(struct bpf_link *link, struct bpf_map
>   	struct bpf_struct_ops_map *st_map, *old_st_map;
>   	struct bpf_map *old_map;
>   	struct bpf_struct_ops_link *st_link;
> -	int err = 0;
> +	int err;
>   
>   	st_link = container_of(link, struct bpf_struct_ops_link, link);
>   	st_map = container_of(new_map, struct bpf_struct_ops_map, map);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-03  0:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02  1:23 [PATCH] bpf: bpf_struct_ops: Remove unnecessary ‘0’ values from err Li kunyu
2023-08-03  0:51 ` Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).