* [PATCH] sim: sprinkle some ATTRIBUTE_PRINTF
@ 2021-04-22 13:43 Simon Marchi via Gdb-patches
2021-04-22 14:21 ` Mike Frysinger via Gdb-patches
0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi via Gdb-patches @ 2021-04-22 13:43 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] sim: sprinkle some ATTRIBUTE_PRINTF
2021-04-22 13:43 [PATCH] sim: sprinkle some ATTRIBUTE_PRINTF Simon Marchi via Gdb-patches
@ 2021-04-22 14:21 ` Mike Frysinger via Gdb-patches
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-04-22 14:21 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On 22 Apr 2021 09:43, Simon Marchi via Gdb-patches wrote:
> 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.
lgtm, thanks
-mike
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-22 14:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 13:43 [PATCH] sim: sprinkle some ATTRIBUTE_PRINTF Simon Marchi via Gdb-patches
2021-04-22 14:21 ` Mike Frysinger via Gdb-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox