Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/vfs: fix printf format string for size_t

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>
Link: https://lore.kernel.org/r/20250224141406.1400864-1-arnd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Arnd Bergmann and committed by
Christian Brauner
33cec19d 7a54947e

+2 -2
+2 -2
samples/vfs/test-list-all-mounts.c
··· 149 149 const char *idmap = stmnt->str + stmnt->mnt_uidmap; 150 150 151 151 for (size_t idx = 0; idx < stmnt->mnt_uidmap_num; idx++) { 152 - printf("mnt_uidmap[%lu]:\t%s\n", idx, idmap); 152 + printf("mnt_uidmap[%zu]:\t%s\n", idx, idmap); 153 153 idmap += strlen(idmap) + 1; 154 154 } 155 155 } ··· 158 158 const char *idmap = stmnt->str + stmnt->mnt_gidmap; 159 159 160 160 for (size_t idx = 0; idx < stmnt->mnt_gidmap_num; idx++) { 161 - printf("mnt_gidmap[%lu]:\t%s\n", idx, idmap); 161 + printf("mnt_gidmap[%zu]:\t%s\n", idx, idmap); 162 162 idmap += strlen(idmap) + 1; 163 163 } 164 164 }