smc: return booleans instead of integers
PATCH v2 1/1 smc: return booleans instead of integers
Return statements in functions returning bool should use true/false instead of 1/0.
This issue was detected with the help of Coccinelle.
---
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(-)
net/smc/smc.h +2 -2
@@ -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
Signature · 1 line
2.7.4
Quoted 23 lines · 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 <[email protected]>---
Changes in v2:
- Fix functionusing_ipsecas suggested by Ursula Braun.
- Update subject line.net/smc/smc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/smc/smc.h +0
-1@@ -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 ;
net/smc/smc.h static inline int smc_uncompress_bufsize(u8 compressed) · line 264
Quoted 10 lines
net/smc/smc.h +2
-1+ 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
Quoting Ursula Braun <[email protected]>:
[...]
Quoted 4 lines
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
Quoted 13 lines · Ursula Braun
Quoted 11 lines · 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 <[email protected]>---
Changes in v2:
- Fix functionusing_ipsecas suggested by Ursula Braun.
- Update subject line.
Quoted 4 lines
net/smc/smc.h
Quoted 4 lines
net/smc/smc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/smc/smc.h +0
-0
[]
Quoted 6 lines
net/smc/smc.h static inline int smc_uncompress_bufsize(u8 compressed) · line 256
Quoted 6 lines
net/smc/smc.h +1
-1@@ -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;
Quoted 28 lines · Joe Perches
Quoted 13 lines · Ursula Braun
Quoted 11 lines · 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 <[email protected]>---
Changes in v2:
- Fix functionusing_ipsecas suggested by Ursula Braun.
- Update subject line.Quoted 4 lines
net/smc/smc.h
Quoted 4 lines
net/smc/smc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/smc/smc.h +0
-0[]
Quoted 6 lines
net/smc/smc.h static inline int smc_uncompress_bufsize(u8 compressed) · line 256
Quoted 6 lines
net/smc/smc.h +1
-1@@ -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
Quoted 6 lines
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?