aboutsummaryrefslogtreecommitdiff
path: root/sim/arm
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/arm
parent5e0a033bd2927a027a5fb2c93d9e403c4f505bd0 (diff)
downloadfsf-binutils-gdb-f08708cbf59ec153eac33d7a2a99ef99f1ca825a.zip
fsf-binutils-gdb-f08708cbf59ec153eac33d7a2a99ef99f1ca825a.tar.gz
fsf-binutils-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/arm')
-rw-r--r--sim/arm/ChangeLog5
-rw-r--r--sim/arm/armdefs.h4
-rw-r--r--sim/arm/wrapper.c4
3 files changed, 10 insertions, 3 deletions
diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index 639942a..54712e3 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-03 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * armdefs.h (ARMul_ConsolePrint): Use format attribute.
+ * wrapper.c (op_printf): Likewise.
+
2021-05-01 Mike Frysinger <vapier@gentoo.org>
* config.in, configure: Regenerate.
diff --git a/sim/arm/armdefs.h b/sim/arm/armdefs.h
index 2b5ff9b..68cf199 100644
--- a/sim/arm/armdefs.h
+++ b/sim/arm/armdefs.h
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <ansidecl.h>
#define FALSE 0
#define TRUE 1
@@ -415,5 +416,6 @@ extern unsigned ARMul_OSHandleSWI (ARMul_State * state, ARMword number);
extern void ARMul_UndefInstr (ARMul_State *, ARMword);
extern void ARMul_FixCPSR (ARMul_State *, ARMword, ARMword);
extern void ARMul_FixSPSR (ARMul_State *, ARMword, ARMword);
-extern void ARMul_ConsolePrint (ARMul_State *, const char *, ...);
+extern void ARMul_ConsolePrint (ARMul_State *, const char *, ...)
+ ATTRIBUTE_PRINTF (2, 3);
extern void ARMul_SelectProcessor (ARMul_State *, unsigned);
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index c89efe4..54a04f4 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -62,8 +62,8 @@ int trace_funcs = 0;
static struct disassemble_info info;
static char opbuf[1000];
-static int
-op_printf (char *buf, char *fmt, ...)
+static int ATTRIBUTE_PRINTF (2, 3)
+op_printf (char *buf, const char *fmt, ...)
{
int ret;
va_list ap;