The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] samples/vfs: fix printf format string for size_t
@ 2025-02-24 14:14 Arnd Bergmann
  2025-02-25 10:56 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2025-02-24 14:14 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton; +Cc: Arnd Bergmann, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

size_t needs a %z format string modifier instead of %l

samples/vfs/test-list-all-mounts.c:152:39: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
  152 |                                         printf("mnt_uidmap[%lu]:\t%s\n", idx, idmap);
      |                                                            ~~~           ^~~
      |                                                            %zu
samples/vfs/test-list-all-mounts.c:161:39: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
  161 |                                         printf("mnt_gidmap[%lu]:\t%s\n", idx, idmap);
      |                                                            ~~~           ^~~
      |                                                            %zu

Fixes: fa204a65f1b6 ("samples/vfs: add STATMOUNT_MNT_{G,U}IDMAP")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 samples/vfs/test-list-all-mounts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/samples/vfs/test-list-all-mounts.c b/samples/vfs/test-list-all-mounts.c
index bb3b83d8f1d7..713c174626aa 100644
--- a/samples/vfs/test-list-all-mounts.c
+++ b/samples/vfs/test-list-all-mounts.c
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
 				const char *idmap = stmnt->str + stmnt->mnt_uidmap;
 
 				for (size_t idx = 0; idx < stmnt->mnt_uidmap_num; idx++) {
-					printf("mnt_uidmap[%lu]:\t%s\n", idx, idmap);
+					printf("mnt_uidmap[%zu]:\t%s\n", idx, idmap);
 					idmap += strlen(idmap) + 1;
 				}
 			}
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
 				const char *idmap = stmnt->str + stmnt->mnt_gidmap;
 
 				for (size_t idx = 0; idx < stmnt->mnt_gidmap_num; idx++) {
-					printf("mnt_gidmap[%lu]:\t%s\n", idx, idmap);
+					printf("mnt_gidmap[%zu]:\t%s\n", idx, idmap);
 					idmap += strlen(idmap) + 1;
 				}
 			}
-- 
2.39.5


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

* Re: [PATCH] samples/vfs: fix printf format string for size_t
  2025-02-24 14:14 [PATCH] samples/vfs: fix printf format string for size_t Arnd Bergmann
@ 2025-02-25 10:56 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2025-02-25 10:56 UTC (permalink / raw)
  To: Jeff Layton, Arnd Bergmann; +Cc: Christian Brauner, Arnd Bergmann, linux-kernel

On Mon, 24 Feb 2025 15:14:00 +0100, Arnd Bergmann wrote:
> size_t needs a %z format string modifier instead of %l
> 
> samples/vfs/test-list-all-mounts.c:152:39: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
>   152 |                                         printf("mnt_uidmap[%lu]:\t%s\n", idx, idmap);
>       |                                                            ~~~           ^~~
>       |                                                            %zu
> samples/vfs/test-list-all-mounts.c:161:39: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
>   161 |                                         printf("mnt_gidmap[%lu]:\t%s\n", idx, idmap);
>       |                                                            ~~~           ^~~
>       |                                                            %zu
> 
> [...]

Applied to the vfs-6.15.mount branch of the vfs/vfs.git tree.
Patches in the vfs-6.15.mount branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.15.mount

[1/1] samples/vfs: fix printf format string for size_t
      https://git.kernel.org/vfs/vfs/c/33cec19dc022

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

end of thread, other threads:[~2025-02-25 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 14:14 [PATCH] samples/vfs: fix printf format string for size_t Arnd Bergmann
2025-02-25 10:56 ` Christian Brauner

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