aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-05-03 10:54:08 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-05-03 10:55:25 -0400
commitf08708cbf59ec153eac33d7a2a99ef99f1ca825a (patch)
treed5262053baa03a20bedc5d9b8b74b1c968e37a3e /sim/common
parent5e0a033bd2927a027a5fb2c93d9e403c4f505bd0 (diff)
downloadgdb-f08708cbf59ec153eac33d7a2a99ef99f1ca825a.zip
gdb-f08708cbf59ec153eac33d7a2a99ef99f1ca825a.tar.gz
gdb-f08708cbf59ec153eac33d7a2a99ef99f1ca825a.tar.bz2
sim: add ATTRIBUTE_PRINTF / ATTRIBUTE_NULL_PRINTF where necessary
I finally got the all-targets sim building with Clang, these are all the instances where an ATTRIBUTE_PRINTF or ATTRIBUTE_NULL_PRINTF attribute needed to be added to avoid errors like: /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-profile.c:464:19: error: format string is not a string literal [-Werror,-Wformat-nonliteral] vfprintf (fp, fmt, ap); ^~~ There are more fixes needed to get everything building, but adding these attributes is trivial enough, so I send them all in a single patch. Adding the format attributes introduces some format string errors when building with GCC (because now format strings are checked), so corresponding changes are needed to avoid breaking the build. Other than simple format string specified changes, there is this one: /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c: In function 'hw_event_queue_schedule': /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c:95:15: error: too many arguments for format [-Werror=format-extra-args] 95 | NULL, dummy); | ^~~~~ We can fix it and avoid using a dummy variable by simply calling hw_event_queue_schedule_tracef instead of hw_event_queue_schedule_vtracef. sim/arm/ChangeLog: * armdefs.h (ARMul_ConsolePrint): Use format attribute. * wrapper.c (op_printf): Likewise. sim/bfin/ChangeLog: * interp.c (sim_open): Adjust format string specifier. sim/common/ChangeLog: * hw-events.h (hw_event_queue_schedule_tracef): Use format attribute. (hw_event_queue_schedule_vtracef): Likewise. * hw-tree.h (hw_tree_vparse): Likewise. * sim-profile.c (profile_vprintf): Likewise. * sim-trace.c (dis_printf): Likewise. * sim-trace.h (trace_printf): Likewise. (trace_vprintf): Likewise. * sim-utils.h (sim_do_commandf): Likewise. * hw-events.c (hw_event_queue_schedule): Use hw_event_queue_schedule_tracef. sim/rx/ChangeLog: * trace.c (op_printf): Likewise. sim/v850/ChangeLog: * interp.c (sim_open): Adjust format string specifier. Change-Id: I1445115ce57db15bb8e35dca93014555e7555794
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog13
-rw-r--r--sim/common/hw-events.c7
-rw-r--r--sim/common/hw-events.h4
-rw-r--r--sim/common/hw-tree.h2
-rw-r--r--sim/common/sim-profile.c2
-rw-r--r--sim/common/sim-trace.c2
-rw-r--r--sim/common/sim-trace.h5
-rw-r--r--sim/common/sim-utils.h3
8 files changed, 24 insertions, 14 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index fd9a5dd..17b711c 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,16 @@
+2021-05-03 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * hw-events.h (hw_event_queue_schedule_tracef): Use format attribute.
+ (hw_event_queue_schedule_vtracef): Likewise.
+ * hw-tree.h (hw_tree_vparse): Likewise.
+ * sim-profile.c (profile_vprintf): Likewise.
+ * sim-trace.c (dis_printf): Likewise.
+ * sim-trace.h (trace_printf): Likewise.
+ (trace_vprintf): Likewise.
+ * sim-utils.h (sim_do_commandf): Likewise.
+ * hw-events.c (hw_event_queue_schedule): Use
+ hw_event_queue_schedule_tracef.
+
2021-05-02 Simon Marchi <simon.marchi@polymtl.ca>
* sim-options.c (standard_option_handler): Add default cases to
diff --git a/sim/common/hw-events.c b/sim/common/hw-events.c
index 1c749dd..81628f0 100644
--- a/sim/common/hw-events.c
+++ b/sim/common/hw-events.c
@@ -88,12 +88,7 @@ hw_event_queue_schedule (struct hw *me,
hw_event_callback *callback,
void *data)
{
- struct hw_event *event;
- va_list dummy;
- memset (&dummy, 0, sizeof dummy);
- event = hw_event_queue_schedule_vtracef (me, delta_time, callback, data,
- NULL, dummy);
- return event;
+ return hw_event_queue_schedule_tracef (me, delta_time, callback, data, NULL);
}
struct hw_event *
diff --git a/sim/common/hw-events.h b/sim/common/hw-events.h
index 901063b..51ca5bd 100644
--- a/sim/common/hw-events.h
+++ b/sim/common/hw-events.h
@@ -39,7 +39,7 @@ struct hw_event *hw_event_queue_schedule_tracef
hw_event_callback *handler,
void *data,
const char *fmt,
- ...) ATTRIBUTE_PRINTF (5, 6);
+ ...) ATTRIBUTE_NULL_PRINTF (5, 6);
struct hw_event *hw_event_queue_schedule_vtracef
(struct hw *me,
@@ -47,7 +47,7 @@ struct hw_event *hw_event_queue_schedule_vtracef
hw_event_callback *handler,
void *data,
const char *fmt,
- va_list ap);
+ va_list ap) ATTRIBUTE_NULL_PRINTF (5, 0);
void hw_event_queue_deschedule
diff --git a/sim/common/hw-tree.h b/sim/common/hw-tree.h
index 86ebf17..85c91ad 100644
--- a/sim/common/hw-tree.h
+++ b/sim/common/hw-tree.h
@@ -39,7 +39,7 @@ struct hw *hw_tree_parse
struct hw *hw_tree_vparse
(struct hw *root,
const char *fmt,
- va_list ap);
+ va_list ap) ATTRIBUTE_PRINTF (2, 0);
void hw_tree_finish
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index 75bdc70..455e1a2 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -454,7 +454,7 @@ profile_option_handler (SIM_DESC sd,
/* Profiling output hooks. */
-static void
+static void ATTRIBUTE_PRINTF (3, 0)
profile_vprintf (SIM_DESC sd, sim_cpu *cpu, const char *fmt, va_list ap)
{
FILE *fp = PROFILE_FILE (CPU_PROFILE_DATA (cpu));
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index 5f161da..26d9556 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -889,7 +889,7 @@ dis_read (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length,
return 0;
}
-static int
+static int ATTRIBUTE_PRINTF (2, 3)
dis_printf (SIM_CPU *cpu, const char *fmt, ...)
{
SIM_DESC sd = CPU_STATE (cpu);
diff --git a/sim/common/sim-trace.h b/sim/common/sim-trace.h
index 7ff7b02..c89084e 100644
--- a/sim/common/sim-trace.h
+++ b/sim/common/sim-trace.h
@@ -653,9 +653,10 @@ do { \
extern void trace_printf (SIM_DESC, sim_cpu *, const char *, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF (3, 4);
-extern void trace_vprintf (SIM_DESC, sim_cpu *, const char *, va_list);
+extern void trace_vprintf (SIM_DESC, sim_cpu *, const char *, va_list)
+ ATTRIBUTE_PRINTF (3, 0);
/* Debug support.
This is included here because there isn't enough of it to justify
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
index f089245..9cc19f5 100644
--- a/sim/common/sim-utils.h
+++ b/sim/common/sim-utils.h
@@ -68,7 +68,8 @@ struct bfd *sim_load_file (SIM_DESC sd, const char *myname,
int lma_p, sim_write_fn do_load);
/* Internal version of sim_do_command, include formatting */
-void sim_do_commandf (SIM_DESC sd, const char *fmt, ...);
+void sim_do_commandf (SIM_DESC sd, const char *fmt, ...)
+ ATTRIBUTE_PRINTF (2, 3);
/* These are defined in callback.c as cover functions to the vprintf