public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] chew.c printf of intptr_t
Date: Tue, 28 Feb 2023 00:38:26 +0000 (GMT)	[thread overview]
Message-ID: <20230228003826.4A0843858C62@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=26c294bd1b8d95b421487294863eb1560b65580d

commit 26c294bd1b8d95b421487294863eb1560b65580d
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Feb 28 11:04:33 2023 +1030

    chew.c printf of intptr_t
    
    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.

Diff:
---
 bfd/doc/chew.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index e8478969d64..5257bf42361 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -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 ();

                 reply	other threads:[~2023-02-28  0:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230228003826.4A0843858C62@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).