]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change printf attribute to fix clang build
authorTom Tromey <tromey@adacore.com>
Mon, 15 Apr 2024 15:33:21 +0000 (09:33 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 15 Apr 2024 15:37:12 +0000 (09:37 -0600)
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

index 0120dd034fa391b1bada19a6455d4fac70e03f1c..1462aaf0f89c0582507bffe9395028e16f55bfe0 100644 (file)
@@ -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;