All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]  ipv6: xfrm6: fix dubious code
@ 2011-05-23  8:42 Eric Dumazet
  2011-05-23 15:36 ` Ben Hutchings
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2011-05-23  8:42 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

net/ipv6/xfrm6_tunnel.c: In function ‘xfrm6_tunnel_rcv’:
net/ipv6/xfrm6_tunnel.c:244:53: warning: the omitted middle operand
in ?: will always be ‘true’, suggest explicit middle operand

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 net/ipv6/xfrm6_tunnel.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index a6770a0..fb9b0c3 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -241,7 +241,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
 	__be32 spi;
 
 	spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr);
-	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? : 0;
+	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? 1 : 0;
 }
 
 static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,



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

* Re: [PATCH]  ipv6: xfrm6: fix dubious code
  2011-05-23  8:42 [PATCH] ipv6: xfrm6: fix dubious code Eric Dumazet
@ 2011-05-23 15:36 ` Ben Hutchings
  2011-05-23 20:33   ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2011-05-23 15:36 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev

On Mon, 2011-05-23 at 10:42 +0200, Eric Dumazet wrote:
> net/ipv6/xfrm6_tunnel.c: In function ‘xfrm6_tunnel_rcv’:
> net/ipv6/xfrm6_tunnel.c:244:53: warning: the omitted middle operand
> in ?: will always be ‘true’, suggest explicit middle operand
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
>  net/ipv6/xfrm6_tunnel.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
> index a6770a0..fb9b0c3 100644
> --- a/net/ipv6/xfrm6_tunnel.c
> +++ b/net/ipv6/xfrm6_tunnel.c
> @@ -241,7 +241,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
>  	__be32 spi;
>  
>  	spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr);
> -	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? : 0;
> +	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? 1 : 0;
>  }
>  
>  static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,

I suspect that this was intended to return the result of xfrm6_rcv_spi()
if > 0.  But if it really is intended to return the result of the
inequality, then the '?:' operation is not needed at all.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


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

* Re: [PATCH] ipv6: xfrm6: fix dubious code
  2011-05-23 15:36 ` Ben Hutchings
@ 2011-05-23 20:33   ` David Miller
  2011-05-24  5:02     ` Steffen Klassert
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2011-05-23 20:33 UTC (permalink / raw)
  To: bhutchings; +Cc: eric.dumazet, netdev

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Mon, 23 May 2011 08:36:00 -0700

> On Mon, 2011-05-23 at 10:42 +0200, Eric Dumazet wrote:
>> net/ipv6/xfrm6_tunnel.c: In function ‘xfrm6_tunnel_rcv’:
>> net/ipv6/xfrm6_tunnel.c:244:53: warning: the omitted middle operand
>> in ?: will always be ‘true’, suggest explicit middle operand
>> 
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>> ---
>>  net/ipv6/xfrm6_tunnel.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
>> index a6770a0..fb9b0c3 100644
>> --- a/net/ipv6/xfrm6_tunnel.c
>> +++ b/net/ipv6/xfrm6_tunnel.c
>> @@ -241,7 +241,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
>>  	__be32 spi;
>>  
>>  	spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr);
>> -	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? : 0;
>> +	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? 1 : 0;
>>  }
>>  
>>  static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
> 
> I suspect that this was intended to return the result of xfrm6_rcv_spi()
> if > 0.

I also suspect this was the intent, but I'm not sure why it matters
at all.

The equivalent code implementing the same operations on the ipv4
side return xfrm4_rcv_spi()'s return value directly.

So we need to either decide that we can do the same thing here on the
ipv6 side, or document exactly why we can't.

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

* Re: [PATCH] ipv6: xfrm6: fix dubious code
  2011-05-23 20:33   ` David Miller
@ 2011-05-24  5:02     ` Steffen Klassert
  2011-05-24  5:12       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Steffen Klassert @ 2011-05-24  5:02 UTC (permalink / raw)
  To: David Miller; +Cc: bhutchings, eric.dumazet, netdev

On Mon, May 23, 2011 at 04:33:02PM -0400, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Mon, 23 May 2011 08:36:00 -0700
> 
> > On Mon, 2011-05-23 at 10:42 +0200, Eric Dumazet wrote:
> >> net/ipv6/xfrm6_tunnel.c: In function ‘xfrm6_tunnel_rcv’:
> >> net/ipv6/xfrm6_tunnel.c:244:53: warning: the omitted middle operand
> >> in ?: will always be ‘true’, suggest explicit middle operand
> >> 
> >> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> >> ---
> >>  net/ipv6/xfrm6_tunnel.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
> >> index a6770a0..fb9b0c3 100644
> >> --- a/net/ipv6/xfrm6_tunnel.c
> >> +++ b/net/ipv6/xfrm6_tunnel.c
> >> @@ -241,7 +241,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
> >>  	__be32 spi;
> >>  
> >>  	spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr);
> >> -	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? : 0;
> >> +	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? 1 : 0;
> >>  }
> >>  
> >>  static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
> > 
> > I suspect that this was intended to return the result of xfrm6_rcv_spi()
> > if > 0.
> 
> I also suspect this was the intent, but I'm not sure why it matters
> at all.
> 
> The equivalent code implementing the same operations on the ipv4
> side return xfrm4_rcv_spi()'s return value directly.
> 
> So we need to either decide that we can do the same thing here on the
> ipv6 side, or document exactly why we can't.

I think we can return the value directly like ipv4 does it. xfrm6_rcv_spi()
returns the return value of xfrm_input() which returns 0 in any case.

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

* Re: [PATCH] ipv6: xfrm6: fix dubious code
  2011-05-24  5:02     ` Steffen Klassert
@ 2011-05-24  5:12       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2011-05-24  5:12 UTC (permalink / raw)
  To: steffen.klassert; +Cc: bhutchings, eric.dumazet, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Tue, 24 May 2011 07:02:42 +0200

> I think we can return the value directly like ipv4 does it. xfrm6_rcv_spi()
> returns the return value of xfrm_input() which returns 0 in any case.

Indeed, works for me:

--------------------
ipv6: Fix return of xfrm6_tunnel_rcv()

Like ipv4, just return xfrm6_rcv_spi()'s return value directly.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv6/xfrm6_tunnel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index a6770a0..4fe1db1 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -241,7 +241,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
 	__be32 spi;
 
 	spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr);
-	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi) > 0 ? : 0;
+	return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi);
 }
 
 static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-- 
1.7.4.4


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

end of thread, other threads:[~2011-05-24  5:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23  8:42 [PATCH] ipv6: xfrm6: fix dubious code Eric Dumazet
2011-05-23 15:36 ` Ben Hutchings
2011-05-23 20:33   ` David Miller
2011-05-24  5:02     ` Steffen Klassert
2011-05-24  5:12       ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.