diff mbox series

net: macvlan: remove redundant initialization in macvlan_dev_netpoll_setup

Message ID 1604490791-53825-1-git-send-email-dong.menglong@zte.com.cn
State Superseded
Headers show
Series net: macvlan: remove redundant initialization in macvlan_dev_netpoll_setup | expand

Commit Message

Menglong Dong Nov. 4, 2020, 11:53 a.m. UTC
From: Menglong Dong <dong.menglong@zte.com.cn>

The initialization for err with 0 seems useless, as it is soon updated
with -ENOMEM. So, we can init err with -ENOMEM.

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

Comments

Jakub Kicinski Nov. 4, 2020, 9:35 p.m. UTC | #1
On Wed,  4 Nov 2020 06:53:11 -0500 menglong8.dong@gmail.com wrote:
> From: Menglong Dong <dong.menglong@zte.com.cn>

> 

> The initialization for err with 0 seems useless, as it is soon updated

> with -ENOMEM. So, we can init err with -ENOMEM.

> 

> Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>

> ---

>  drivers/net/macvlan.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)

> 

> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c

> index dd96020..a568b39 100644

> --- a/drivers/net/macvlan.c

> +++ b/drivers/net/macvlan.c

> @@ -1096,10 +1096,9 @@ static int macvlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info

>  	struct macvlan_dev *vlan = netdev_priv(dev);

>  	struct net_device *real_dev = vlan->lowerdev;

>  	struct netpoll *netpoll;

> -	int err = 0;


Removing the ' = 0' would be better, let's keep the assignment of
-ENOMEM close to where it matters.

> +	int err = -ENOMEM;

>  

>  	netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);

> -	err = -ENOMEM;

>  	if (!netpoll)

>  		goto out;

>
diff mbox series

Patch

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index dd96020..a568b39 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1096,10 +1096,9 @@  static int macvlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info
 	struct macvlan_dev *vlan = netdev_priv(dev);
 	struct net_device *real_dev = vlan->lowerdev;
 	struct netpoll *netpoll;
-	int err = 0;
+	int err = -ENOMEM;
 
 	netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
-	err = -ENOMEM;
 	if (!netpoll)
 		goto out;