[PATCH] accessibility: Use str_plural() to simplify the code

Xichao Zhao posted 1 patch 1 month, 4 weeks ago
drivers/accessibility/speakup/kobjects.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] accessibility: Use str_plural() to simplify the code
Posted by Xichao Zhao 1 month, 4 weeks ago
Use the string choice helper function str_plural() to simplify the code.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 drivers/accessibility/speakup/kobjects.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/accessibility/speakup/kobjects.c b/drivers/accessibility/speakup/kobjects.c
index 0dfdb6608e02..57139971e997 100644
--- a/drivers/accessibility/speakup/kobjects.c
+++ b/drivers/accessibility/speakup/kobjects.c
@@ -98,7 +98,7 @@ static void report_char_chartab_status(int reset, int received, int used,
 		if (rejected)
 			snprintf(buf + (len - 1), sizeof(buf) - (len - 1),
 				 " with %d reject%s\n",
-				 rejected, rejected > 1 ? "s" : "");
+				 rejected, str_plural(rejected));
 		pr_info("%s", buf);
 	}
 }
@@ -740,7 +740,7 @@ static void report_msg_status(int reset, int received, int used,
 		if (rejected)
 			snprintf(buf + (len - 1), sizeof(buf) - (len - 1),
 				 " with %d reject%s\n",
-				 rejected, rejected > 1 ? "s" : "");
+				 rejected, str_plural(rejected));
 		pr_info("%s", buf);
 	}
 }
-- 
2.34.1
Re: [PATCH] accessibility: Use str_plural() to simplify the code
Posted by Samuel Thibault 1 month, 4 weeks ago
Xichao Zhao, le jeu. 07 août 2025 16:59:30 +0800, a ecrit:
> Use the string choice helper function str_plural() to simplify the code.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  drivers/accessibility/speakup/kobjects.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/accessibility/speakup/kobjects.c b/drivers/accessibility/speakup/kobjects.c
> index 0dfdb6608e02..57139971e997 100644
> --- a/drivers/accessibility/speakup/kobjects.c
> +++ b/drivers/accessibility/speakup/kobjects.c
> @@ -98,7 +98,7 @@ static void report_char_chartab_status(int reset, int received, int used,
>  		if (rejected)
>  			snprintf(buf + (len - 1), sizeof(buf) - (len - 1),
>  				 " with %d reject%s\n",
> -				 rejected, rejected > 1 ? "s" : "");
> +				 rejected, str_plural(rejected));
>  		pr_info("%s", buf);
>  	}
>  }
> @@ -740,7 +740,7 @@ static void report_msg_status(int reset, int received, int used,
>  		if (rejected)
>  			snprintf(buf + (len - 1), sizeof(buf) - (len - 1),
>  				 " with %d reject%s\n",
> -				 rejected, rejected > 1 ? "s" : "");
> +				 rejected, str_plural(rejected));
>  		pr_info("%s", buf);
>  	}
>  }
> -- 
> 2.34.1