Skip to content

Commit

Permalink
samples/vfs: fix printf format string for size_t
Browse files Browse the repository at this point in the history
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: fa204a6 ("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>
  • Loading branch information
Arnd Bergmann authored and Christian Brauner committed Feb 25, 2025
1 parent 7a54947 commit 33cec19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/vfs/test-list-all-mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 33cec19

Please sign in to comment.