Skip to content

Commit

Permalink
Replace GCC_FMT_ATTR with G_GNUC_PRINTF
Browse files Browse the repository at this point in the history
One less qemu-specific macro. It also helps to make some headers/units
only depend on glib, and thus moved in standalone projects eventually.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Richard W.M. Jones <[email protected]>
  • Loading branch information
elmarco committed Mar 22, 2022
1 parent e7b7942 commit 9edc631
Show file tree
Hide file tree
Showing 58 changed files with 130 additions and 137 deletions.
4 changes: 2 additions & 2 deletions audio/alsaaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct alsa_params_obt {
snd_pcm_uframes_t samples;
};

static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF (2, 3) alsa_logerr (int err, const char *fmt, ...)
{
va_list ap;

Expand All @@ -83,7 +83,7 @@ static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...)
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
}

static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
static void G_GNUC_PRINTF (3, 4) alsa_logerr2 (
int err,
const char *typ,
const char *fmt,
Expand Down
4 changes: 2 additions & 2 deletions audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ typedef struct QEMUAudioTimeStamp {
uint64_t old_ts;
} QEMUAudioTimeStamp;

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_vlog (const char *cap, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
void AUD_log (const char *cap, const char *fmt, ...) G_GNUC_PRINTF(2, 3);

void AUD_register_card (const char *name, QEMUSoundCard *card);
void AUD_remove_card (QEMUSoundCard *card);
Expand Down
4 changes: 2 additions & 2 deletions audio/coreaudio.m
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void coreaudio_logstatus (OSStatus status)
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
}

static void GCC_FMT_ATTR (2, 3) coreaudio_logerr (
static void G_GNUC_PRINTF (2, 3) coreaudio_logerr (
OSStatus status,
const char *fmt,
...
Expand All @@ -226,7 +226,7 @@ static void GCC_FMT_ATTR (2, 3) coreaudio_logerr (
coreaudio_logstatus (status);
}

static void GCC_FMT_ATTR (3, 4) coreaudio_logerr2 (
static void G_GNUC_PRINTF (3, 4) coreaudio_logerr2 (
OSStatus status,
const char *typ,
const char *fmt,
Expand Down
4 changes: 2 additions & 2 deletions audio/dsoundaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static void dsound_log_hresult (HRESULT hr)
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
}

static void GCC_FMT_ATTR (2, 3) dsound_logerr (
static void G_GNUC_PRINTF (2, 3) dsound_logerr (
HRESULT hr,
const char *fmt,
...
Expand All @@ -237,7 +237,7 @@ static void GCC_FMT_ATTR (2, 3) dsound_logerr (
dsound_log_hresult (hr);
}

static void GCC_FMT_ATTR (3, 4) dsound_logerr2 (
static void G_GNUC_PRINTF (3, 4) dsound_logerr2 (
HRESULT hr,
const char *typ,
const char *fmt,
Expand Down
4 changes: 2 additions & 2 deletions audio/ossaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct oss_params {
int fragsize;
};

static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF (2, 3) oss_logerr (int err, const char *fmt, ...)
{
va_list ap;

Expand All @@ -74,7 +74,7 @@ static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...)
AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
}

static void GCC_FMT_ATTR (3, 4) oss_logerr2 (
static void G_GNUC_PRINTF (3, 4) oss_logerr2 (
int err,
const char *typ,
const char *fmt,
Expand Down
2 changes: 1 addition & 1 deletion audio/paaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct {

static void qpa_conn_fini(PAConnection *c);

static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...)
static void G_GNUC_PRINTF (2, 3) qpa_logerr (int err, const char *fmt, ...)
{
va_list ap;

Expand Down
2 changes: 1 addition & 1 deletion audio/sdlaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef struct SDLVoiceIn {
SDL_AudioDeviceID devid;
} SDLVoiceIn;

static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char *fmt, ...)
static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...)
{
va_list ap;

Expand Down
2 changes: 1 addition & 1 deletion block/blkverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct BlkverifyRequest {
QEMUIOVector *raw_qiov; /* cloned I/O vector for raw file */
} BlkverifyRequest;

static void GCC_FMT_ATTR(2, 3) blkverify_err(BlkverifyRequest *r,
static void G_GNUC_PRINTF(2, 3) blkverify_err(BlkverifyRequest *r,
const char *fmt, ...)
{
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion block/qcow2.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ int qcow2_update_header(BlockDriverState *bs);

void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
int64_t size, const char *message_format, ...)
GCC_FMT_ATTR(5, 6);
G_GNUC_PRINTF(5, 6);

int qcow2_validate_table(BlockDriverState *bs, uint64_t offset,
uint64_t entries, size_t entry_len,
Expand Down
4 changes: 2 additions & 2 deletions block/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void ssh_state_free(BDRVSSHState *s)
}
}

static void GCC_FMT_ATTR(3, 4)
static void G_GNUC_PRINTF(3, 4)
session_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
{
va_list args;
Expand All @@ -133,7 +133,7 @@ session_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
g_free(msg);
}

static void GCC_FMT_ATTR(3, 4)
static void G_GNUC_PRINTF(3, 4)
sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
{
va_list args;
Expand Down
2 changes: 1 addition & 1 deletion bsd-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,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, ...) GCC_FMT_ATTR(1, 2);
void gemu_log(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
extern __thread CPUState *thread_cpu;
void cpu_loop(CPUArchState *env);
char *target_strerror(int err);
Expand Down
2 changes: 1 addition & 1 deletion fsdev/9p-marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void v9fs_string_free(V9fsString *str)
str->size = 0;
}

void GCC_FMT_ATTR(2, 3)
void G_GNUC_PRINTF(2, 3)
v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
{
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion fsdev/virtfs-proxy-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static bool is_daemon;
static bool get_version; /* IOC getversion IOCTL supported */
static char *prog_name;

static void GCC_FMT_ATTR(2, 3) do_log(int loglevel, const char *format, ...)
static void G_GNUC_PRINTF(2, 3) do_log(int loglevel, const char *format, ...)
{
va_list ap;

Expand Down
2 changes: 1 addition & 1 deletion hw/9pfs/9p.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void v9fs_path_free(V9fsPath *path)
}


void GCC_FMT_ATTR(2, 3)
void G_GNUC_PRINTF(2, 3)
v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
{
va_list ap;
Expand Down
4 changes: 2 additions & 2 deletions hw/acpi/aml-build.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ build_append_nameseg(GArray *array, const char *seg)
g_array_append_vals(array, "____", ACPI_NAMESEG_LEN - len);
}

static void GCC_FMT_ATTR(2, 0)
static void G_GNUC_PRINTF(2, 0)
build_append_namestringv(GArray *array, const char *format, va_list ap)
{
char *s;
Expand Down Expand Up @@ -270,7 +270,7 @@ build_append_namestringv(GArray *array, const char *format, va_list ap)
g_strfreev(segs);
}

GCC_FMT_ATTR(2, 3)
G_GNUC_PRINTF(2, 3)
static void build_append_namestring(GArray *array, const char *format, ...)
{
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion hw/display/qxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(PCIQXLDevice, PCI_QXL)
/* qxl.c */
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 3);

void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
struct QXLRect *area, struct QXLRect *dirty_rects,
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/fuloong2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static struct _loaderparams {
const char *initrd_filename;
} loaderparams;

static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t *prom_buf, int index,
static void G_GNUC_PRINTF(3, 4) prom_set(uint32_t *prom_buf, int index,
const char *string, ...)
{
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/malta.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,

}

static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t *prom_buf, int index,
static void G_GNUC_PRINTF(3, 4) prom_set(uint32_t *prom_buf, int index,
const char *string, ...)
{
va_list ap;
Expand Down
2 changes: 1 addition & 1 deletion hw/net/rocker/rocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
fprintf(stderr, "%s ROCKER: " fmt, nowstr, ## __VA_ARGS__);\
} while (0)
#else
static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
static inline G_GNUC_PRINTF(1, 2) int DPRINTF(const char *fmt, ...)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/net/rtl8139.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
# define DPRINTF(fmt, ...) \
do { fprintf(stderr, "RTL8139: " fmt, ## __VA_ARGS__); } while (0)
#else
static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
static inline G_GNUC_PRINTF(1, 2) int DPRINTF(const char *fmt, ...)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3579,7 +3579,7 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
vdev->bus_name = g_strdup(bus_name);
}

void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
void G_GNUC_PRINTF(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
{
va_list ap;

Expand Down
2 changes: 1 addition & 1 deletion hw/xen/xen_pt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
bool xen_igd_gfx_pt_enabled(void);
void xen_igd_gfx_pt_set(bool value, Error **errp);

void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3);
void xen_pt_log(const PCIDevice *d, const char *f, ...) G_GNUC_PRINTF(2, 3);

#define XEN_PT_ERR(d, _f, _a...) xen_pt_log(d, "%s: Error: "_f, __func__, ##_a)

Expand Down
2 changes: 1 addition & 1 deletion include/chardev/char-fe.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
* Chardev.
*/
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 3);


typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *data);
Expand Down
2 changes: 1 addition & 1 deletion include/disas/dis-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ typedef struct symbol_cache_entry
} asymbol;

typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 3);

enum dis_insn_type {
dis_noninsn, /* Not a valid instruction */
Expand Down
12 changes: 6 additions & 6 deletions include/hw/acpi/aml-build.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void free_aml_allocator(void);
void aml_append(Aml *parent_ctx, Aml *child);

/* non block AML object primitives */
Aml *aml_name(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
Aml *aml_name(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_name_decl(const char *name, Aml *val);
Aml *aml_debug(void);
Aml *aml_return(Aml *val);
Expand Down Expand Up @@ -344,13 +344,13 @@ Aml *aml_irq_no_flags(uint8_t irq);
Aml *aml_named_field(const char *name, unsigned length);
Aml *aml_reserved_field(unsigned length);
Aml *aml_local(int num);
Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
Aml *aml_string(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_lnot(Aml *arg);
Aml *aml_equal(Aml *arg1, Aml *arg2);
Aml *aml_lgreater(Aml *arg1, Aml *arg2);
Aml *aml_lgreater_equal(Aml *arg1, Aml *arg2);
Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len,
const char *name_format, ...) GCC_FMT_ATTR(4, 5);
const char *name_format, ...) G_GNUC_PRINTF(4, 5);
Aml *aml_eisaid(const char *str);
Aml *aml_word_bus_number(AmlMinFixed min_fixed, AmlMaxFixed max_fixed,
AmlDecode dec, uint16_t addr_gran,
Expand Down Expand Up @@ -384,8 +384,8 @@ Aml *aml_sleep(uint64_t msec);
Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source);

/* Block AML object primitives */
Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
Aml *aml_scope(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_device(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag);
Aml *aml_if(Aml *predicate);
Aml *aml_else(void);
Expand Down Expand Up @@ -460,7 +460,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,

int
build_append_named_dword(GArray *array, const char *name_format, ...)
GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 3);

void build_append_gas(GArray *table, AmlAddressSpace as,
uint8_t bit_width, uint8_t bit_offset,
Expand Down
2 changes: 1 addition & 1 deletion include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len);
AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx);

void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 3);

/* $(top_srcdir)/cpu.c */
void cpu_class_init_props(DeviceClass *dc);
Expand Down
2 changes: 1 addition & 1 deletion include/hw/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#error Cannot include hw/hw.h from user emulation
#endif

void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void QEMU_NORETURN hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);

#endif
2 changes: 1 addition & 1 deletion include/hw/virtio/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
uint16_t device_id, size_t config_size);
void virtio_cleanup(VirtIODevice *vdev);

void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(2, 3);

/* Set the child bus name. */
void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
Expand Down
4 changes: 2 additions & 2 deletions include/hw/xen/xen-bus-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ void xs_node_destroy(struct xs_handle *xsh, xs_transaction_t tid,
void xs_node_vprintf(struct xs_handle *xsh, xs_transaction_t tid,
const char *node, const char *key, Error **errp,
const char *fmt, va_list ap)
GCC_FMT_ATTR(6, 0);
G_GNUC_PRINTF(6, 0);
void xs_node_printf(struct xs_handle *xsh, xs_transaction_t tid,
const char *node, const char *key, Error **errp,
const char *fmt, ...)
GCC_FMT_ATTR(6, 7);
G_GNUC_PRINTF(6, 7);

/* Read from node/key unless node is empty, in which case read from key */
int xs_node_vscanf(struct xs_handle *xsh, xs_transaction_t tid,
Expand Down
4 changes: 2 additions & 2 deletions include/hw/xen/xen-bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ enum xenbus_state xen_device_backend_get_state(XenDevice *xendev);

void xen_device_backend_printf(XenDevice *xendev, const char *key,
const char *fmt, ...)
GCC_FMT_ATTR(3, 4);
G_GNUC_PRINTF(3, 4);
void xen_device_frontend_printf(XenDevice *xendev, const char *key,
const char *fmt, ...)
GCC_FMT_ATTR(3, 4);
G_GNUC_PRINTF(3, 4);

int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
const char *fmt, ...);
Expand Down
2 changes: 1 addition & 1 deletion include/hw/xen/xen_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static inline int xen_restrict(domid_t domid)
void destroy_hvm_domain(bool reboot);

/* shutdown/destroy current domain because of an error */
void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void xen_shutdown_fatal_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);

#ifdef HVM_PARAM_VMPORT_REGS_PFN
static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom,
Expand Down
2 changes: 1 addition & 1 deletion include/hw/xen/xen_pvdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ void xen_pv_unbind_evtchn(struct XenLegacyDevice *xendev);
int xen_pv_send_notify(struct XenLegacyDevice *xendev);

void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level,
const char *fmt, ...) GCC_FMT_ATTR(3, 4);
const char *fmt, ...) G_GNUC_PRINTF(3, 4);

#endif /* QEMU_HW_XEN_PVDEV_H */
4 changes: 2 additions & 2 deletions include/monitor/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);

int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
GCC_FMT_ATTR(2, 0);
int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
G_GNUC_PRINTF(2, 0);
int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
void monitor_flush(Monitor *mon);
int monitor_set_cpu(Monitor *mon, int cpu_index);
int monitor_get_cpu_index(Monitor *mon);
Expand Down
Loading

0 comments on commit 9edc631

Please sign in to comment.