Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: sprinkle some ATTRIBUTE_PRINTF
Date: Thu, 22 Apr 2021 09:43:44 -0400	[thread overview]
Message-ID: <20210422134344.3303416-1-simon.marchi@polymtl.ca> (raw)

Add some ATTRIBUTE_PRINTF attributes to functions that take a format
string, to fix a few -Wformat-nonliteral warnings.  Use the
ATTRIBUTE_PRINTF macro like we use in GDB, instead of spelling out
__attribute__((format...)).  Use ATTRIBUTE_NULL_PRINTF at one place,
because callers expect to be able to pass NULL.

sim/common/ChangeLog:

	* callback.c (os_printf_filtered, os_vprintf_filtered,
	os_evprintf_filtered, os_error): Use ATTRIBUTE_PRINTF.
	* sim-engine.h (sim_engine_abort, sim_engine_vabort): Likewise.
	* sim-events.h (sim_events_schedule_tracef,
	sim_events_schedule_vtracef): Use ATTRIBUTE_NULL_PRINTF.

Change-Id: Icd206f7b2c325e8b144f72eb129fb2a6b5af2fa3
---
 sim/common/callback.c   | 8 ++++----
 sim/common/sim-engine.h | 4 ++--
 sim/common/sim-events.h | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sim/common/callback.c b/sim/common/callback.c
index f9e848fd913d..2fec2704f3e0 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -639,7 +639,7 @@ os_init (host_callback *p)
 /* DEPRECATED */
 
 /* VARARGS */
-static void
+static void ATTRIBUTE_PRINTF (2, 3)
 os_printf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, ...)
 {
   va_list args;
@@ -650,14 +650,14 @@ os_printf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, ...)
 }
 
 /* VARARGS */
-static void
+static void ATTRIBUTE_PRINTF (2, 0)
 os_vprintf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, va_list args)
 {
   vprintf (format, args);
 }
 
 /* VARARGS */
-static void
+static void ATTRIBUTE_PRINTF (2, 0)
 os_evprintf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, va_list args)
 {
   vfprintf (stderr, format, args);
@@ -667,7 +667,7 @@ os_evprintf_filtered (host_callback *p ATTRIBUTE_UNUSED, const char *format, va_
 #ifdef __GNUC__
 __attribute__ ((__noreturn__))
 #endif
-static void
+static void ATTRIBUTE_PRINTF (2, 3)
 os_error (host_callback *p ATTRIBUTE_UNUSED, const char *format, ...)
 {
   va_list args;
diff --git a/sim/common/sim-engine.h b/sim/common/sim-engine.h
index 25d06f774de0..5adce8deedbc 100644
--- a/sim/common/sim-engine.h
+++ b/sim/common/sim-engine.h
@@ -115,14 +115,14 @@ extern void sim_engine_abort
  sim_cpu *cpu,
  sim_cia cia,
  const char *fmt,
- ...) __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
+ ...) ATTRIBUTE_PRINTF (4, 5) __attribute__ ((noreturn));
 
 extern void sim_engine_vabort
 (SIM_DESC sd,
  sim_cpu *cpu,
  sim_cia cia,
  const char *fmt,
- va_list ap) __attribute__ ((noreturn));
+ va_list ap) ATTRIBUTE_PRINTF (4, 0) __attribute__ ((noreturn));
 
 /* No abort hook - when possible this function exits using the
    engine_halt function (and SIM_ENGINE_HALT_HOOK). */
diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h
index 7a5fc9665d21..3f1501ea67cd 100644
--- a/sim/common/sim-events.h
+++ b/sim/common/sim-events.h
@@ -117,7 +117,7 @@ extern sim_event *sim_events_schedule_tracef
  sim_event_handler *handler,
  void *data,
  const char *fmt,
- ...) __attribute__ ((format (printf, 5, 6)));
+ ...) ATTRIBUTE_NULL_PRINTF (5, 6);
 
 extern sim_event *sim_events_schedule_vtracef
 (SIM_DESC sd,
@@ -125,7 +125,7 @@ extern sim_event *sim_events_schedule_vtracef
  sim_event_handler *handler,
  void *data,
  const char *fmt,
- va_list ap);
+ va_list ap) ATTRIBUTE_NULL_PRINTF (5, 0);
 
 
 extern void sim_events_schedule_after_signal
-- 
2.30.1


             reply	other threads:[~2021-04-22 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 13:43 Simon Marchi via Gdb-patches [this message]
2021-04-22 14:21 ` Mike Frysinger via Gdb-patches

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=20210422134344.3303416-1-simon.marchi@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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