]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: fix printf format specifiers on 32-bit platforms
authorDarrick J. Wong <djwong@kernel.org>
Fri, 12 Aug 2022 18:39:25 +0000 (13:39 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 12 Aug 2022 18:39:25 +0000 (13:39 -0500)
armv7l builds spit out the following warnings:

In file included from ../include/platform_defs.h:44,
                 from ../include/libxfs.h:13,
                 from bmap.c:7:
bmap.c: In function ‘blkmap_alloc’:
bmap.c:41:11: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘xfs_extnum_t’ {aka ‘long long unsigned int’} [-Werror=format=]
   41 |         _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n"
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bmap.c:41:9: note: in expansion of macro ‘_’
   41 |         _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n"
      |         ^
bmap.c:41:58: note: format string is defined here
   41 |         _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n"
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %lld
In file included from ../include/platform_defs.h:44,
                 from ../include/libxfs.h:13,
                 from bmap.c:7:
bmap.c:54:35: error: format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘xfs_extnum_t’ {aka ‘long long unsigned int’} [-Werror=format=]
   54 |                         do_warn(_("malloc failed in blkmap_alloc (%zu bytes)\n"),
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bmap.c:54:33: note: in expansion of macro ‘_’
   54 |                         do_warn(_("malloc failed in blkmap_alloc (%zu bytes)\n"),
      |                                 ^
bmap.c:54:69: note: format string is defined here
   54 |                         do_warn(_("malloc failed in blkmap_alloc (%zu bytes)\n"),
      |                                                                   ~~^
      |                                                                     |
      |                                                                     unsigned int
      |                                                                   %llu

Fix these.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
logprint/log_misc.c
repair/bmap.c

index 82e1f682fd622c071d1c969637823dac781e5d17..836156e0d58628564be10399080cd73b04bd2ead 100644 (file)
@@ -493,16 +493,16 @@ xlog_print_trans_inode_core(
        nextents = ip->di_big_nextents;
     else
        nextents = ip->di_nextents;
-    printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%lx\n"),
+    printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%llx\n"),
           (unsigned long long)ip->di_size, (unsigned long long)ip->di_nblocks,
-          ip->di_extsize, nextents);
+          ip->di_extsize, (unsigned long long)nextents);
 
     if (ip->di_flags2 & XFS_DIFLAG2_NREXT64)
        nextents = ip->di_big_anextents;
     else
        nextents = ip->di_anextents;
-    printf(_("naextents 0x%lx forkoff %d dmevmask 0x%x dmstate 0x%hx\n"),
-          nextents, (int)ip->di_forkoff, ip->di_dmevmask, ip->di_dmstate);
+    printf(_("naextents 0x%llx forkoff %d dmevmask 0x%x dmstate 0x%hx\n"),
+          (unsigned long long)nextents, (int)ip->di_forkoff, ip->di_dmevmask, ip->di_dmstate);
     printf(_("flags 0x%x gen 0x%x\n"),
           ip->di_flags, ip->di_gen);
     if (ip->di_version == 3) {
index 44e43ab48b4298b377093f634699f1da9473d75e..cd1a8b07b301ae095a9553071e3f96e06d110143 100644 (file)
@@ -38,10 +38,10 @@ blkmap_alloc(
 #if (BITS_PER_LONG == 32)      /* on 64-bit platforms this is never true */
        if (nex > BLKMAP_NEXTS_MAX) {
                do_warn(
-       _("Number of extents requested in blkmap_alloc (%d) overflows 32 bits.\n"
+       _("Number of extents requested in blkmap_alloc (%llu) overflows 32 bits.\n"
          "If this is not a corruption, then you will need a 64 bit system\n"
          "to repair this filesystem.\n"),
-                       nex);
+                       (unsigned long long)nex);
                return NULL;
        }
 #endif
@@ -51,8 +51,8 @@ blkmap_alloc(
        if (!blkmap || blkmap->naexts < nex) {
                blkmap = realloc(blkmap, BLKMAP_SIZE(nex));
                if (!blkmap) {
-                       do_warn(_("malloc failed in blkmap_alloc (%zu bytes)\n"),
-                               BLKMAP_SIZE(nex));
+                       do_warn(_("malloc failed in blkmap_alloc (%llu bytes)\n"),
+                               (unsigned long long)BLKMAP_SIZE(nex));
                        return NULL;
                }
                pthread_setspecific(key, blkmap);