Skip to contentSkip to conversation

s390/smp: Use min() to fix Coccinelle warning

PATCH In review Thorsten Blum 2 participants 2 messages Apr 8, 2024 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/smp: Use min() to fix Coccinelle warning

Fixes the following Coccinelle/coccicheck warning reported by minmax.cocci:

WARNING opportunity for min()

---
 arch/s390/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/smp.c +1 -1
index 0324649aae0a..d69cf2475744 100644
@@ -1205,7 +1205,7 @@ static int __init s390_smp_init(void)
 
 	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online",
 			       smp_cpu_online, smp_cpu_pre_down);
-	rc = rc <= 0 ? rc : 0;
+	rc = min(rc, 0);
 out:
 	return rc;
 }
Signature · 1 line
2.44.0
maintainer
#1 lore raw
Quoted 15 lines · Thorsten Blum

Fixes the following Coccinelle/coccicheck warning reported by minmax.cocci:

WARNING opportunity for min()

---
 arch/s390/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/smp.c +0 -0
index 0324649aae0a..d69cf2475744 100644

arch/s390/kernel/smp.c static int __init s390_smp_init(void) · line 1208

Quoted 5 lines
arch/s390/kernel/smp.c +1 -1
@@ -1205,7 +1205,7 @@ static int __init s390_smp_init(void)
 
 	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online",
 			       smp_cpu_online, smp_cpu_pre_down);
-	rc = rc <= 0 ? rc : 0;
+	rc = min(rc, 0);

No. This decreases readability. Please do not send such patches just because Coccinelle reports something.