Skip to contentSkip to conversation

sparc/irq: Remove unneeded if check in sun4v_cookie_only_virqs()

PATCH In review Thorsten Blum 3 participants 4 messages Jan 14, 2025 – Jan 17, 2025 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc/irq: Remove unneeded if check in sun4v_cookie_only_virqs()

Remove the unnecessary if check and return the result directly.

---
 arch/sparc/kernel/irq_64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sparc/kernel/irq_64.c +1 -3
index aff0d24f8c6f..81fb49b089a8 100644
@@ -146,9 +146,7 @@ static int hv_irq_version;
  */
 static bool sun4v_cookie_only_virqs(void)
 {
-	if (hv_irq_version >= 3)
-		return true;
-	return false;
+	return hv_irq_version >= 3;
 }
 
 static void __init irq_init_hv(void)
Signature · 1 line
2.47.1
#1 lore raw

Hi Thorsten,

Quoted 12 lines · Thorsten Blum

Remove the unnecessary if check and return the result directly.

---
 arch/sparc/kernel/irq_64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sparc/kernel/irq_64.c +0 -0
index aff0d24f8c6f..81fb49b089a8 100644

arch/sparc/kernel/irq_64.c static int hv_irq_version; · line 152

Quoted 10 lines
arch/sparc/kernel/irq_64.c +1 -3
@@ -146,9 +146,7 @@ static int hv_irq_version;
  */
 static bool sun4v_cookie_only_virqs(void)
 {
-	if (hv_irq_version >= 3)
-		return true;
-	return false;
+	return hv_irq_version >= 3;
 }
 
 static void __init irq_init_hv(void)

I'm not sure whether this change is really necessary nor will it improve the readability of the code. I think the compiler will optimize the code the same way, for both variants.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#2 lore raw

Hi Adrian,

Quoted 22 lines · John Paul Adrian Glaubitz
Quoted 21 lines · Thorsten Blum

Remove the unnecessary if check and return the result directly.

---
arch/sparc/kernel/irq_64.c | 4 +---

1 file changed, 1 insertion(+), 3 deletions(-)
arch/sparc/kernel/irq_64.c +1 -3
index aff0d24f8c6f..81fb49b089a8 100644
@@ -146,9 +146,7 @@ static int hv_irq_version;
 */
 static bool sun4v_cookie_only_virqs(void)
 {
- if (hv_irq_version >= 3)
- return true;
- return false;
+ return hv_irq_version >= 3;
 }
 
Quoted 5 lines

arch/sparc/kernel/irq_64.c static int hv_irq_version; · line 152

Quoted 1 line
arch/sparc/kernel/irq_64.c +0 -0
 static void __init irq_init_hv(void)

I'm not sure whether this change is really necessary nor will it improve the readability of the code. I think the compiler will optimize the code the same way, for both variants.

It's not strictly necessary, but it's shorter, less verbose, and imo improves the code's readability. Personally, I'd even consider the current version a code smell, but feel free to ignore the patch.

Thanks,
Thorsten

maintainer Reviewed-by
#3 lore raw
Quoted 31 lines · Thorsten Blum

Hi Adrian,

Quoted 22 lines · John Paul Adrian Glaubitz
Quoted 21 lines · Thorsten Blum

Remove the unnecessary if check and return the result directly.

---
arch/sparc/kernel/irq_64.c | 4 +---

1 file changed, 1 insertion(+), 3 deletions(-)
arch/sparc/kernel/irq_64.c +1 -3
index aff0d24f8c6f..81fb49b089a8 100644
@@ -146,9 +146,7 @@ static int hv_irq_version;
 */
 static bool sun4v_cookie_only_virqs(void)
 {
- if (hv_irq_version >= 3)
- return true;
- return false;
+ return hv_irq_version >= 3;
 }
 
Quoted 5 lines

arch/sparc/kernel/irq_64.c static int hv_irq_version; · line 152

Quoted 1 line
arch/sparc/kernel/irq_64.c +0 -0
 static void __init irq_init_hv(void)

I'm not sure whether this change is really necessary nor will it improve the readability of the code. I think the compiler will optimize the code the same way, for both variants.

Quoted 3 lines

It's not strictly necessary, but it's shorter, less verbose, and imo improves the code's readability. Personally, I'd even consider the current version a code smell, but feel free to ignore the patch.

I could see it both ways, but personally agree about it being slightly more readable. As I'll pick up the other sun4v_cookie_only_virqs() related patch I might as well take this one as well.

Picking this up to my for-next.

Thanks,
Andreas