sim: callback: add printf attributes

This helps these funcs get printf format checking coverage.

The sim-io.c hack as a result is a bit unfortunate, but the compiler
throws warnings when printing with empty strings.  In this one case,
we actually want that due to the side-effect of the callback halting
execution for us.
This commit is contained in:
Mike Frysinger
2021-06-27 23:21:26 -04:00
parent 54e66d16e8
commit a1d9117f94
4 changed files with 20 additions and 5 deletions

View File

@@ -1,3 +1,8 @@
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* sim/callback.h (struct host_callback_struct): Add ATTRIBUTE_PRINTF
to printf functions.
2021-06-24 Mike Frysinger <vapier@gentoo.org>
* sim/callback.h (struct host_callback_struct): Add arg5, arg6, and

View File

@@ -113,18 +113,22 @@ struct host_callback_struct
int (*init) (host_callback *);
/* depreciated, use vprintf_filtered - Talk to the user on a console. */
void (*printf_filtered) (host_callback *, const char *, ...);
void (*printf_filtered) (host_callback *, const char *, ...)
ATTRIBUTE_PRINTF_2;
/* Talk to the user on a console. */
void (*vprintf_filtered) (host_callback *, const char *, va_list);
void (*vprintf_filtered) (host_callback *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
/* Same as vprintf_filtered but to stderr. */
void (*evprintf_filtered) (host_callback *, const char *, va_list);
void (*evprintf_filtered) (host_callback *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
/* Print an error message and "exit".
In the case of gdb "exiting" means doing a longjmp back to the main
command loop. */
void (*error) (host_callback *, const char *, ...) ATTRIBUTE_NORETURN;
void (*error) (host_callback *, const char *, ...)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_2;
int last_errno; /* host format */