mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 19:09:31 +08:00
sim: Suppress non-literal printf warning
Clang generates a warning if the format string of a printf-like function is not a literal ("-Wformat-nonliteral"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). To avoid this warning, this commit now uses vsnprintf to format error message and pass the message to sim_engine_abort function with another printf-style formatting. This patch is mostly authored by Andrew Burgess and slightly modified by Tsukasa OI. Co-authored-by: Andrew Burgess <aburgess@redhat.com> Signed-off-by: Tsukasa OI <research_trasio@irq.a4lg.com>
This commit is contained in:

committed by
Andrew Burgess

parent
25ae9e2659
commit
96894c19ad
@ -437,10 +437,8 @@ void hw_abort
|
|||||||
const char *fmt,
|
const char *fmt,
|
||||||
...) ATTRIBUTE_PRINTF (2, 3) ATTRIBUTE_NORETURN;
|
...) ATTRIBUTE_PRINTF (2, 3) ATTRIBUTE_NORETURN;
|
||||||
|
|
||||||
void hw_vabort
|
extern void hw_vabort (struct hw *me, const char *fmt, va_list ap)
|
||||||
(struct hw *me,
|
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
|
||||||
const char *fmt,
|
|
||||||
va_list ap) ATTRIBUTE_NORETURN;
|
|
||||||
|
|
||||||
void hw_halt
|
void hw_halt
|
||||||
(struct hw *me,
|
(struct hw *me,
|
||||||
|
@ -408,8 +408,11 @@ hw_vabort (struct hw *me,
|
|||||||
const char *fmt,
|
const char *fmt,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
|
int len;
|
||||||
const char *name;
|
const char *name;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
va_list cpy;
|
||||||
|
|
||||||
/* find an identity */
|
/* find an identity */
|
||||||
if (me != NULL && hw_path (me) != NULL && hw_path (me) [0] != '\0')
|
if (me != NULL && hw_path (me) != NULL && hw_path (me) [0] != '\0')
|
||||||
name = hw_path (me);
|
name = hw_path (me);
|
||||||
@ -419,16 +422,19 @@ hw_vabort (struct hw *me,
|
|||||||
name = hw_family (me);
|
name = hw_family (me);
|
||||||
else
|
else
|
||||||
name = "device";
|
name = "device";
|
||||||
/* construct an updated format string */
|
|
||||||
msg = alloca (strlen (name) + strlen (": ") + strlen (fmt) + 1);
|
/* Expand FMT and AP into MSG buffer. */
|
||||||
strcpy (msg, name);
|
va_copy (cpy, ap);
|
||||||
strcat (msg, ": ");
|
len = vsnprintf (NULL, 0, fmt, cpy) + 1;
|
||||||
strcat (msg, fmt);
|
va_end (cpy);
|
||||||
|
msg = alloca (len);
|
||||||
|
vsnprintf (msg, len, fmt, ap);
|
||||||
|
|
||||||
/* report the problem */
|
/* report the problem */
|
||||||
sim_engine_vabort (hw_system (me),
|
sim_engine_abort (hw_system (me),
|
||||||
STATE_HW (hw_system (me))->cpu,
|
STATE_HW (hw_system (me))->cpu,
|
||||||
STATE_HW (hw_system (me))->cia,
|
STATE_HW (hw_system (me))->cia,
|
||||||
msg, ap);
|
"%s: %s", name, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user