[PATCH] orangefs: bufmap: fix size_t format string

Arnd Bergmann posted 1 patch 2 months ago
fs/orangefs/orangefs-bufmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] orangefs: bufmap: fix size_t format string
Posted by Arnd Bergmann 2 months ago
From: Arnd Bergmann <arnd@arndb.de>

One of the printk() formats was accidentally changed from %zd to
%ld, causing a build time warning on 32-bit targets:

In file included  from fs/orangefs/orangefs-bufmap.c:7:
fs/orangefs/orangefs-bufmap.c: In function 'orangefs_bufmap_copy_to_iovec':
include/linux/kern_levels.h:5:25: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
fs/orangefs/orangefs-bufmap.c:759:29: note: in expansion of macro 'pr_info'
  759 |         if (size > 4194304) pr_info("%s: size:%ld\n", __func__, size);
      |                             ^~~~~~~

Change this back to the correct version.

Fixes: df6fd4485d7a ("bufmap: manage as folios.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/orangefs/orangefs-bufmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index d476bd4df37c..122526f26b19 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -756,7 +756,7 @@ int orangefs_bufmap_copy_to_iovec(struct iov_iter *iter,
 	from = &__orangefs_bufmap->desc_array[buffer_index];
 
 	/* shouldn't happen... */
-	if (size > 4194304) pr_info("%s: size:%ld\n", __func__, size);
+	if (size > 4194304) pr_info("%s: size:%zd\n", __func__, size);
 
 	gossip_debug(GOSSIP_BUFMAP_DEBUG,
 		"%s: buffer_index:%d size:%zu folio_count:%d\n",
-- 
2.39.5
Re: [PATCH] orangefs: bufmap: fix size_t format string
Posted by Mike Marshall 2 months ago
Thanks Arnd...

I made a V2 of my patch, you suggested %zd,
I used %zu which I think is OK too. I added
some suggestions from Dan Williams to my
V2 as well, I'll post the V2 version as soon as
xfstests completes and I update my linux-next...

-Mike

On Mon, Apr 13, 2026 at 4:09 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> One of the printk() formats was accidentally changed from %zd to
> %ld, causing a build time warning on 32-bit targets:
>
> In file included  from fs/orangefs/orangefs-bufmap.c:7:
> fs/orangefs/orangefs-bufmap.c: In function 'orangefs_bufmap_copy_to_iovec':
> include/linux/kern_levels.h:5:25: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
> fs/orangefs/orangefs-bufmap.c:759:29: note: in expansion of macro 'pr_info'
>   759 |         if (size > 4194304) pr_info("%s: size:%ld\n", __func__, size);
>       |                             ^~~~~~~
>
> Change this back to the correct version.
>
> Fixes: df6fd4485d7a ("bufmap: manage as folios.")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/orangefs/orangefs-bufmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
> index d476bd4df37c..122526f26b19 100644
> --- a/fs/orangefs/orangefs-bufmap.c
> +++ b/fs/orangefs/orangefs-bufmap.c
> @@ -756,7 +756,7 @@ int orangefs_bufmap_copy_to_iovec(struct iov_iter *iter,
>         from = &__orangefs_bufmap->desc_array[buffer_index];
>
>         /* shouldn't happen... */
> -       if (size > 4194304) pr_info("%s: size:%ld\n", __func__, size);
> +       if (size > 4194304) pr_info("%s: size:%zd\n", __func__, size);
>
>         gossip_debug(GOSSIP_BUFMAP_DEBUG,
>                 "%s: buffer_index:%d size:%zu folio_count:%d\n",
> --
> 2.39.5
>