sctp: remove the never used 'return' and, redundant 'break'
Subsystems (3)
PATCH 2/3 sctp: remove the never used 'return' and, redundant 'break'
In switch() had do return, and never use the 'return NULL'. The 'break' after return or goto has no effect. Remove it.
--- net/sctp/input.c | 5 ----- 1 file changed, 5 deletions(-)
net/sctp/input.c +0 -5
@@ -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. */
Signature · 1 line
1.7.12
Quoted 19 lines · Wang Weidong
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 <[email protected]>--- net/sctp/input.c | 5 ----- 1 file changed, 5 deletions(-)net/sctp/input.c +0
-1@@ -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 ;
net/sctp/input.c static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net, · line 1129
Quoted 10 lines
net/sctp/input.c +0
-4default :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
Quoted 33 lines · Wang Weidong
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 <[email protected]>--- net/sctp/input.c | 5 ----- 1 file changed, 5 deletions(-)net/sctp/input.c +0
-5@@ -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. */ Signature · 1 line
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
From: Wang Weidong <[email protected]>
Quoted 39 lines · Neil Horman
Quoted 29 lines · Wang Weidong
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 <[email protected]>--- net/sctp/input.c | 5 ----- 1 file changed, 5 deletions(-)net/sctp/input.c +0
-6@@ -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. */ --Quoted 4 lines
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 {...}
Quoted 4 lines
That seems like it would be more readable to me.
Neil
Hm, I will fix it.
Thanks.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 sctp: remove the never used 'return' and redundant 'break'
In reply to Wang WeidongIn 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.
--- net/sctp/input.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
net/sctp/input.c +2 -11
@@ -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. */
Signature · 1 line
1.7.12
Re: [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'
Quoted 42 lines · Wang Weidong
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 <[email protected]>--- net/sctp/input.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)net/sctp/input.c +2
-11@@ -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. */ Signature · 1 line
1.7.12
Re: [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'
In reply to Wang WeidongFrom: Wang Weidong <[email protected]>
Date: Thu, 19 Dec 2013 10:02:42 +0800
Quoted 6 lines
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 <[email protected]>
Applied, thanks.