const char *fmt,
...) ATTRIBUTE_PRINTF (2, 3) ATTRIBUTE_NORETURN;
-void hw_vabort
-(struct hw *me,
- const char *fmt,
- va_list ap) ATTRIBUTE_NORETURN;
+extern void hw_vabort (struct hw *me, const char *fmt, va_list ap)
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
void hw_halt
(struct hw *me,
const char *fmt,
va_list ap)
{
+ int len;
const char *name;
char *msg;
+ va_list cpy;
+
/* find an identity */
if (me != NULL && hw_path (me) != NULL && hw_path (me) [0] != '\0')
name = hw_path (me);
name = hw_family (me);
else
name = "device";
- /* construct an updated format string */
- msg = alloca (strlen (name) + strlen (": ") + strlen (fmt) + 1);
- strcpy (msg, name);
- strcat (msg, ": ");
- strcat (msg, fmt);
+
+ /* Expand FMT and AP into MSG buffer. */
+ va_copy (cpy, ap);
+ len = vsnprintf (NULL, 0, fmt, cpy) + 1;
+ va_end (cpy);
+ msg = alloca (len);
+ vsnprintf (msg, len, fmt, ap);
+
/* report the problem */
- sim_engine_vabort (hw_system (me),
- STATE_HW (hw_system (me))->cpu,
- STATE_HW (hw_system (me))->cia,
- msg, ap);
+ sim_engine_abort (hw_system (me),
+ STATE_HW (hw_system (me))->cpu,
+ STATE_HW (hw_system (me))->cia,
+ "%s: %s", name, msg);
}
void