Skip to contentSkip to conversation

net/udp_offload: Drop unnecessary continue

PATCH In review Himangi Saraogi 3 participants 3 messages Aug 13, 2014

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

PATCH 1/1 net/udp_offload: Drop unnecessary continue

Continue is not needed at the bottom of a loop.

The Coccinelle semantic patch implementing this change is:

@@
@@

for (...;...;...) {
...

  if (...) {
    ...

- continue;
}
}

---
 net/ipv4/udp_offload.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv4/udp_offload.c +1 -3
index 59035bc..62d5b9b 100644
@@ -269,10 +269,8 @@ unflush:
 			continue;
 
 		uh2 = (struct udphdr   *)(p->data + off);
-		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source)) {
+		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source))
 			NAPI_GRO_CB(p)->same_flow = 0;
-			continue;
-		}
 	}
 
 	skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 27 lines · Himangi Saraogi

Continue is not needed at the bottom of a loop.

The Coccinelle semantic patch implementing this change is:

@@
@@

for (...;...;...) {
...

  if (...) {
    ...

- continue;
}
}

---
 net/ipv4/udp_offload.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv4/udp_offload.c +0 -0
index 59035bc..62d5b9b 100644
@@ -269,10 +269,8 @@ unflush:
 			continue;

net/ipv4/udp_offload.c unflush: · line 276

Quoted 10 lines
net/ipv4/udp_offload.c +1 -3
 
 		uh2 = (struct udphdr   *)(p->data + off);
-		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source)) {
+		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source))
 			NAPI_GRO_CB(p)->same_flow = 0;
-			continue;
-		}
 	}
 
 	skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */

Please do not do that.

If we add another check later, we'll miss that the 'continue;' needs to be put back.

GRO stack is quite difficult to maintain, I prefer we keep this as is for consistency and code readability.

Every time we clear same_flow, we use the "continue;" construct.

 if (...) {
     NAPI_GRO_CB(p)->same_flow = 0;
     continue;

}

<here we can eventually add some other check>

Compiler generates the same code anyway.

#2 lore raw
Quoted 42 lines · Eric Dumazet
Quoted 27 lines · Himangi Saraogi

Continue is not needed at the bottom of a loop.

The Coccinelle semantic patch implementing this change is:

@@
@@

for (...;...;...) {
...

  if (...) {
    ...

- continue;
}
}

---
 net/ipv4/udp_offload.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv4/udp_offload.c +0 -0
index 59035bc..62d5b9b 100644
@@ -269,10 +269,8 @@ unflush:
 			continue;

net/ipv4/udp_offload.c unflush: · line 276

Quoted 10 lines
net/ipv4/udp_offload.c +1 -3
 
 		uh2 = (struct udphdr   *)(p->data + off);
-		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source)) {
+		if ((*(u32 *)&uh->source != *(u32 *)&uh2->source))
 			NAPI_GRO_CB(p)->same_flow = 0;
-			continue;
-		}
 	}
 
 	skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */

Please do not do that.

Quoted 5 lines

If we add another check later, we'll miss that the 'continue;' needs to be put back.

GRO stack is quite difficult to maintain, I prefer we keep this as is for consistency and code readability.

+1
this code as-is is definitely more readable