[PATCH v2] md/raid0: Use str_plural() to simplify the code

Xichao Zhao posted 1 patch 1 month ago
drivers/md/raid0.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] md/raid0: Use str_plural() to simplify the code
Posted by Xichao Zhao 1 month ago
Use the string choice helper function str_plural() to simplify the code.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
v2:
  - correct the subject of the v1 version patch.
v1: https://lore.kernel.org/all/20250828112714.633108-1-zhao.xichao@vivo.com/
---
 drivers/md/raid0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index cbe2a9054cb9..a2e59a8d441f 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -41,7 +41,7 @@ static void dump_zones(struct mddev *mddev)
 	int raid_disks = conf->strip_zone[0].nb_dev;
 	pr_debug("md: RAID0 configuration for %s - %d zone%s\n",
 		 mdname(mddev),
-		 conf->nr_strip_zones, conf->nr_strip_zones==1?"":"s");
+		 conf->nr_strip_zones, str_plural(conf->nr_strip_zones));
 	for (j = 0; j < conf->nr_strip_zones; j++) {
 		char line[200];
 		int len = 0;
-- 
2.34.1
Re: [PATCH v2] md/raid0: Use str_plural() to simplify the code
Posted by Paul Menzel 1 month ago
Dear Xichao,


Thank you for your patch.


Am 29.08.25 um 08:58 schrieb Xichao Zhao:
> Use the string choice helper function str_plural() to simplify the code.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
> v2:
>    - correct the subject of the v1 version patch.
> v1: https://lore.kernel.org/all/20250828112714.633108-1-zhao.xichao@vivo.com/
> ---
>   drivers/md/raid0.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> index cbe2a9054cb9..a2e59a8d441f 100644
> --- a/drivers/md/raid0.c
> +++ b/drivers/md/raid0.c
> @@ -41,7 +41,7 @@ static void dump_zones(struct mddev *mddev)
>   	int raid_disks = conf->strip_zone[0].nb_dev;
>   	pr_debug("md: RAID0 configuration for %s - %d zone%s\n",
>   		 mdname(mddev),
> -		 conf->nr_strip_zones, conf->nr_strip_zones==1?"":"s");
> +		 conf->nr_strip_zones, str_plural(conf->nr_strip_zones));
>   	for (j = 0; j < conf->nr_strip_zones; j++) {
>   		char line[200];
>   		int len = 0;

I guess some will debate, whether this helper is an improvement or not, 
especially as the helper implementation has no advantage. But as it’s 
under `include/`, why not use it. I see the only advantage, that it 
denotes some kind of semantic meaning.

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>


Kind regards,

Paul