Skip to contentSkip to conversation

platform/x86: acer-wmi: refactor function has_cap

PATCH Superseded Gustavo A. R. Silva 2 participants 3 messages Aug 6, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: acer-wmi: refactor function has_cap

Refactor function has_cap in order to avoid returning integer values, when instead it should return booleans.

This code was detected with the help of Coccinelle.

---
 drivers/platform/x86/acer-wmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/platform/x86/acer-wmi.c +1 -4
index 8952173..ff1689d 100644
@@ -672,10 +672,7 @@ static void __init find_quirks(void)
 
 static bool has_cap(u32 cap)
 {
-	if ((interface->capability & cap) != 0)
-		return 1;
-
-	return 0;
+	return (interface->capability & cap) != 0;
 }
 
 /*
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · Gustavo A. R. Silva

Refactor function has_cap in order to avoid returning integer values, when instead it should return booleans.

This code was detected with the help of Coccinelle.

---
 drivers/platform/x86/acer-wmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/platform/x86/acer-wmi.c +0 -0
index 8952173..ff1689d 100644

drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 676

Quoted 9 lines
drivers/platform/x86/acer-wmi.c +1 -4
@@ -672,10 +672,7 @@ static void __init find_quirks(void)
 
 static bool has_cap(u32 cap)
 {
-       if ((interface->capability & cap) != 0)
-               return 1;
-
-       return 0;
+       return (interface->capability & cap) != 0;
 }

Thanks, as Joe mentioned even != 0 part is not needed (followed by unneeded parens), though I would let it be (one line is good enough to me) if there will be no strong preferences.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 18 lines · Andy Shevchenko
Quoted 16 lines · Gustavo A. R. Silva

Refactor function has_cap in order to avoid returning integer values, when instead it should return booleans.

This code was detected with the help of Coccinelle.

---
 drivers/platform/x86/acer-wmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/platform/x86/acer-wmi.c +0 -0
index 8952173..ff1689d 100644
@@ -672,10 +672,7 @@ static void __init find_quirks(void)
 
Quoted 13 lines

drivers/platform/x86/acer-wmi.c static void __init find_quirks(void) · line 676

Quoted 8 lines
drivers/platform/x86/acer-wmi.c +1 -4
 static bool has_cap(u32 cap)
 {
-       if ((interface->capability & cap) != 0)
-               return 1;
-
-       return 0;
+       return (interface->capability & cap) != 0;
 }

Thanks, as Joe mentioned even != 0 part is not needed (followed by unneeded parens), though I would let it be (one line is good enough to me) if there will be no strong preferences.

Oh, yeah. I like it better what Joe suggested.

Let me send v2, shortly.

Thanks
--
Gustavo