diff mbox series

net: ipv4: remove redundant initialization in inet_rtm_deladdr

Message ID 1604644960-48378-1-git-send-email-dong.menglong@zte.com.cn (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: ipv4: remove redundant initialization in inet_rtm_deladdr | expand

Commit Message

Menglong Dong Nov. 6, 2020, 6:42 a.m. UTC
From: Menglong Dong <dong.menglong@zte.com.cn>

The initialization for 'err' with '-EINVAL' is redundant and
can be removed, as it is updated soon.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
 net/ipv4/devinet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Nov. 7, 2020, 11:48 p.m. UTC | #1
On Fri,  6 Nov 2020 01:42:37 -0500 menglong8.dong@gmail.com wrote:
> From: Menglong Dong <dong.menglong@zte.com.cn>
> 
> The initialization for 'err' with '-EINVAL' is redundant and
> can be removed, as it is updated soon.
> 
> Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>

How many changes like this are there in the kernel right now?

I'm afraid that if there are too many it's not worth the effort.

Also - what tool do you use to find those, we need to make sure new
instances don't get into the tree.

> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 123a6d3..847cb18 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -651,7 +651,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
>  	struct ifaddrmsg *ifm;
>  	struct in_ifaddr *ifa;
>  

You can remove this empty line while at it.

> -	int err = -EINVAL;
> +	int err;
>  
>  	ASSERT_RTNL();
>
Menglong Dong Nov. 8, 2020, 12:42 a.m. UTC | #2
Dear Jakub,

On Sun, Nov 8, 2020 at 7:48 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri,  6 Nov 2020 01:42:37 -0500 menglong8.dong@gmail.com wrote:
> > From: Menglong Dong <dong.menglong@zte.com.cn>
> >
> > The initialization for 'err' with '-EINVAL' is redundant and
> > can be removed, as it is updated soon.
> >
> > Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
>
> How many changes like this are there in the kernel right now?
>
> I'm afraid that if there are too many it's not worth the effort.
>
> Also - what tool do you use to find those, we need to make sure new
> instances don't get into the tree.
>

I didn't use any tools. Maybe some general tools, such as kw,
coverity, coccicheck,
are able to find these changes(as far as I know, they can).

In fact, I find these changes by my eyes. I believe 'err' is the most
likely victim
and checked every usage of it in 'net' directory. Here are all the
changes I found,
and I think there won't be too many.

Cheers,
Menglong Dong
diff mbox series

Patch

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 123a6d3..847cb18 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -651,7 +651,7 @@  static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct ifaddrmsg *ifm;
 	struct in_ifaddr *ifa;
 
-	int err = -EINVAL;
+	int err;
 
 	ASSERT_RTNL();