Skip to contentSkip to conversation

mm/cma: Use str_plural() in cma_declare_contiguous_multi()

PATCH Applied Thorsten Blum 4 participants 4 messages Jun 30, 2025 – Jul 4, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/cma: Use str_plural() in cma_declare_contiguous_multi()

Use the string choice helper function str_plural() to simplify the code and to fix the following Coccinelle/coccicheck warning reported by string_choices.cocci:

opportunity for str_plural(nr)

---
 mm/cma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/cma.c +2 -2
index c0b2630a1b81..c40d53298801 100644
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/log2.h>
 #include <linux/cma.h>
 #include <linux/highmem.h>
@@ -548,8 +549,7 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
 			(unsigned long)total_size / SZ_1M);
 	else
 		pr_info("Reserved %lu MiB in %d range%s\n",
-			(unsigned long)total_size / SZ_1M, nr,
-			nr > 1 ? "s" : "");
+			(unsigned long)total_size / SZ_1M, nr, str_plural(nr));
 	return ret;
 }
 
Signature · 1 line
2.50.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thorsten Blum

Use the string choice helper function str_plural() to simplify the code and to fix the following Coccinelle/coccicheck warning reported by string_choices.cocci:

opportunity for str_plural(nr)

---

Thanks for basing on mm-new, I have tested the patch.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum
Quoted 24 lines · Thorsten Blum

Use the string choice helper function str_plural() to simplify the code and to fix the following Coccinelle/coccicheck warning reported by string_choices.cocci:

opportunity for str_plural(nr)

---
 mm/cma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/cma.c +1 -0
index c0b2630a1b81..c40d53298801 100644
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/log2.h>
 #include <linux/cma.h>
 #include <linux/highmem.h>

mm/cma.c int __init cma_declare_contiguous_multi(phys_addr_t total_size, · line 555

Quoted 9 lines
mm/cma.c +1 -2
@@ -548,8 +549,7 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
 			(unsigned long)total_size / SZ_1M);
 	else
 		pr_info("Reserved %lu MiB in %d range%s\n",
-			(unsigned long)total_size / SZ_1M, nr,
-			nr > 1 ? "s" : "");
+			(unsigned long)total_size / SZ_1M, nr, str_plural(nr));
 	return ret;
 }