lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dvc257dkgpbxa7n43tqd6uin6hyyrwqreukozu63ldgufkr5td@unh7nmttomds>
Date: Fri, 5 Jul 2024 11:30:33 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc: linux-pwm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] pwm: core: Use str_plural() in pwm_seq_show()

On Tue, Jun 18, 2024 at 03:52:48PM +0800, Jiapeng Chong wrote:
> Use existing str_plural() function rather than duplicating its
> implementation.
> 
> ./drivers/pwm/core.c:1690:6-16: opportunity for str_plural(chip->npwm).
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9352
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>  drivers/pwm/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 5c1d20985148..141c5003b216 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -1687,7 +1687,7 @@ static int pwm_seq_show(struct seq_file *s, void *v)
>  		   (char *)s->private, chip->id,
>  		   pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
>  		   dev_name(pwmchip_parent(chip)), chip->npwm,
> -		   (chip->npwm != 1) ? "s" : "");
> +		   str_plural(chip->npwm));
>  
>  	pwm_dbg_show(chip, s);

I'm not convinced this change to be beneficial. Given that emitting npwm
doesn't add a valuable information[1], I tend to suggest instead:

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 5c1d20985148..fc7aa17dc6b5 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -1683,11 +1683,10 @@ static int pwm_seq_show(struct seq_file *s, void *v)
 {
 	struct pwm_chip *chip = v;
 
-	seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n",
+	seq_printf(s, "%s%d: %s/%s\n",
 		   (char *)s->private, chip->id,
 		   pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
-		   dev_name(pwmchip_parent(chip)), chip->npwm,
-		   (chip->npwm != 1) ? "s" : "");
+		   dev_name(pwmchip_parent(chip)))
 
 	pwm_dbg_show(chip, s);
 

If you want to pick up on this, feel free to use this patch without
attribution.

Best regards
Uwe

[1] pwm_dbg_show() emits npwm lines, so the value can be determined
easily.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ