linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] smc: return booleans instead of integers
@ 2018-01-19 20:54 Gustavo A. R. Silva
  2018-01-22 11:58 ` Ursula Braun
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-01-19 20:54 UTC (permalink / raw)
  To: Ursula Braun, David S. Miller
  Cc: linux-s390, netdev, linux-kernel, Gustavo A. R. Silva

Return statements in functions returning bool should use
true/false instead of 1/0.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
 - Fix function using_ipsec as suggested by Ursula Braun.
 - Update subject line.

 net/smc/smc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/smc/smc.h b/net/smc/smc.h
index 0bee9d1..6328565 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -253,12 +253,12 @@ static inline int smc_uncompress_bufsize(u8 compressed)
 static inline bool using_ipsec(struct smc_sock *smc)
 {
 	return (smc->clcsock->sk->sk_policy[0] ||
-		smc->clcsock->sk->sk_policy[1]) ? 1 : 0;
+		smc->clcsock->sk->sk_policy[1]) ? true : false;
 }
 #else
 static inline bool using_ipsec(struct smc_sock *smc)
 {
-	return 0;
+	return false;
 }
 #endif
 
-- 
2.7.4

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

* Re: [PATCH v2] smc: return booleans instead of integers
  2018-01-19 20:54 [PATCH v2] smc: return booleans instead of integers Gustavo A. R. Silva
@ 2018-01-22 11:58 ` Ursula Braun
  2018-01-22 23:38   ` Gustavo A. R. Silva
  2018-01-23  0:31   ` Joe Perches
  0 siblings, 2 replies; 5+ messages in thread
From: Ursula Braun @ 2018-01-22 11:58 UTC (permalink / raw)
  To: Gustavo A. R. Silva, David S. Miller
  Cc: linux-s390, netdev, linux-kernel, Gustavo A. R. Silva



On 01/19/2018 09:54 PM, Gustavo A. R. Silva wrote:
> Return statements in functions returning bool should use
> true/false instead of 1/0.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  - Fix function using_ipsec as suggested by Ursula Braun.
>  - Update subject line.
> 
>  net/smc/smc.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/smc/smc.h b/net/smc/smc.h
> index 0bee9d1..6328565 100644
> --- a/net/smc/smc.h
> +++ b/net/smc/smc.h
> @@ -253,12 +253,12 @@ static inline int smc_uncompress_bufsize(u8 compressed)
>  static inline bool using_ipsec(struct smc_sock *smc)
>  {
>  	return (smc->clcsock->sk->sk_policy[0] ||
> -		smc->clcsock->sk->sk_policy[1]) ? 1 : 0;
> +		smc->clcsock->sk->sk_policy[1]) ? true : false;
>  }
>  #else
>  static inline bool using_ipsec(struct smc_sock *smc)
>  {
> -	return 0;
> +	return false;
>  }
>  #endif
> 

Thanks, Gustavo. I have added the patch to our local repository. It will
be part of one of my next patch sets to be sent to Dave Miller.

Regards, Ursula

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

* Re: [PATCH v2] smc: return booleans instead of integers
  2018-01-22 11:58 ` Ursula Braun
@ 2018-01-22 23:38   ` Gustavo A. R. Silva
  2018-01-23  0:31   ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-01-22 23:38 UTC (permalink / raw)
  To: Ursula Braun
  Cc: Gustavo A. R. Silva, David S. Miller, linux-s390, netdev, linux-kernel


Quoting Ursula Braun <ubraun@linux.vnet.ibm.com>:

[...]

>
> Thanks, Gustavo. I have added the patch to our local repository. It will
> be part of one of my next patch sets to be sent to Dave Miller.
>


Thanks, Ursula :)

--
Gustavo

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

* Re: [PATCH v2] smc: return booleans instead of integers
  2018-01-22 11:58 ` Ursula Braun
  2018-01-22 23:38   ` Gustavo A. R. Silva
@ 2018-01-23  0:31   ` Joe Perches
  2018-01-23 11:44     ` Ursula Braun
  1 sibling, 1 reply; 5+ messages in thread
From: Joe Perches @ 2018-01-23  0:31 UTC (permalink / raw)
  To: Ursula Braun, Gustavo A. R. Silva, David S. Miller
  Cc: linux-s390, netdev, linux-kernel, Gustavo A. R. Silva

On Mon, 2018-01-22 at 12:58 +0100, Ursula Braun wrote:
> 
> On 01/19/2018 09:54 PM, Gustavo A. R. Silva wrote:
> > Return statements in functions returning bool should use
> > true/false instead of 1/0.
> > 
> > This issue was detected with the help of Coccinelle.
> > 
> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> > ---
> > Changes in v2:
> >  - Fix function using_ipsec as suggested by Ursula Braun.
> >  - Update subject line.
> > 
> >  net/smc/smc.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/smc/smc.h b/net/smc/smc.h
[]
> > @@ -253,12 +253,12 @@ static inline int smc_uncompress_bufsize(u8 compressed)
> >  static inline bool using_ipsec(struct smc_sock *smc)
> >  {
> >  	return (smc->clcsock->sk->sk_policy[0] ||
> > -		smc->clcsock->sk->sk_policy[1]) ? 1 : 0;
> > +		smc->clcsock->sk->sk_policy[1]) ? true : false;

Generally, any bool return like

	return condition ? true : false;

could be written

	return condition;

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

* Re: [PATCH v2] smc: return booleans instead of integers
  2018-01-23  0:31   ` Joe Perches
@ 2018-01-23 11:44     ` Ursula Braun
  0 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-01-23 11:44 UTC (permalink / raw)
  To: Joe Perches, Gustavo A. R. Silva, David S. Miller
  Cc: linux-s390, netdev, linux-kernel, Gustavo A. R. Silva



On 01/23/2018 01:31 AM, Joe Perches wrote:
> On Mon, 2018-01-22 at 12:58 +0100, Ursula Braun wrote:
>>
>> On 01/19/2018 09:54 PM, Gustavo A. R. Silva wrote:
>>> Return statements in functions returning bool should use
>>> true/false instead of 1/0.
>>>
>>> This issue was detected with the help of Coccinelle.
>>>
>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>> ---
>>> Changes in v2:
>>>  - Fix function using_ipsec as suggested by Ursula Braun.
>>>  - Update subject line.
>>>
>>>  net/smc/smc.h | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/smc/smc.h b/net/smc/smc.h
> []
>>> @@ -253,12 +253,12 @@ static inline int smc_uncompress_bufsize(u8 compressed)
>>>  static inline bool using_ipsec(struct smc_sock *smc)
>>>  {
>>>  	return (smc->clcsock->sk->sk_policy[0] ||
>>> -		smc->clcsock->sk->sk_policy[1]) ? 1 : 0;
>>> +		smc->clcsock->sk->sk_policy[1]) ? true : false;
> 
> Generally, any bool return like
> 
> 	return condition ? true : false;
> 
> could be written
> 
> 	return condition;
> 
This would be shorter, but is it really better readable/understandable?
Do you have a reference for us confirming your proposed style is the way to go?

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

end of thread, other threads:[~2018-01-23 11:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 20:54 [PATCH v2] smc: return booleans instead of integers Gustavo A. R. Silva
2018-01-22 11:58 ` Ursula Braun
2018-01-22 23:38   ` Gustavo A. R. Silva
2018-01-23  0:31   ` Joe Perches
2018-01-23 11:44     ` Ursula Braun

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