chew.c printf of intptr_t
authorAlan Modra <amodra@gmail.com>
Tue, 28 Feb 2023 00:34:33 +0000 (11:04 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 28 Feb 2023 00:36:41 +0000 (11:06 +1030)
Seen when building binutils with gcc -m32 on x86_64-linux.
chew.c: In function ‘print’:
chew.c:1434:59: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘intptr_t’ {aka ‘int’} [-Wformat=]
 1434 |     fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
      |                                                         ~~^      ~~~~
      |                                                           |      |
      |                                                           |      intptr_t {aka int}
      |                                                           long int
      |                                                         %d

* chew.c: Include inttypes.h.
(print): Use PRIdPTR for *isp.

bfd/doc/chew.c

index e8478969d64b46d5e21291eaf3b9744bb683d66e..5257bf423610f7fc29260f4c6eac06db40e3bdee 100644 (file)
@@ -91,6 +91,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <inttypes.h>
 
 #define DEF_SIZE 5000
 #define STACK 50
@@ -1431,7 +1432,7 @@ print (void)
   else if (*isp == 2)
     write_buffer (tos, stderr);
   else
-    fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
+    fprintf (stderr, "print: illegal print destination `%" PRIdPTR "'\n", *isp);
   isp--;
   tos--;
   icheck_range ();