Replace most gcc format attributes by macro GCC_FMT_ATTR (format checking)
PATCH 1/3 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).
--- audio/audio.h | 6 +----- bsd-user/qemu.h | 2 +- darwin-user/qemu.h | 2 +- hw/xen_backend.h | 2 +- linux-user/qemu.h | 2 +- monitor.h | 3 +-- qemu-common.h | 3 +-- qemu-error.h | 7 +++---- qerror.h | 3 +-- qjson.h | 3 +-- 10 files changed, 12 insertions(+), 21 deletions(-)
audio/audio.h +1 -5
@@ -87,11 +87,7 @@ typedef struct QEMUAudioTimeStamp { } QEMUAudioTimeStamp;void AUD_vlog (const char *cap,const char *fmt,va_list ap); -void AUD_log (const char *cap,const char *fmt, ...) -#ifdef __GNUC__ - __attribute__ ((__format__ (__printf__,2 ,3 ))) -#endif - ; +void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void AUD_help (void );void AUD_register_card (const char *name,QEMUSoundCard *card);
bsd-user/qemu.h +1 -1
@@ -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 arg2,abi_long arg3,abi_long arg4,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;void cpu_loop (CPUState *env);char *target_strerror (int err);
darwin-user/qemu.h +1 -1
@@ -99,7 +99,7 @@ int do_sigaction(int sig, const struct sigaction *act, struct sigaction *oact);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 write_dt (void *ptr,unsigned long addr,unsigned long limit,int flags);
hw/xen_backend.h +1 -1
@@ -84,7 +84,7 @@ int xen_be_bind_evtchn(struct XenDevice *xendev);void xen_be_unbind_evtchn (struct XenDevice *xendev);int xen_be_send_notify (struct XenDevice *xendev); 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 */ extern struct XenDevOps xen_console_ops;/* xen_console.c */
linux-user/qemu.h +1 -1
@@ -186,7 +186,7 @@ void syscall_init(void);abi_long do_syscall (void *cpu_env,int num,abi_long arg1,abi_long arg2,abi_long arg3,abi_long arg4,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;void cpu_loop (CPUState *env);char *target_strerror (int err);
monitor.h +1 -2
@@ -50,8 +50,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,int monitor_get_fd (Monitor *mon,const char *fdname);void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap); -void monitor_printf (Monitor *mon,const char *fmt, ...) - __attribute__ ((__format__ (__printf__,2 ,3 ))); +void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon);
qemu-common.h +1 -2
@@ -196,8 +196,7 @@ int qemu_pipe(int pipefd[2]);/* Error handling. */ -void QEMU_NORETURN hw_error(const char *fmt, ...) - __attribute__ ((__format__ (__printf__,1 ,2 ))); +void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);/* IO callbacks. */ typedef void IOReadHandler (void *opaque,const uint8_t *buf,int size);
qemu-error.h +3 -4
@@ -31,11 +31,10 @@ void loc_set_cmdline(char **argv, int idx, int cnt);void loc_set_file (const char *fname,int lno);void error_vprintf (const char *fmt,va_list ap); -void error_printf (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 ))); -void error_printf_unless_qmp (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, ...) GCC_FMT_ATTR(1, 2);void error_print_loc (void );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
qerror.h +1 -2
@@ -38,8 +38,7 @@ QError *qerror_from_info(const char *file, int linenr, const char *func,QString *qerror_human (const QError *qerror);void qerror_print (QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func, -const char *fmt, ...) - __attribute__ ((format (printf,4 ,5 ))); + const char *fmt, ...) GCC_FMT_ATTR(4, 5);#define qerror_report (fmt, ...) \ qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)QError *qobject_to_qerror (const QObject *obj);
qjson.h +1 -2
@@ -19,8 +19,7 @@#include "qstring.h" QObject *qobject_from_json (const char *string); -QObject *qobject_from_jsonf (const char *string, ...) - __attribute__((__format__ (__printf__,1 ,2 ))); +QObject *qobject_from_jsonf (const char *string, ...)GCC_FMT_ATTR (1 ,2 );QObject *qobject_from_jsonv (const char *string,va_list *ap);QString *qobject_to_json (const QObject *obj);
Signature · 1 line
1.7.1
PATCH 2/3 Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)
Replace the remaining format attribute printf by macro GCC_FMT_ATTR which uses gnu_printf (if supported).
This needs additional code changes:
* Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
* Remove standard includes when qemu-common.h was added. qemu-common.h already provides these includes.
* Remove local definitions which now come from stdio.h. These definitions were needed before tcg was introduced. They raise conflicts when qemu-common.h is included.
--- cpu-all.h | 2 +- cpu-exec.c | 2 ++ dyngen-exec.h | 9 --------- target-alpha/op_helper.c | 1 + target-arm/op_helper.c | 2 ++ target-cris/op_helper.c | 1 + target-i386/op_helper.c | 1 + target-m68k/op_helper.c | 2 ++ target-microblaze/op_helper.c | 2 +- target-mips/op_helper.c | 3 ++- target-ppc/op_helper.c | 3 ++- target-sh4/op_helper.c | 4 ++-- target-sparc/op_helper.c | 1 + 13 files changed, 18 insertions(+), 15 deletions(-)
cpu-all.h +1 -1
@@ -773,7 +773,7 @@ void cpu_dump_statistics (CPUState *env, FILE *f, int flags); void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) - __attribute__ ((__format__ (__printf__,2 ,3 ))); + GCC_FMT_ATTR(2, 3);extern CPUState *first_cpu;extern CPUState *cpu_single_env;
cpu-exec.c +2 -0
@@ -16,6 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu-common.h" #include "config.h" #include "exec.h" #include "disas.h"
dyngen-exec.h +0 -9
@@ -40,15 +40,6 @@/* XXX: This may be wrong for 64-bit ILP32 hosts. */ typedef void *host_reg_t ; -#ifdef CONFIG_BSD -typedef struct __sFILE FILE ; -#else -typedef struct FILE FILE ; -#endif -extern int fprintf (FILE *,const char *, ...); -extern int fputs (const char *,FILE *); -extern int printf (const char *, ...); -#if defined(__i386__)#define AREG0 "ebp"#elif defined(__x86_64__)
target-alpha/op_helper.c +1 -0
@@ -17,6 +17,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu-common.h" #include "exec.h" #include "host-utils.h" #include "softfloat.h"
target-arm/op_helper.c +2 -0
@@ -16,6 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu-common.h" #include "exec.h" #include "helpers.h"
target-cris/op_helper.c +1 -0
@@ -18,6 +18,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu-common.h" #include "exec.h" #include "mmu.h" #include "helper.h"
target-i386/op_helper.c +1 -0
@@ -17,6 +17,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu-common.h" #include "exec.h" #include "exec-all.h" #include "host-utils.h"
target-m68k/op_helper.c +2 -0
@@ -16,6 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu-common.h" #include "exec.h" #include "helpers.h"
target-microblaze/op_helper.c +1 -1
@@ -17,7 +17,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <assert.h> +#include "qemu-common.h" #include "exec.h" #include "helper.h" #include "host-utils.h"
target-mips/op_helper.c +2 -1
@@ -16,7 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> + +#include "qemu-common.h" #include "exec.h" #include "host-utils.h"
target-ppc/op_helper.c +2 -1
@@ -16,7 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <string.h> + +#include "qemu-common.h" #include "exec.h" #include "host-utils.h" #include "helper.h"
target-sh4/op_helper.c +2 -2
@@ -16,8 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <assert.h> -#include <stdlib.h> + +#include "qemu-common.h" #include "exec.h" #include "helper.h"
target-sparc/op_helper.c +1 -0
@@ -1,3 +1,4 @@ +#include "qemu-common.h" #include "exec.h" #include "host-utils.h" #include "helper.h"
Signature · 1 line
1.7.1
[Qemu-devel] Re: [PATCH 2/3] Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)
Quoted 5 lines · Stefan Weil
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.
IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
[Qemu-devel] Re: [PATCH 2/3] Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 15 lines · Stefan Weil
Quoted 5 lines
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.
Quoted 6 lines
IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
For linux and win32, I did not notice problems caused by these changes.
[Qemu-devel] Re: [PATCH 2/3] Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)
Quoted 21 lines · Stefan Weil
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 20 lines · Stefan Weil
Quoted 6 lines
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
Quoted 8 lines
Quoted 3 lines
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
One explanation is that the code in target-*/op_helper.c may assume that env/AREG0 is always available but since library functions may clobber that, we want to hide them.
Quoted 1 line
For linux and win32, I did not notice problems caused by these changes.
It looks like that code has origins in one of the very first patches, r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from exec-i386.h to dyngen-exec.h by r236 or 79638566e5b87058e92f537b989df0dbc23f8b41. R997 or 1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system headers. The commits around that add OS X support, maybe the problem was there?
[Qemu-devel] [RFC] Can we remove special handling of standard headers (introduced for dyngen / OSX?)
Am 25.09.2010 09:46, schrieb Blue Swirl:
Quoted 37 lines · Stefan Weil
Quoted 21 lines
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 20 lines · Stefan Weil
Quoted 6 lines
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
Quoted 8 lines
Quoted 3 lines
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
One explanation is that the code in
target-*/op_helper.cmay assume that env/AREG0 is always available but since library functions may clobber that, we want to hide them.Quoted 1 line
For linux and win32, I did not notice problems caused by these changes.
Quoted 7 lines
It looks like that code has origins in one of the very first patches, r16 or
ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved fromexec-i386.htodyngen-exec.hby r236 or79638566e5b87058e92f537b989df0dbc23f8b41. R997 or1e6cae953d6a37216359b79e05d23e1bf4dc6bbeadded a warning about system headers. The commits around that add OS X support, maybe the problem was there?
Current qemu code includes several locations where standard headers like stdio.h are forbidden. See qemu-common.h (__DYNGEN_EXEC_H__), dyngen-exec.h, cris-dis.h and perhaps more examples of this restriction.
Who knows the reason for this restriction? Was it use of global registers with dyngen? Was it needed only for certain hosts (maybe OSX) or old versions of gcc?
Most important: Is this restriction still needed?
It would simplify things like common declarations and also allow cleaner code (without private declarations for FILE etc.) if we could remove this restriction.
In my personal test environment (gcc-4.x, linux on different hosts, win32) the restriction was not needed.
Regards,
Stefan
Andreas Färber
Tested-byRe: [Qemu-devel] [RFC] Can we remove special handling of standard headers (introduced for dyngen / OSX?)
Am 04.10.2010 um 21:29 schrieb Stefan Weil:
Quoted 56 lines
Am 25.09.2010 09:46, schrieb Blue Swirl:
Quoted 37 lines · Stefan Weil
Quoted 21 lines
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 20 lines · Stefan Weil
Quoted 6 lines
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
Quoted 8 lines
Quoted 3 lines
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
One explanation is that the code in
target-*/op_helper.cmay assume that env/AREG0 is always available but since library functions may clobber that, we want to hide them.Quoted 1 line
For linux and win32, I did not notice problems caused by these changes.
Quoted 7 lines
It looks like that code has origins in one of the very first patches, r16 or
ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved fromexec-i386.htodyngen-exec.hby r236 or79638566e5b87058e92f537b989df0dbc23f8b41. R997 or1e6cae953d6a37216359b79e05d23e1bf4dc6bbeadded a warning about system headers. The commits around that add OS X support, maybe the problem was there?Current qemu code includes several locations where standard headers like
stdio.hare forbidden. Seeqemu-common.h(__DYNGEN_EXEC_H__),dyngen-exec.h,cris-dis.hand perhaps more examples of this restriction.Who knows the reason for this restriction? Was it use of global registers with dyngen? Was it needed only for certain hosts (maybe OSX) or old versions of gcc?
Quoted 8 lines
Most important: Is this restriction still needed?
It would simplify things like common declarations and also allow cleaner code (without private declarations for FILE etc.) if we could remove this restriction.
In my personal test environment (gcc-4.x, linux on different hosts, win32) the restriction was not needed.
Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using Apple's GCC 4.0.1. As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as before.
Andreas
Re: [Qemu-devel] [RFC] Can we remove special handling of standard headers (introduced for dyngen / OSX?)
Am 10.10.2010 00:46, schrieb Andreas Färber:
Quoted 67 lines
Am 04.10.2010 um 21:29 schrieb Stefan Weil:
Quoted 56 lines
Am 25.09.2010 09:46, schrieb Blue Swirl:
Quoted 37 lines · Stefan Weil
Quoted 21 lines
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 20 lines · Stefan Weil
Quoted 6 lines
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
Quoted 8 lines
Quoted 3 lines
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
One explanation is that the code in
target-*/op_helper.cmay assume that env/AREG0 is always available but since library functions may clobber that, we want to hide them.Quoted 1 line
For linux and win32, I did not notice problems caused by these changes.
Quoted 7 lines
It looks like that code has origins in one of the very first patches, r16 or
ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved fromexec-i386.htodyngen-exec.hby r236 or79638566e5b87058e92f537b989df0dbc23f8b41. R997 or1e6cae953d6a37216359b79e05d23e1bf4dc6bbeadded a warning about system headers. The commits around that add OS X support, maybe the problem was there?Current qemu code includes several locations where standard headers like
stdio.hare forbidden. Seeqemu-common.h(__DYNGEN_EXEC_H__),dyngen-exec.h,cris-dis.hand perhaps more examples of this restriction.Who knows the reason for this restriction? Was it use of global registers with dyngen? Was it needed only for certain hosts (maybe OSX) or old versions of gcc?
Quoted 8 lines
Most important: Is this restriction still needed?
It would simplify things like common declarations and also allow cleaner code (without private declarations for FILE etc.) if we could remove this restriction.
In my personal test environment (gcc-4.x, linux on different hosts, win32) the restriction was not needed.
Quoted 8 lines
Tested-by Andreas Färber <[email protected]>Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using Apple's GCC 4.0.1. As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as before.
Andreas
Andreas, thank you for testing.
Blue Swirl, for the next steps towards getting full format checks patch 2/3 or something equivalent is needed because GCC_FMT_ATTR (which is defined in qemu-common.h) should be available everywhere.
With Andreas test results, we now know that Linux, OSX and Win32 don't need the restriction regarding system include files like stdio.h.
Do you think more tests are needed, should we wait for more feedback or can the patch be applied?
Re: [Qemu-devel] [RFC] Can we remove special handling of standard headers (introduced for dyngen / OSX?)
Quoted 92 lines · Stefan Weil
Am 10.10.2010 00:46, schrieb Andreas Färber:
Quoted 75 lines
Am 04.10.2010 um 21:29 schrieb Stefan Weil:
Quoted 62 lines
Am 25.09.2010 09:46, schrieb Blue Swirl:
Quoted 41 lines
Quoted 23 lines · Stefan Weil
Am 23.09.2010 22:33, schrieb Blue Swirl:
Quoted 21 lines
Quoted 6 lines · Stefan Weil
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
Quoted 8 lines
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.IIRC the problem was that some system headers were incompatible with global asm variables. There is still one, AREG0.
Quoted 8 lines
Quoted 3 lines
But I'd rather not keep the hideous local definitions forever. Maybe those systems which are broken by the patch are not interesting anymore?
Are there such systems? Or did the problems with earlier versions arise from the fact that a lot of global asm variables were reserved by qemu? How could a correctly defined AREG0 interfere with system headers?
One explanation is that the code in
target-*/op_helper.cmay assume that env/AREG0 is always available but since library functions may clobber that, we want to hide them.Quoted 1 line
For linux and win32, I did not notice problems caused by these changes.
Quoted 7 lines
It looks like that code has origins in one of the very first patches, r16 or
ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved fromexec-i386.htodyngen-exec.hby r236 or79638566e5b87058e92f537b989df0dbc23f8b41. R997 or1e6cae953d6a37216359b79e05d23e1bf4dc6bbeadded a warning about system headers. The commits around that add OS X support, maybe the problem was there?Current qemu code includes several locations where standard headers like
stdio.hare forbidden. Seeqemu-common.h(__DYNGEN_EXEC_H__),dyngen-exec.h,cris-dis.hand perhaps more examples of this restriction.Who knows the reason for this restriction? Was it use of global registers with dyngen? Was it needed only for certain hosts (maybe OSX) or old versions of gcc?
Most important: Is this restriction still needed?
Quoted 7 lines
It would simplify things like common declarations and also allow cleaner code (without private declarations for FILE etc.) if we could remove this restriction.
In my personal test environment (gcc-4.x, linux on different hosts, win32)
the restriction was not needed.Tested-by Andreas Färber <[email protected]>Quoted 8 lines
Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using Apple's GCC 4.0.1.
As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as before.Andreas
Andreas, thank you for testing.
Blue Swirl, for the next steps towards getting full format checks patch 2/3 or something equivalent is needed because
GCC_FMT_ATTR(which is defined inqemu-common.h) should be available everywhere.
Quoted 5 lines
With Andreas test results, we now know that Linux, OSX and Win32 don't need the restriction regarding system include files like
stdio.h.Do you think more tests are needed, should we wait for more feedback or can the patch be applied?
What about the library compatibility situation, do we know anything about that?
On the other hand, we could apply the patch and wait for bug reports.
[Qemu-devel] Re: [PATCH 2/3] Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)
In reply to Stefan WeilQuoted 50 lines · Stefan Weil
Replace the remaining format attribute printf by macro
GCC_FMT_ATTRwhich usesgnu_printf(if supported).This needs additional code changes:
* Add
qemu-common.h(which definedGCC_FMT_ATTR) were needed.* Remove standard includes when
qemu-common.hwas added.qemu-common.halready provides these includes.* Remove local definitions which now come from
stdio.h. These definitions were needed before tcg was introduced. They raise conflicts whenqemu-common.his included.Cc Blue Swirl <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
cpu-all.h | 2 +-
cpu-exec.c | 2 ++
dyngen-exec.h | 9 ---------
target-alpha/op_helper.c | 1 +
target-arm/op_helper.c | 2 ++target-cris/op_helper.c | 1 + target-i386/op_helper.c | 1 + target-m68k/op_helper.c | 2 ++target-microblaze/op_helper.c | 2 +-
target-mips/op_helper.c | 3 ++-
target-ppc/op_helper.c | 3 ++-
target-sh4/op_helper.c | 4 ++--
target-sparc/op_helper.c | 1 +13 files changed, 18 insertions(+), 15 deletions(-)cpu-all.h +1
-1@@ -773,7 +773,7 @@ void cpu_dump_statistics (CPUState *env, FILE *f, int flags); void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + GCC_FMT_ATTR(2, 3); extern CPUState *first_cpu; extern CPUState *cpu_single_env;cpu-exec.c +0
-0
cpu-exec.c line 20
Quoted 5 lines
cpu-exec.c +2
-0@@ -16,6 +16,8 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu-common.h"
This and other similar additions are not needed for GCC_FMT_ATTR, qemu-common is already #included by exec-all.h (included by exec.h). Only the macro definition needs to move up near QEMU_NORETURN etc so that it's available to exec code.
Quoted 10 lines
cpu-exec.c +0
-0#include "config.h" #include "exec.h" #include "disas.h"dyngen-exec.h +0
-0@@ -40,15 +40,6 @@ /* XXX: This may be wrong for 64-bit ILP32 hosts. */ typedef void * host_reg_t;
dyngen-exec.h line 51
Quoted 10 lines
dyngen-exec.h +0
-9-#ifdef CONFIG_BSD -typedef struct __sFILE FILE ; -#else -typedef struct FILE FILE ; -#endif -extern int fprintf (FILE *,const char *, ...); -extern int fputs (const char *,FILE *); -extern int printf (const char *, ...); -
This should be in a separate patch which removes __DYNGEN_EXEC_H.
PATCH 3/3 Use GCC_FMT_ATTR (format checking)
In reply to Stefan Weil--- audio/audio.h | 2 +- disas.c | 3 ++- hw/mips_fulong2e.c | 3 ++- hw/mips_malta.c | 3 ++- json-parser.c | 3 ++- monitor.c | 3 ++- monitor.h | 3 ++- qemu-char.h | 3 ++- qemu-error.h | 2 +- qemu-img.c | 2 +- qerror.c | 6 ++++-- qerror.h | 2 +- qjson.h | 4 ++-- slirp/slirp.h | 2 +- 14 files changed, 25 insertions(+), 16 deletions(-)
audio/audio.h +1 -1
@@ -86,7 +86,7 @@ typedef struct QEMUAudioTimeStamp {uint64_t old_ts; } 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) GCC_FMT_ATTR(2, 0); void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void AUD_help (void );
disas.c +2 -1
@@ -349,7 +349,8 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,return 0 ; } -static int monitor_fprintf (FILE *stream,const char *fmt, ...) +static int GCC_FMT_ATTR(2, 3) +monitor_fprintf(FILE *stream, const char *fmt, ...) {va_list ap;va_start (ap, fmt);
hw/mips_fulong2e.c +2 -1
@@ -76,7 +76,8 @@ static struct _loaderparams {const char *initrd_filename; } loaderparams; -static void prom_set (uint32_t * prom_buf,int index,const char *string, ...) +static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t* prom_buf, int index, + const char *string, ...) {va_list ap;int32_t table_addr;
hw/mips_malta.c +2 -1
@@ -654,7 +654,8 @@ static void write_bootloader (CPUState *env, uint8_t *base, } -static void prom_set (uint32_t * prom_buf,int index,const char *string, ...) +static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t* prom_buf, int index, + const char *string, ...) {va_list ap;int32_t table_addr;
json-parser.c +2 -1
@@ -91,7 +91,8 @@ static int token_is_escape(QObject *obj, const char *value)/** * Error handler */ -static void parse_error (JSONParserContext *ctxt,QObject *token,const char *msg, ...) +static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt, + QObject *token, const char *msg, ...) {va_list ap;va_start (ap, msg);
monitor.c +2 -1
@@ -316,7 +316,8 @@ void monitor_print_filename(Monitor *mon, const char *filename) } } -static int monitor_fprintf (FILE *stream,const char *fmt, ...) +static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, + const char *fmt, ...) {va_list ap;va_start (ap, fmt);
monitor.h +2 -1
@@ -49,7 +49,8 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,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) + GCC_FMT_ATTR(2, 0); void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon);
qemu-char.h +2 -1
@@ -76,7 +76,8 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s));CharDriverState *qemu_chr_open (const char *label,const char *filename,void (*init)(struct CharDriverState *s));void qemu_chr_close (CharDriverState *chr); -void qemu_chr_printf (CharDriverState *s,const char *fmt, ...); +void qemu_chr_printf(CharDriverState *s, const char *fmt, ...) + GCC_FMT_ATTR(2, 3);int qemu_chr_write (CharDriverState *s,const uint8_t *buf,int len);void qemu_chr_send_event (CharDriverState *s,int event); void qemu_chr_add_handlers(CharDriverState *s,
qemu-error.h +1 -1
@@ -30,7 +30,7 @@ void loc_set_none(void);void loc_set_cmdline (char **argv,int idx,int cnt);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) GCC_FMT_ATTR(1, 0); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);void error_print_loc (void );
qemu-img.c +1 -1
@@ -39,7 +39,7 @@ typedef struct img_cmd_t {/* Default to cache=writeback as data integrity is not important for qemu-tcg. */ #define BDRV_O_FLAGS BDRV_O_CACHE_WB -static void error (const char *fmt, ...) +static void GCC_FMT_ATTR(1, 2) error(const char *fmt, ...) { va_list ap; va_start(ap, fmt);
qerror.c +4 -2
@@ -218,7 +218,8 @@ QError *qerror_new(void)return qerr; } -static void qerror_abort (const QError *qerr,const char *fmt, ...) +static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, + const char *fmt, ...) {va_list ap;
@@ -233,7 +234,8 @@ static void qerror_abort(const QError *qerr, const char *fmt, ...)abort (); } -static void qerror_set_data (QError *qerr,const char *fmt,va_list *va) +static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, + const char *fmt, va_list *va) {QObject *obj;
qerror.h +1 -1
@@ -34,7 +34,7 @@ typedef struct QError {QError *qerror_new (void );QError *qerror_from_info (const char *file,int linenr,const char *func, -const char *fmt,va_list *va); +const char *fmt,va_list *va)GCC_FMT_ATTR (4 ,0 );QString *qerror_human (const QError *qerror);void qerror_print (QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func,
qjson.h +2 -2
@@ -18,9 +18,9 @@#include "qobject.h" #include "qstring.h" -QObject *qobject_from_json (const char *string); +QObject *qobject_from_json (const char *string)GCC_FMT_ATTR (1 ,0 );QObject *qobject_from_jsonf (const char *string, ...)GCC_FMT_ATTR (1 ,2 ); -QObject *qobject_from_jsonv (const char *string,va_list *ap); +QObject *qobject_from_jsonv (const char *string,va_list *ap)GCC_FMT_ATTR (1 ,0 );QString *qobject_to_json (const QObject *obj);
slirp/slirp.h +1 -1
@@ -261,7 +261,7 @@ void if_start(struct ttys *);long gethostid (void );#endif -void lprint (const char *, ...); +void lprint(const char *, ...) GCC_FMT_ATTR(1, 2);#ifndef _WIN32#include <netdb.h>
Signature · 1 line
1.7.1
Blue Swirl
AppliedRe: [Qemu-devel] [PATCH 3/3] Use GCC_FMT_ATTR (format checking)
Thanks, applied.
Quoted 226 lines · Stefan Weil
Signed-off-by Stefan Weil <[email protected]>---
audio/audio.h | 2 +-
disas.c | 3 ++-
hw/mips_fulong2e.c | 3 ++-
hw/mips_malta.c | 3 ++-
json-parser.c | 3 ++-
monitor.c | 3 ++-
monitor.h | 3 ++-
qemu-char.h | 3 ++-
qemu-error.h | 2 +-
qemu-img.c | 2 +-
qerror.c | 6 ++++--
qerror.h | 2 +-
qjson.h | 4 ++--
slirp/slirp.h | 2 +-14 files changed, 25 insertions(+), 16 deletions(-)audio/audio.h +1
-1@@ -86,7 +86,7 @@ typedef struct QEMUAudioTimeStamp { uint64_t old_ts; } 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) GCC_FMT_ATTR(2, 0); void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void AUD_help (void);disas.c +2
-1@@ -349,7 +349,8 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, return 0; } -static int monitor_fprintf (FILE *stream,const char *fmt, ...) +static int GCC_FMT_ATTR(2, 3) +monitor_fprintf(FILE *stream, const char *fmt, ...) { va_list ap; va_start(ap, fmt);hw/mips_fulong2e.c +2
-1@@ -76,7 +76,8 @@ static struct _loaderparams { const char *initrd_filename; } loaderparams; -static void prom_set (uint32_t * prom_buf,int index,const char *string, ...) +static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t* prom_buf, int index, + const char *string, ...) { va_list ap; int32_t table_addr;hw/mips_malta.c +2
-1@@ -654,7 +654,8 @@ static void write_bootloader (CPUState *env, uint8_t *base, } -static void prom_set (uint32_t * prom_buf,int index,const char *string, ...) +static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t* prom_buf, int index, + const char *string, ...) { va_list ap; int32_t table_addr;json-parser.c +2
-1@@ -91,7 +91,8 @@ static int token_is_escape(QObject *obj, const char *value) /*** Error handler */ -static void parse_error (JSONParserContext *ctxt,QObject *token,const char *msg, ...) +static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt, + QObject *token, const char *msg, ...) { va_list ap; va_start(ap, msg);monitor.c +2
-1@@ -316,7 +316,8 @@ void monitor_print_filename(Monitor *mon, const char *filename) } } -static int monitor_fprintf (FILE *stream,const char *fmt, ...) +static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, + const char *fmt, ...) { va_list ap; va_start(ap, fmt);monitor.h +2
-1@@ -49,7 +49,8 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, 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) + GCC_FMT_ATTR(2, 0); void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_print_filename(Monitor *mon, const char *filename); void monitor_flush(Monitor *mon);qemu-char.h +2
-1@@ -76,7 +76,8 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s)); CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s)); void qemu_chr_close(CharDriverState *chr); -void qemu_chr_printf (CharDriverState *s,const char *fmt, ...); +void qemu_chr_printf(CharDriverState *s, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); void qemu_chr_send_event(CharDriverState *s, int event); void qemu_chr_add_handlers(CharDriverState *s,qemu-error.h +1
-1@@ -30,7 +30,7 @@ void loc_set_none(void); void loc_set_cmdline(char **argv, int idx, int cnt); 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) GCC_FMT_ATTR(1, 0); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_print_loc(void);qemu-img.c +1
-1@@ -39,7 +39,7 @@ typedef struct img_cmd_t { /* Default to cache=writeback as data integrity is not important for qemu-tcg. */ #define BDRV_O_FLAGS BDRV_O_CACHE_WB -static void error (const char *fmt, ...) +static void GCC_FMT_ATTR(1, 2) error(const char *fmt, ...) { va_list ap; va_start(ap, fmt);qerror.c +4
-2@@ -218,7 +218,8 @@ QError *qerror_new(void) return qerr; } -static void qerror_abort (const QError *qerr,const char *fmt, ...) +static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, + const char *fmt, ...) { va_list ap;@@ -233,7 +234,8 @@ static void qerror_abort(const QError *qerr, const char *fmt, ...) abort(); } -static void qerror_set_data (QError *qerr,const char *fmt,va_list *va) +static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, + const char *fmt, va_list *va) { QObject *obj;qerror.h +1
-1@@ -34,7 +34,7 @@ typedef struct QError { QError *qerror_new(void); QError *qerror_from_info(const char *file, int linenr, const char *func, - const char *fmt, va_list *va); + const char *fmt, va_list *va) GCC_FMT_ATTR(4, 0); QString *qerror_human(const QError *qerror); void qerror_print(QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func,qjson.h +2
-2@@ -18,9 +18,9 @@ #include "qobject.h" #include "qstring.h" -QObject *qobject_from_json (const char *string); +QObject *qobject_from_json (const char *string)GCC_FMT_ATTR (1 ,0 ); QObject *qobject_from_jsonf(const char *string, ...) GCC_FMT_ATTR(1, 2); -QObject *qobject_from_jsonv (const char *string,va_list *ap); +QObject *qobject_from_jsonv (const char *string,va_list *ap)GCC_FMT_ATTR (1 ,0 ); QString *qobject_to_json(const QObject *obj);slirp/slirp.h +1
-2@@ -261,7 +261,7 @@ void if_start(struct ttys *); long gethostid(void); #endif -void lprint (const char *, ...); +void lprint(const char *, ...) GCC_FMT_ATTR(1, 2); #ifndef _WIN32 #include <netdb.h> --1.7.1
Blue Swirl
AppliedThanks, applied.
Quoted 174 lines · Stefan Weil
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 macroGCC_FMT_ATTRwhich usesgnu_printfif supported.It also removes an #ifdef
__GNUC__(not needed any longer).Cc Blue Swirl <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
audio/audio.h | 6 +-----
bsd-user/qemu.h | 2 +-
darwin-user/qemu.h | 2 +-
hw/xen_backend.h | 2 +-
linux-user/qemu.h | 2 +-
monitor.h | 3 +--
qemu-common.h | 3 +--
qemu-error.h | 7 +++----
qerror.h | 3 +--
qjson.h | 3 +--10 files changed, 12 insertions(+), 21 deletions(-)audio/audio.h +1
-5@@ -87,11 +87,7 @@ typedef struct QEMUAudioTimeStamp { } QEMUAudioTimeStamp; void AUD_vlog (const char *cap, const char *fmt, va_list ap); -void AUD_log (const char *cap,const char *fmt, ...) -#ifdef __GNUC__ - __attribute__ ((__format__ (__printf__, 2, 3))) -#endif - ; +void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void AUD_help (void); void AUD_register_card (const char *name, QEMUSoundCard *card);bsd-user/qemu.h +1
-1@@ -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 arg2, abi_long arg3, abi_long arg4, 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; void cpu_loop(CPUState *env); char *target_strerror(int err);darwin-user/qemu.h +1
-1@@ -99,7 +99,7 @@ int do_sigaction(int sig, const struct sigaction *act, struct sigaction *oact); 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 write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags);hw/xen_backend.h +1
-1@@ -84,7 +84,7 @@ int xen_be_bind_evtchn(struct XenDevice *xendev); void xen_be_unbind_evtchn(struct XenDevice *xendev); int xen_be_send_notify(struct XenDevice *xendev); 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 */extern struct XenDevOps
xen_console_ops; /*xen_console.c*/linux-user/qemu.h +1
-1@@ -186,7 +186,7 @@ void syscall_init(void); abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, 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; void cpu_loop(CPUState *env); char *target_strerror(int err);monitor.h +1
-2@@ -50,8 +50,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, int monitor_get_fd(Monitor *mon, const char *fdname); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap); -void monitor_printf (Monitor *mon,const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); +void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_print_filename(Monitor *mon, const char *filename); void monitor_flush(Monitor *mon);qemu-common.h +1
-2@@ -196,8 +196,7 @@ int qemu_pipe(int pipefd[2]); /* Error handling. */ -void QEMU_NORETURN hw_error(const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); +void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); /* IO callbacks. */ typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);qemu-error.h +3
-4@@ -31,11 +31,10 @@ void loc_set_cmdline(char **argv, int idx, int cnt); void loc_set_file(const char *fname, int lno); void error_vprintf(const char *fmt, va_list ap); -void error_printf (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 ))); -void error_printf_unless_qmp (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, ...) GCC_FMT_ATTR(1, 2); void error_print_loc(void); 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); #endifqerror.h +1
-2@@ -38,8 +38,7 @@ QError *qerror_from_info(const char *file, int linenr, const char *func, QString *qerror_human(const QError *qerror); void qerror_print(QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func, - const char *fmt, ...) - __attribute__ ((format(printf, 4, 5))); + const char *fmt, ...) GCC_FMT_ATTR(4, 5); #define qerror_report(fmt, ...) \ qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) QError *qobject_to_qerror(const QObject *obj);qjson.h +1
-3@@ -19,8 +19,7 @@ #include "qstring.h" QObject *qobject_from_json(const char *string); -QObject *qobject_from_jsonf (const char *string, ...) - __attribute__((__format__ (__printf__, 1, 2))); +QObject *qobject_from_jsonf (const char *string, ...)GCC_FMT_ATTR (1 ,2 ); QObject *qobject_from_jsonv(const char *string, va_list *ap); QString *qobject_to_json(const QObject *obj); --1.7.1