netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/udp_offload: Drop unnecessary continue
@ 2014-08-13  9:16 Himangi Saraogi
  2014-08-13 14:48 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Himangi Saraogi @ 2014-08-13  9:16 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel
  Cc: Julia Lawall

Continue is not needed at the bottom of a loop.

The Coccinelle semantic patch implementing this change is:

@@
@@

for (...;...;...) {
  ...
  if (...) {
    ...
-   continue;
  }
}

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 net/ipv4/udp_offload.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 59035bc..62d5b9b 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -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 */
-- 
1.9.1

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

* Re: [PATCH] net/udp_offload: Drop unnecessary continue
  2014-08-13  9:16 [PATCH] net/udp_offload: Drop unnecessary continue Himangi Saraogi
@ 2014-08-13 14:48 ` Eric Dumazet
  2014-08-13 17:06   ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2014-08-13 14:48 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel,
	Julia Lawall

On Wed, 2014-08-13 at 14:46 +0530, Himangi Saraogi wrote:
> Continue is not needed at the bottom of a loop.
> 
> The Coccinelle semantic patch implementing this change is:
> 
> @@
> @@
> 
> for (...;...;...) {
>   ...
>   if (...) {
>     ...
> -   continue;
>   }
> }
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
>  net/ipv4/udp_offload.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index 59035bc..62d5b9b 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -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 */


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.

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

* Re: [PATCH] net/udp_offload: Drop unnecessary continue
  2014-08-13 14:48 ` Eric Dumazet
@ 2014-08-13 17:06   ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2014-08-13 17:06 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Himangi Saraogi, David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel,
	Julia Lawall

On Wed, Aug 13, 2014 at 07:48:11AM -0700, Eric Dumazet wrote:
> On Wed, 2014-08-13 at 14:46 +0530, Himangi Saraogi wrote:
> > Continue is not needed at the bottom of a loop.
> > 
> > The Coccinelle semantic patch implementing this change is:
> > 
> > @@
> > @@
> > 
> > for (...;...;...) {
> >   ...
> >   if (...) {
> >     ...
> > -   continue;
> >   }
> > }
> > 
> > Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> > ---
> >  net/ipv4/udp_offload.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> > index 59035bc..62d5b9b 100644
> > --- a/net/ipv4/udp_offload.c
> > +++ b/net/ipv4/udp_offload.c
> > @@ -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 */
> 
> 
> 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.

+1
this code as-is is definitely more readable

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

end of thread, other threads:[~2014-08-13 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-13  9:16 [PATCH] net/udp_offload: Drop unnecessary continue Himangi Saraogi
2014-08-13 14:48 ` Eric Dumazet
2014-08-13 17:06   ` Alexei Starovoitov

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