linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Thorsten Blum <thorsten.blum@toblux.com>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Johannes Thumshirn <jth@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] zonefs: Use str_plural() to fix Coccinelle warning
Date: Mon, 8 Apr 2024 10:48:44 +0900	[thread overview]
Message-ID: <99a8d3ec-1028-44c5-9fcd-01598a40a014@kernel.org> (raw)
In-Reply-To: <20240402101715.226284-2-thorsten.blum@toblux.com>

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@toblux.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


  reply	other threads:[~2024-04-08  1:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 10:17 [PATCH] zonefs: Use str_plural() to fix Coccinelle warning Thorsten Blum
2024-04-08  1:48 ` Damien Le Moal [this message]
2024-04-08 10:04   ` Thorsten Blum
2024-04-08 10:06     ` Damien Le Moal
2024-04-09 23:50 ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99a8d3ec-1028-44c5-9fcd-01598a40a014@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=jth@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=thorsten.blum@toblux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).