Replace most gcc format attributes by macro GCC_FMT_ATTR (format checking)

Since version 4.4.x, gcc supports additional format attributes.
    __attribute__ ((format (gnu_printf, 1, 2)))
should be used instead of
    __attribute__ ((format (printf, 1, 2))
because QEMU always uses standard format strings (even with mingw32).

The patch replaces format attribute printf / __printf__ by macro
GCC_FMT_ATTR which uses gnu_printf if supported.

It also removes an #ifdef __GNUC__ (not needed any longer).

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Stefan Weil 2010-09-23 21:28:03 +02:00 committed by Blue Swirl
parent 4a2b39d323
commit e5924d8980
10 changed files with 12 additions and 21 deletions

View File

@ -87,11 +87,7 @@ typedef struct QEMUAudioTimeStamp {
} QEMUAudioTimeStamp; } QEMUAudioTimeStamp;
void AUD_vlog (const char *cap, const char *fmt, va_list ap); void AUD_vlog (const char *cap, const char *fmt, va_list ap);
void AUD_log (const char *cap, const char *fmt, ...) void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
#ifdef __GNUC__
__attribute__ ((__format__ (__printf__, 2, 3)))
#endif
;
void AUD_help (void); void AUD_help (void);
void AUD_register_card (const char *name, QEMUSoundCard *card); void AUD_register_card (const char *name, QEMUSoundCard *card);

View File

@ -139,7 +139,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6); abi_long arg5, abi_long arg6);
void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
extern THREAD CPUState *thread_env; extern THREAD CPUState *thread_env;
void cpu_loop(CPUState *env); void cpu_loop(CPUState *env);
char *target_strerror(int err); char *target_strerror(int err);

View File

@ -99,7 +99,7 @@ int do_sigaction(int sig, const struct sigaction *act,
struct sigaction *oact); struct sigaction *oact);
int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss);
void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void qerror(const char *fmt, ...); void qerror(const char *fmt, ...);
void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags); void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags);

View File

@ -84,7 +84,7 @@ int xen_be_bind_evtchn(struct XenDevice *xendev);
void xen_be_unbind_evtchn(struct XenDevice *xendev); void xen_be_unbind_evtchn(struct XenDevice *xendev);
int xen_be_send_notify(struct XenDevice *xendev); int xen_be_send_notify(struct XenDevice *xendev);
void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...) void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
__attribute__ ((format(printf, 3, 4))); GCC_FMT_ATTR(3, 4);
/* actual backend drivers */ /* actual backend drivers */
extern struct XenDevOps xen_console_ops; /* xen_console.c */ extern struct XenDevOps xen_console_ops; /* xen_console.c */

View File

@ -186,7 +186,7 @@ void syscall_init(void);
abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6); abi_long arg5, abi_long arg6);
void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
extern THREAD CPUState *thread_env; extern THREAD CPUState *thread_env;
void cpu_loop(CPUState *env); void cpu_loop(CPUState *env);
char *target_strerror(int err); char *target_strerror(int err);

View File

@ -50,8 +50,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
int monitor_get_fd(Monitor *mon, const char *fdname); int monitor_get_fd(Monitor *mon, const char *fdname);
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap);
void monitor_printf(Monitor *mon, const char *fmt, ...) void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
__attribute__ ((__format__ (__printf__, 2, 3)));
void monitor_print_filename(Monitor *mon, const char *filename); void monitor_print_filename(Monitor *mon, const char *filename);
void monitor_flush(Monitor *mon); void monitor_flush(Monitor *mon);

View File

@ -196,8 +196,7 @@ int qemu_pipe(int pipefd[2]);
/* Error handling. */ /* Error handling. */
void QEMU_NORETURN hw_error(const char *fmt, ...) void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
__attribute__ ((__format__ (__printf__, 1, 2)));
/* IO callbacks. */ /* IO callbacks. */
typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);

View File

@ -31,11 +31,10 @@ void loc_set_cmdline(char **argv, int idx, int cnt);
void loc_set_file(const char *fname, int lno); void loc_set_file(const char *fname, int lno);
void error_vprintf(const char *fmt, va_list ap); void error_vprintf(const char *fmt, va_list ap);
void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_printf_unless_qmp(const char *fmt, ...) void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
__attribute__ ((format(printf, 1, 2)));
void error_print_loc(void); void error_print_loc(void);
void error_set_progname(const char *argv0); void error_set_progname(const char *argv0);
void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
#endif #endif

View File

@ -38,8 +38,7 @@ QError *qerror_from_info(const char *file, int linenr, const char *func,
QString *qerror_human(const QError *qerror); QString *qerror_human(const QError *qerror);
void qerror_print(QError *qerror); void qerror_print(QError *qerror);
void qerror_report_internal(const char *file, int linenr, const char *func, void qerror_report_internal(const char *file, int linenr, const char *func,
const char *fmt, ...) const char *fmt, ...) GCC_FMT_ATTR(4, 5);
__attribute__ ((format(printf, 4, 5)));
#define qerror_report(fmt, ...) \ #define qerror_report(fmt, ...) \
qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
QError *qobject_to_qerror(const QObject *obj); QError *qobject_to_qerror(const QObject *obj);

View File

@ -19,8 +19,7 @@
#include "qstring.h" #include "qstring.h"
QObject *qobject_from_json(const char *string); QObject *qobject_from_json(const char *string);
QObject *qobject_from_jsonf(const char *string, ...) QObject *qobject_from_jsonf(const char *string, ...) GCC_FMT_ATTR(1, 2);
__attribute__((__format__ (__printf__, 1, 2)));
QObject *qobject_from_jsonv(const char *string, va_list *ap); QObject *qobject_from_jsonv(const char *string, va_list *ap);
QString *qobject_to_json(const QObject *obj); QString *qobject_to_json(const QObject *obj);