diff mbox

[net-next] net: remove useless if check from register_netdevice()

Message ID 1392191152-24182-1-git-send-email-kda@linux-powerpc.org
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Denis Kirjanov Feb. 12, 2014, 7:45 a.m. UTC
remove useless if check from register_netdevice()

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Ding Tianhong Feb. 12, 2014, 8:20 a.m. UTC | #1
On 2014/2/12 15:45, Denis Kirjanov wrote:
> remove useless if check from register_netdevice()
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
>  net/core/dev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4ad1b78..4be9a37 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -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;

pls use checkpatch.pl to check the code.

Ding

>  			goto out;
>  		}
>  	}
> 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ding Tianhong Feb. 12, 2014, 8:24 a.m. UTC | #2
On 2014/2/12 15:45, Denis Kirjanov wrote:
> remove useless if check from register_netdevice()
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
>  net/core/dev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4ad1b78..4be9a37 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -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;

and:
some ndo_init() will return -ENOMEM, not only -EIO


>  			goto out;
>  		}
>  	}
> 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Denis Kirjanov Feb. 12, 2014, 8:47 a.m. UTC | #3
On 2/12/14, Ding Tianhong <dingtianhong@huawei.com> wrote:
> On 2014/2/12 15:45, Denis Kirjanov wrote:
>> remove useless if check from register_netdevice()
>>
>> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>> ---
>>  net/core/dev.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 4ad1b78..4be9a37 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -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;
>
> and:
> some ndo_init() will return -ENOMEM, not only -EIO
>
>
>>  			goto out;
>>  		}
>>  	}
>>

Yes, I was thinking about that. The return code may contain everything.
Probably it's better to propagate return value back to
register_netdevice. On the other hand the return value -ENOTSUPP for
register_netdevice return value looks odd...

>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Feb. 12, 2014, 2:46 p.m. UTC | #4
From: Denis Kirjanov <kda@linux-powerpc.org>
Date: Wed, 12 Feb 2014 11:45:52 +0400

> @@ -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;
>  		}

Like your other patch you are not formatting this code properly at all.

If you cannot insert the correct TAB and space characters necessary
to indent the code properly, have something help you do it, such as
emacs's C-mode in "linux" mode.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Denis Kirjanov Feb. 12, 2014, 2:51 p.m. UTC | #5
On 2/12/14, David Miller <davem@davemloft.net> wrote:
> From: Denis Kirjanov <kda@linux-powerpc.org>
> Date: Wed, 12 Feb 2014 11:45:52 +0400
>
>> @@ -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;
>>  		}
>
> Like your other patch you are not formatting this code properly at all.
>

I'll resubmit both. Thank you.

> If you cannot insert the correct TAB and space characters necessary
> to indent the code properly, have something help you do it, such as
> emacs's C-mode in "linux" mode.
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 4ad1b78..4be9a37 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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;
 		}
 	}