public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [pushed] Change printf attribute to fix clang build
Date: Mon, 15 Apr 2024 09:36:48 -0600	[thread overview]
Message-ID: <20240415153648.2270383-1-tromey@adacore.com> (raw)

commit e8cd90f0 ("Rewrite gdb_bfd_error_handler") broke the clang
build.

The problem here is that print_error_callback isn't marked as being
printf-like, but it calls string_file::vprintf, triggering:

../../binutils-gdb/gdb/gdb_bfd.c:1202:18: error: format string is not a string literal [-Werror,-Wformat-nonliteral]

This patch applies the attribute to this function.

It also removes the attribute from gdb_bfd_error_handler, because that
function is no longer really printf-like.
---
 gdb/gdb_bfd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 0120dd034fa..1462aaf0f89 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -1192,7 +1192,7 @@ increment_bfd_error_count (const std::string &str)
 
 /* A print callback for bfd_print_error.  */
 
-static int
+static int ATTRIBUTE_PRINTF (2, 0)
 print_error_callback (void *stream, const char *fmt, ...)
 {
   string_file *file = (string_file *) stream;
@@ -1208,7 +1208,7 @@ print_error_callback (void *stream, const char *fmt, ...)
    messages which have been printed once already.  This is done on a
    per-inferior basis.  */
 
-static void ATTRIBUTE_PRINTF (1, 0)
+static void
 gdb_bfd_error_handler (const char *fmt, va_list ap)
 {
   string_file output;
-- 
2.43.0


                 reply	other threads:[~2024-04-15 15:36 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=20240415153648.2270383-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@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).