net: remove useless if check from register_netdevice()
Subsystems (2)
PATCH v2 1/1 net: remove useless if check from register_netdevice()
remove useless if check from register_netdevice()
---
v1 -> v2: Fixed identation
--- net/core/dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/dev.c +1 -2
@@ -5876,8 +5876,7 @@ int register_netdevice(struct net_device *dev)if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init (dev);if (ret) { -if (ret >0 ) - ret = -EIO ; + ret = -EIO ; goto out; } }
Signature · 1 line
1.8.0.2
Quoted 14 lines · Denis Kirjanov
remove useless if check from
register_netdevice()Signed-off-by Denis Kirjanov <[email protected]>---
v1 -> v2: Fixed identation--- net/core/dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/core/dev.c +0
-0
net/core/dev.c int register_netdevice(struct net_device *dev) · line 5880
Quoted 7 lines
net/core/dev.c +1
-2@@ -5876,8 +5876,7 @@ int register_netdevice(struct net_device *dev)if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init (dev);if (ret) { -if (ret >0 ) - ret = -EIO ; + ret = -EIO ; goto out;
why is it a useless check?
seems perfectly valid to me.
most of the time ndo_init() returns negative error code like -ENOMEM which we want
to propagate further down and want to override it to -EIO if it's > 0
All of the users of ndo_init return negative error code on error path. Only staging stuff tries to use positive codes like octeon ethernet which does request_irq inside ndo_open...
Quoted 30 lines · Alexei Starovoitov
Quoted 14 lines · Denis Kirjanov
remove useless if check from
register_netdevice()Signed-off-by Denis Kirjanov <[email protected]>---
v1 -> v2: Fixed identation--- net/core/dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/core/dev.c +0
-0net/core/dev.c int register_netdevice(struct net_device *dev) · line 5880
Quoted 7 lines
net/core/dev.c +1
-2@@ -5876,8 +5876,7 @@ int register_netdevice(struct net_device *dev)if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init (dev);if (ret) { -if (ret >0 ) - ret = -EIO ; + ret = -EIO ; goto out;why is it a useless check?
seems perfectly valid to me.
most of the timendo_init()returns negative error code like-ENOMEMwhich we want
to propagate further down and want to override it to-EIOif it's > 0
Quoted 4 lines · Denis Kirjanov
All of the users of
ndo_initreturn negative error code on error path. Only staging stuff tries to use positive codes like octeon ethernet which doesrequest_irqinsidendo_open...
You should put this explanation in the changelog.
David Miller
maintainerFrom: Denis Kirjanov <[email protected]>
Date: Thu, 13 Feb 2014 21:15:46 +0400
Quoted 3 lines
All of the users of
ndo_initreturn negative error code on error path. Only staging stuff tries to use positive codes like octeon ethernet which doesrequest_irqinsidendo_open...
Do not top-post, please.
Quote the necessary material of the person you are replying to, then provide your response underneath.
David Miller
maintainerFrom: Alexei Starovoitov <[email protected]>
Date: Thu, 13 Feb 2014 08:23:08 -0800
Quoted 20 lines · Denis Kirjanov
Quoted 19 lines
remove useless if check from
register_netdevice()Signed-off-by Denis Kirjanov <[email protected]>---
v1 -> v2: Fixed identation--- net/core/dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/core/dev.c +0
-2@@ -5876,8 +5876,7 @@ int register_netdevice(struct net_device *dev)if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init (dev);if (ret) { -if (ret >0 ) - ret = -EIO ;
Quoted 8 lines
net/core/dev.c int register_netdevice(struct net_device *dev) · line 5880
Quoted 2 lines
net/core/dev.c +1
-0+ ret = -EIO ; goto out;why is it a useless check?
seems perfectly valid to me.
most of the timendo_init()returns negative error code like-ENOMEMwhich we want
to propagate further down and want to override it to-EIOif it's > 0
Agreed, and if it is useless then unconditionally returining -EIO is absolutely the wrong thing to do. We should always use whatever negative error code ndo_init() gave us.
I'm not applying this patch.