]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gprofng format mismatch on 32-bit host
authorAlan Modra <amodra@gmail.com>
Mon, 6 Apr 2026 00:02:06 +0000 (09:32 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 6 Apr 2026 01:01:29 +0000 (10:31 +0930)
On a 32-bit host without --enable-64-bit-bfd

gp-gmon.cc:531:42: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘bfd_size_type’ {aka ‘unsigned int’} [-Wformat=]

On a 32-bit-host with --enable-64-bit-bfd the underlying type will be
unsigned long long.

* src/gp-gmon.cc (gen_gmon_map): Use %llu to print msize, and cast.

gprofng/src/gp-gmon.cc

index d3b4a67f51c3c0b12e8f874409a28cfc03850905..f8a8adb7fc914fea210f75a926d6fd0835be297e 100644 (file)
@@ -528,12 +528,12 @@ gen_gmon_map (char *name)
   msize = (msize + page_size - 1) & mpage;
 
   fprintf (mapx, "<event kind=\"map\" object=\"segment\" tstamp=\"%u.%09u\" "
-          "vaddr=\"0x%016llX\" size=\"%lu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
+          "vaddr=\"0x%016llX\" size=\"%llu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
           "modes=\"0x%03X\" chksum=\"0x%0X\" name=\"%s\"/>\n",
           (unsigned) (timestamp / NANOSEC),
           (unsigned) (timestamp % NANOSEC),
-          (long long unsigned) loadaddr, msize, (int) page_size,
-          offset < 0 ? '-' : '+',
+          (long long unsigned) loadaddr, (long long unsigned) msize,
+          (int) page_size, offset < 0 ? '-' : '+',
           (long long unsigned) (offset < 0 ? -offset : offset),
           modeflags, check, name);