Skip to contentSkip to conversation

smp: Use str_plural() to fix Coccinelle warnings

PATCH Superseded Thorsten Blum 3 participants 5 messages Mar 27, 2024 – Jun 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smp: Use str_plural() to fix Coccinelle warnings

Fixes the following two Coccinelle/coccicheck warnings reported by string_choices.cocci:

opportunity for str_plural(num_cpus)
opportunity for str_plural(num_nodes)

---
 kernel/smp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/smp.c +2 -2
index f085ebcdf9e7..58b7f134c044 100644
@@ -982,8 +982,8 @@ void __init smp_init(void)
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
 	pr_info("Brought up %d node%s, %d CPU%s\n",
-		num_nodes, (num_nodes > 1 ? "s" : ""),
-		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+		num_nodes, str_plural(num_nodes),
+		num_cpus,  str_plural(num_cpus));
 
 	/* Any cleanup work */
 	smp_cpus_done(setup_max_cpus);
Signature · 1 line
2.44.0
#1 lore raw

PATCH v2 1/1 smp: Use str_plural() to fix Coccinelle warnings

Fixes the following two Coccinelle/coccicheck warnings reported by string_choices.cocci:

opportunity for str_plural(num_cpus)
opportunity for str_plural(num_nodes)

---
Changes in v2:
- Include missing header file

---
 kernel/smp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/smp.c +3 -2
index f085ebcdf9e7..28fee28174e0 100644
@@ -25,6 +25,7 @@
 #include <linux/nmi.h>
 #include <linux/sched/debug.h>
 #include <linux/jump_label.h>
+#include <linux/string_choices.h>
 
 #include <trace/events/ipi.h>
 #define CREATE_TRACE_POINTS
@@ -982,8 +983,8 @@ void __init smp_init(void)
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
 	pr_info("Brought up %d node%s, %d CPU%s\n",
-		num_nodes, (num_nodes > 1 ? "s" : ""),
-		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+		num_nodes, str_plural(num_nodes),
+		num_cpus,  str_plural(num_cpus));
 
 	/* Any cleanup work */
 	smp_cpus_done(setup_max_cpus);
Signature · 1 line
2.44.0
Acked-by on v2 1/1
#2 lore raw
Quoted 7 lines · Thorsten Blum

Fixes the following two Coccinelle/coccicheck warnings reported by string_choices.cocci:

opportunity for str_plural(num_cpus)
opportunity for str_plural(num_nodes)

Quoted 33 lines

---
Changes in v2:
- Include missing header file

---
 kernel/smp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/smp.c +3 -2
index f085ebcdf9e7..28fee28174e0 100644
@@ -25,6 +25,7 @@
 #include <linux/nmi.h>
 #include <linux/sched/debug.h>
 #include <linux/jump_label.h>
+#include <linux/string_choices.h>
 
 #include <trace/events/ipi.h>
 #define CREATE_TRACE_POINTS
@@ -982,8 +983,8 @@ void __init smp_init(void)
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
 	pr_info("Brought up %d node%s, %d CPU%s\n",
-		num_nodes, (num_nodes > 1 ? "s" : ""),
-		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+		num_nodes, str_plural(num_nodes),
+		num_cpus,  str_plural(num_cpus));
 
 	/* Any cleanup work */
 	smp_cpus_done(setup_max_cpus);
Signature · 1 line
2.44.0
#3 lore raw

PATCH RESEND v2 1/1 smp: Use str_plural() to fix Coccinelle warnings

Fixes the following two Coccinelle/coccicheck warnings reported by string_choices.cocci:

opportunity for str_plural(num_cpus)
opportunity for str_plural(num_nodes)

---
Changes in v2:
- Include missing header file

---
 kernel/smp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/smp.c +3 -2
index f085ebcdf9e7..28fee28174e0 100644
@@ -25,6 +25,7 @@
 #include <linux/nmi.h>
 #include <linux/sched/debug.h>
 #include <linux/jump_label.h>
+#include <linux/string_choices.h>
 
 #include <trace/events/ipi.h>
 #define CREATE_TRACE_POINTS
@@ -982,8 +983,8 @@ void __init smp_init(void)
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
 	pr_info("Brought up %d node%s, %d CPU%s\n",
-		num_nodes, (num_nodes > 1 ? "s" : ""),
-		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+		num_nodes, str_plural(num_nodes),
+		num_cpus,  str_plural(num_cpus));
 
 	/* Any cleanup work */
 	smp_cpus_done(setup_max_cpus);
Signature · 1 line
2.45.0
merge bot Applied
#4 lore raw
The following commit has been merged into the smp/core branch of tip:

The following commit has been merged into the smp/core branch of tip:

Commit-ID:     c4df15931cb72556fea93bd763ada88e56cbd8e5
Gitweb:        https://git.kernel.org/tip/c4df15931cb72556fea93bd763ada88e56cbd8e5
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Wed, 08 May 2024 17:42:26 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 17 Jun 2024 15:17:44 +02:00

smp: Use str_plural() to fix Coccinelle warnings

Fixes the following two Coccinelle/coccicheck warnings reported by string_choices.cocci:

opportunity for str_plural(num_cpus)
opportunity for str_plural(num_nodes)

---
 kernel/smp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/smp.c +2 -2
index f085ebc..1848357 100644
@@ -25,6 +25,7 @@
 #include <linux/nmi.h>
 #include <linux/sched/debug.h>
 #include <linux/jump_label.h>
+#include <linux/string_choices.h>
 
 #include <trace/events/ipi.h>
 #define CREATE_TRACE_POINTS
@@ -982,8 +983,7 @@ void __init smp_init(void)
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
 	pr_info("Brought up %d node%s, %d CPU%s\n",
-		num_nodes, (num_nodes > 1 ? "s" : ""),
-		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+		num_nodes, str_plural(num_nodes), num_cpus, str_plural(num_cpus));
 
 	/* Any cleanup work */
 	smp_cpus_done(setup_max_cpus);