aboutsummaryrefslogtreecommitdiff
path: root/sim/m68hc11
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-05-07 21:53:25 -0400
committerMike Frysinger <vapier@gentoo.org>2021-05-07 21:55:27 -0400
commit8a16cc4b934b2dee897837b7c68b9393cfd5ef5a (patch)
treee8d41af2ebe7b86c5f83ea2e014da55dbc961709 /sim/m68hc11
parentf6593c3d4becb7bf53dde35e8adcd63ac2390e0f (diff)
downloadfsf-binutils-gdb-8a16cc4b934b2dee897837b7c68b9393cfd5ef5a.zip
fsf-binutils-gdb-8a16cc4b934b2dee897837b7c68b9393cfd5ef5a.tar.gz
fsf-binutils-gdb-8a16cc4b934b2dee897837b7c68b9393cfd5ef5a.tar.bz2
sim: m68hc11: fix up cycle buffer printing
Make sure the local static buffer is large enough, and simplify the sprintf for merging the fields all into one. This fixes compiler warnings from buf possibly being overflowed.
Diffstat (limited to 'sim/m68hc11')
-rw-r--r--sim/m68hc11/ChangeLog5
-rw-r--r--sim/m68hc11/dv-m68hc11tim.c8
2 files changed, 8 insertions, 5 deletions
diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog
index 1aaa51b..e88f12e 100644
--- a/sim/m68hc11/ChangeLog
+++ b/sim/m68hc11/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-07 Mike Frysinger <vapier@gentoo.org>
+
+ * dv-m68hc11tim.c (cycle_to_string): Increase buf to 128 bytes.
+ Merge two sprintf buf calls.
+
2021-05-06 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_hw_configure): Change %lx to %x in format strings.
diff --git a/sim/m68hc11/dv-m68hc11tim.c b/sim/m68hc11/dv-m68hc11tim.c
index cd8274f..d7bcac3 100644
--- a/sim/m68hc11/dv-m68hc11tim.c
+++ b/sim/m68hc11/dv-m68hc11tim.c
@@ -479,7 +479,8 @@ cycle_to_string (sim_cpu *cpu, signed64 t, int flags)
{
char time_buf[32];
char cycle_buf[32];
- static char buf[64];
+ /* Big enough to handle 64-bit t, time_buf, and cycle_buf. */
+ static char buf[128];
time_buf[0] = 0;
cycle_buf[0] = 0;
@@ -500,10 +501,7 @@ cycle_to_string (sim_cpu *cpu, signed64 t, int flags)
sprintf (cycle_buf, " cycle%s",
(t > 1 ? "s" : ""));
- if (t < LONG_MAX)
- sprintf (buf, "%9lu%s%s", (unsigned long) t, cycle_buf, time_buf);
- else
- sprintf (buf, "%" PRIi64 "%s%s", t, cycle_buf, time_buf);
+ sprintf (buf, "%9" PRIi64 "%s%s", t, cycle_buf, time_buf);
return buf;
}