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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 8 Apr 2024 10:48:44 +0900
From: Damien Le Moal <dlemoal@...nel.org>
To: Thorsten Blum <thorsten.blum@...lux.com>,
 Naohiro Aota <naohiro.aota@....com>, Johannes Thumshirn <jth@...nel.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] zonefs: Use str_plural() to fix Coccinelle warning

On 4/2/24 19:17, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> string_choices.cocci:
> 
> 	opportunity for str_plural(zgroup->g_nr_zones)
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
>  fs/zonefs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index c6a124e8d565..964fa7f24003 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1048,7 +1048,7 @@ static int zonefs_init_zgroup(struct super_block *sb,
>  	zonefs_info(sb, "Zone group \"%s\" has %u file%s\n",
>  		    zonefs_zgroup_name(ztype),
>  		    zgroup->g_nr_zones,
> -		    zgroup->g_nr_zones > 1 ? "s" : "");
> +		    str_plural(zgroup->g_nr_zones));

Looking at this function definition:

static inline const char *str_plural(size_t num)
{
	return num == 1 ? "" : "s";
}

It is wrong: num == 0 should not imply plural. This function needs to be fixed.
E.g. it should be:

static inline const char *str_plural(size_t num)
{
	return num <= 1 ? "" : "s";
}

Please fix that first and then we can apply your patch to zonefs.

-- 
Damien Le Moal
Western Digital Research


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ