platform/x86: acer-wmi: use true and false for boolean values
Subsystems (2)
PATCH 1/1 platform/x86: acer-wmi: use true and false for boolean values
Return statements in functions returning bool should use true or false instead of an integer value.
This code was detected with the help of Coccinelle.
--- drivers/platform/x86/acer-wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/acer-wmi.c +2 -2
@@ -673,9 +673,9 @@ static void __init find_quirks(void)static bool has_cap (u32 cap) {if ((interface->capability & cap) !=0 ) -return 1 ; +return true; -return 0 ; +return false; }/*
Signature · 1 line
2.7.4
Quoted 8 lines · Gustavo A. R. Silva
Return statements in functions returning bool should use true or false instead of an integer value.
This code was detected with the help of Coccinelle.
static bool
has_cap(u32 cap){ if ((interface->capability & cap) != 0)
drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 679
Quoted 6 lines
drivers/platform/x86/acer-wmi.c +2
-2-return 1 ; +return true; -return 0 ; +return false; }
this entire function can be oneliner:
return !!(...);
Signature · 2 lines
With Best Regards, Andy Shevchenko
From: Andy Shevchenko
Quoted 15 lines
Sent: 05 August 2018 11:26
Quoted 11 lines · Gustavo A. R. Silva
Return statements in functions returning bool should use true or false instead of an integer value.
This code was detected with the help of Coccinelle.
static bool
has_cap(u32 cap){ if ((interface->capability & cap) != 0)drivers/platform/x86/acer-wmi.c +1
-1-return 1 ; +return true;
Quoted 7 lines
drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 679
Quoted 3 lines
drivers/platform/x86/acer-wmi.c +1
-1-return 0 ; +return false; }this entire function can be oneliner:
return !!(...);
Why the !! ?? Just:
return (interface->capability & cap) != 0; David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 19 lines · David Laight
From: Andy Shevchenko
Quoted 18 lines
Sent: 05 August 2018 11:26
Quoted 13 lines · Gustavo A. R. Silva
Return statements in functions returning bool should use true or false instead of an integer value.
This code was detected with the help of Coccinelle.
static boolhas_cap(u32 cap){ if ((interface->capability & cap) != 0)drivers/platform/x86/acer-wmi.c +2
-2-return 1 ; +return true; -return 0 ; +return false; }
Quoted 6 lines
Quoted 3 lines
this entire function can be oneliner:
return !!(...);
Why the !! ?? Just:
return (interface->capability & cap) != 0;
Because the return is bool you don't need the !! either. The compiler does that.
Quoted 22 lines · Joe Perches
Quoted 21 lines · David Laight
From: Andy Shevchenko
Quoted 20 lines
Sent: 05 August 2018 11:26
drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 679
Quoted 13 lines · Gustavo A. R. Silva
Return statements in functions returning bool should use true or false instead of an integer value.
This code was detected with the help of Coccinelle.
static boolhas_cap(u32 cap){ if ((interface->capability & cap) != 0)drivers/platform/x86/acer-wmi.c +2
-2-return 1 ; +return true; -return 0 ; +return false; }this entire function can be oneliner:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
return !!(...);
Why the !! ?? Just:
return (interface->capability & cap) != 0;Because the return is bool you don't need the !! either. The compiler does that.
Hi all,
I'll send v2 with the suggested improvements.
Thanks for your feedback.
--
Gustavo
Quoted 16 lines · Joe Perches
Quoted 15 lines · David Laight
From: Andy Shevchenko
Quoted 14 lines
Sent: 05 August 2018 11:26
drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 679
Quoted 9 lines
static bool
has_cap(u32 cap){ if ((interface->capability & cap) != 0)drivers/platform/x86/acer-wmi.c +2
-2-return 1 ; +return true; -return 0 ; +return false; }this entire function can be oneliner:
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
return !!(...);
Why the !! ?? Just:
return (interface->capability & cap) != 0;Because the return is bool you don't need the !! either. The compiler does that.
True, I use that pattern, but in most cases the return value is int and this is just to guarantee the 0,1 possible range.
Signature · 2 lines
With Best Regards, Andy Shevchenko