Skip to contentSkip to conversation

sctp: remove the never used 'return' and, redundant 'break'

PATCH Superseded Wang Weidong 4 participants 7 messages Dec 18, 2013 – Dec 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index 2a192a7..c956dc9 100644
@@ -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
#1 lore raw
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.

---
 net/sctp/input.c | 5 -----
 1 file changed, 5 deletions(-)
net/sctp/input.c +0 -1
index 2a192a7..c956dc9 100644
@@ -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 -4
 	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

#2 lore raw
In reply to Wang Weidong
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.

---
 net/sctp/input.c | 5 -----
 1 file changed, 5 deletions(-)
net/sctp/input.c +0 -5
index 2a192a7..c956dc9 100644
@@ -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

#3 lore raw

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.

---
  net/sctp/input.c | 5 -----
  1 file changed, 5 deletions(-)
net/sctp/input.c +0 -6
index 2a192a7..c956dc9 100644
@@ -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

#4 lore raw

PATCH v2 1/1 sctp: remove the never used 'return' and redundant 'break'

In reply to 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.

---
 net/sctp/input.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
net/sctp/input.c +2 -11
index 042ec6c..476bc8d 100644
@@ -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
Acked-by on v2 1/1
#5 lore raw

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.

---
 net/sctp/input.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
net/sctp/input.c +2 -11
index 042ec6c..476bc8d 100644
@@ -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
maintainer Applied
#6 lore raw

Re: [PATCH net-next v2] sctp: remove the never used 'return' and redundant 'break'

In reply to Wang Weidong

From: 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.

Applied, thanks.