netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break'
@ 2013-12-18  9:20 Wang Weidong
  2013-12-18  9:38 ` Wang Weidong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-18  9:20 UTC (permalink / raw)
  To: David Miller, Vlad Yasevich, Neil Horman; +Cc: netdev, linux-sctp

In switch() had do return, and never use the 'return NULL'. The
'break' after return or goto has no effect. Remove it.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/input.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/sctp/input.c b/net/sctp/input.c
index 2a192a7..c956dc9 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -1120,15 +1120,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
 	case SCTP_CID_INIT:
 	case SCTP_CID_INIT_ACK:
 		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
-		break;
 
 	default:
 		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
-		break;
 	}
-
-
-	return NULL;
 }
 
 /* Lookup an association for an inbound skb. */
-- 
1.7.12

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

* Re: [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break'
  2013-12-18  9:20 [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break' Wang Weidong
@ 2013-12-18  9:38 ` Wang Weidong
  2013-12-18 14:06 ` Neil Horman
  2013-12-19  2:02 ` [PATCH net-next v2] sctp: remove the never used 'return' and " Wang Weidong
  2 siblings, 0 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-18  9:38 UTC (permalink / raw)
  To: David Miller, Vlad Yasevich, Neil Horman; +Cc: netdev, linux-sctp

On 2013/12/18 17:20, Wang Weidong wrote:
> In switch() had do return, and never use the 'return NULL'. The
> 'break' after return or goto has no effect. Remove it.
> 
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> ---
>  net/sctp/input.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 2a192a7..c956dc9 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -1120,15 +1120,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
>  	case SCTP_CID_INIT:
>  	case SCTP_CID_INIT_ACK:
>  		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
> -		break;
>  
>  	default:
>  		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
> -		break;
>  	}
> -
> -
> -	return NULL;
>  }
>  
>  /* Lookup an association for an inbound skb. */
> 

Sorry for sending the Subject "[PATCH net-next 2/3] ...".
It is only one patch, not series.

Regards.
Wang

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

* Re: [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break'
  2013-12-18  9:20 [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break' Wang Weidong
  2013-12-18  9:38 ` Wang Weidong
@ 2013-12-18 14:06 ` Neil Horman
  2013-12-18 14:33   ` Wang Weidong
  2013-12-19  2:02 ` [PATCH net-next v2] sctp: remove the never used 'return' and " Wang Weidong
  2 siblings, 1 reply; 7+ messages in thread
From: Neil Horman @ 2013-12-18 14:06 UTC (permalink / raw)
  To: Wang Weidong; +Cc: David Miller, Vlad Yasevich, netdev, linux-sctp

On Wed, Dec 18, 2013 at 05:20:32PM +0800, Wang Weidong wrote:
> In switch() had do return, and never use the 'return NULL'. The
> 'break' after return or goto has no effect. Remove it.
> 
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> ---
>  net/sctp/input.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 2a192a7..c956dc9 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -1120,15 +1120,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
>  	case SCTP_CID_INIT:
>  	case SCTP_CID_INIT_ACK:
>  		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
> -		break;
>  
>  	default:
>  		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
> -		break;
>  	}
> -
> -
> -	return NULL;
>  }
>  
>  /* Lookup an association for an inbound skb. */
> -- 
> 1.7.12
> 
> 
> 

If you're going to do this, it seems like you may just as well convert the
switch to be if (ch->type && ch->type <= SCTP_CID_INIT_ACK) {...} else {...}


That seems like it would be more readable to me.

Neil

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

* Re: [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break'
  2013-12-18 14:06 ` Neil Horman
@ 2013-12-18 14:33   ` Wang Weidong
  0 siblings, 0 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-18 14:33 UTC (permalink / raw)
  To: Neil Horman, Wang Weidong; +Cc: David Miller, Vlad Yasevich, netdev, linux-sctp

From: Wang Weidong <wangweidong1@huawei.com>

On 2013/12/18 22:06, Neil Horman wrote:
> On Wed, Dec 18, 2013 at 05:20:32PM +0800, Wang Weidong wrote:
>> In switch() had do return, and never use the 'return NULL'. The
>> 'break' after return or goto has no effect. Remove it.
>>
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> ---
>>   net/sctp/input.c | 5 -----
>>   1 file changed, 5 deletions(-)
>>
>> diff --git a/net/sctp/input.c b/net/sctp/input.c
>> index 2a192a7..c956dc9 100644
>> --- a/net/sctp/input.c
>> +++ b/net/sctp/input.c
>> @@ -1120,15 +1120,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
>>   	case SCTP_CID_INIT:
>>   	case SCTP_CID_INIT_ACK:
>>   		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
>> -		break;
>>
>>   	default:
>>   		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
>> -		break;
>>   	}
>> -
>> -
>> -	return NULL;
>>   }
>>
>>   /* Lookup an association for an inbound skb. */
>> --
>> 1.7.12
>>
>>
>>
>
> If you're going to do this, it seems like you may just as well convert the
> switch to be if (ch->type && ch->type <= SCTP_CID_INIT_ACK) {...} else {...}
>
>
> That seems like it would be more readable to me.
>
> Neil
>
Hm, I will fix it.

Thanks.

> --
> 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
>

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

* [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'
  2013-12-18  9:20 [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break' Wang Weidong
  2013-12-18  9:38 ` Wang Weidong
  2013-12-18 14:06 ` Neil Horman
@ 2013-12-19  2:02 ` Wang Weidong
  2013-12-19 12:12   ` Neil Horman
  2013-12-22 23:57   ` David Miller
  2 siblings, 2 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-19  2:02 UTC (permalink / raw)
  To: David Miller, Vlad Yasevich, Neil Horman; +Cc: netdev, linux-sctp

In switch() had do return, and never use the 'return NULL'. The
'break' after return or goto has no effect. Remove it.

v2: make it more readable as suggested by Neil.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/input.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/net/sctp/input.c b/net/sctp/input.c
index 042ec6c..476bc8d 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -1119,19 +1119,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
 		return NULL;
 
 	/* If this is INIT/INIT-ACK look inside the chunk too. */
-	switch (ch->type) {
-	case SCTP_CID_INIT:
-	case SCTP_CID_INIT_ACK:
+	if (ch->type == SCTP_CID_INIT || ch->type == SCTP_CID_INIT_ACK)
 		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
-		break;
 
-	default:
-		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
-		break;
-	}
-
-
-	return NULL;
+	return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
 }
 
 /* Lookup an association for an inbound skb. */
-- 
1.7.12

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

* Re: [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'
  2013-12-19  2:02 ` [PATCH net-next v2] sctp: remove the never used 'return' and " Wang Weidong
@ 2013-12-19 12:12   ` Neil Horman
  2013-12-22 23:57   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: Neil Horman @ 2013-12-19 12:12 UTC (permalink / raw)
  To: Wang Weidong; +Cc: David Miller, Vlad Yasevich, netdev, linux-sctp

On Thu, Dec 19, 2013 at 10:02:42AM +0800, Wang Weidong wrote:
> In switch() had do return, and never use the 'return NULL'. The
> 'break' after return or goto has no effect. Remove it.
> 
> v2: make it more readable as suggested by Neil.
> 
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> ---
>  net/sctp/input.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/net/sctp/input.c b/net/sctp/input.c
> index 042ec6c..476bc8d 100644
> --- a/net/sctp/input.c
> +++ b/net/sctp/input.c
> @@ -1119,19 +1119,10 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
>  		return NULL;
>  
>  	/* If this is INIT/INIT-ACK look inside the chunk too. */
> -	switch (ch->type) {
> -	case SCTP_CID_INIT:
> -	case SCTP_CID_INIT_ACK:
> +	if (ch->type == SCTP_CID_INIT || ch->type == SCTP_CID_INIT_ACK)
>  		return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
> -		break;
>  
> -	default:
> -		return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
> -		break;
> -	}
> -
> -
> -	return NULL;
> +	return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
>  }
>  
>  /* Lookup an association for an inbound skb. */
> -- 
> 1.7.12
> 
> 
> 
> 

Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'
  2013-12-19  2:02 ` [PATCH net-next v2] sctp: remove the never used 'return' and " Wang Weidong
  2013-12-19 12:12   ` Neil Horman
@ 2013-12-22 23:57   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-12-22 23:57 UTC (permalink / raw)
  To: wangweidong1; +Cc: vyasevich, nhorman, netdev, linux-sctp

From: Wang Weidong <wangweidong1@huawei.com>
Date: Thu, 19 Dec 2013 10:02:42 +0800

> In switch() had do return, and never use the 'return NULL'. The
> 'break' after return or goto has no effect. Remove it.
> 
> v2: make it more readable as suggested by Neil.
> 
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>

Applied, thanks.

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

end of thread, other threads:[~2013-12-22 23:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18  9:20 [PATCH net-next 2/3] sctp: remove the never used 'return' and, redundant 'break' Wang Weidong
2013-12-18  9:38 ` Wang Weidong
2013-12-18 14:06 ` Neil Horman
2013-12-18 14:33   ` Wang Weidong
2013-12-19  2:02 ` [PATCH net-next v2] sctp: remove the never used 'return' and " Wang Weidong
2013-12-19 12:12   ` Neil Horman
2013-12-22 23:57   ` David Miller

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).