mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] zonefs: Fix the wrong format specifier
@ 2024-11-11  5:41 Zhu Jun
  2024-11-13 17:55 ` Chaitanya Kulkarni
  2024-12-08 23:17 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Zhu Jun @ 2024-11-11  5:41 UTC (permalink / raw)
  To: dlemoal; +Cc: naohiro.aota, jth, linux-fsdevel, linux-kernel, zhujun2

The format specifier of "signed int" in snprintf() should be "%d", not
"%u".

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.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 faf1eb87895d..43c2f4a59b50 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -811,7 +811,7 @@ static int zonefs_readdir_zgroup(struct file *file,
 	for (f = ctx->pos - 2; f < zgroup->g_nr_zones; f++) {
 		z = &zgroup->g_zones[f];
 		ino = z->z_sector >> sbi->s_zone_sectors_shift;
-		fname_len = snprintf(fname, ZONEFS_NAME_MAX - 1, "%u", f);
+		fname_len = snprintf(fname, ZONEFS_NAME_MAX - 1, "%d", f);
 		if (!dir_emit(ctx, fname, fname_len, ino, DT_REG))
 			break;
 		ctx->pos++;
-- 
2.17.1




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] zonefs: Fix the wrong format specifier
  2024-11-11  5:41 [PATCH] zonefs: Fix the wrong format specifier Zhu Jun
@ 2024-11-13 17:55 ` Chaitanya Kulkarni
  2024-12-08 23:17 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-11-13 17:55 UTC (permalink / raw)
  To: Zhu Jun, dlemoal; +Cc: naohiro.aota, jth, linux-fsdevel, linux-kernel

On 11/10/24 21:41, Zhu Jun wrote:
> The format specifier of "signed int" in snprintf() should be "%d", not
> "%u".
>
> Signed-off-by: Zhu Jun<zhujun2@cmss.chinamobile.com>

Indeed :-
794         int f;

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] zonefs: Fix the wrong format specifier
  2024-11-11  5:41 [PATCH] zonefs: Fix the wrong format specifier Zhu Jun
  2024-11-13 17:55 ` Chaitanya Kulkarni
@ 2024-12-08 23:17 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2024-12-08 23:17 UTC (permalink / raw)
  To: Zhu Jun; +Cc: naohiro.aota, jth, linux-fsdevel, linux-kernel

On 11/11/24 14:41, Zhu Jun wrote:
> The format specifier of "signed int" in snprintf() should be "%d", not
> "%u".

My apologies for the late reply.

A better fix is to make f "unsigned int" as that is consistent with
g_nr_zones and the fact that up to "unsigned int" total number of zones are
allowed for a zoned device.

Can you send a v2 ? Also please add a Fixes tag.

> 
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.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 faf1eb87895d..43c2f4a59b50 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -811,7 +811,7 @@ static int zonefs_readdir_zgroup(struct file *file,
>  	for (f = ctx->pos - 2; f < zgroup->g_nr_zones; f++) {
>  		z = &zgroup->g_zones[f];
>  		ino = z->z_sector >> sbi->s_zone_sectors_shift;
> -		fname_len = snprintf(fname, ZONEFS_NAME_MAX - 1, "%u", f);
> +		fname_len = snprintf(fname, ZONEFS_NAME_MAX - 1, "%d", f);
>  		if (!dir_emit(ctx, fname, fname_len, ino, DT_REG))
>  			break;
>  		ctx->pos++;


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-08 23:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11  5:41 [PATCH] zonefs: Fix the wrong format specifier Zhu Jun
2024-11-13 17:55 ` Chaitanya Kulkarni
2024-12-08 23:17 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®