Purge the silly GLib Basic Types
cover Purge the silly GLib Basic Types
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purged
async.c | 12 +++++------- coroutine-gthread.c | 8 ++++---- hw/9pfs/virtio-9p-coth.c | 2 +- hw/fw_cfg.c | 6 +++--- hw/qdev-monitor.c | 2 +- hw/qdev.c | 4 ++-- hw/xen_disk.c | 6 +++--- include/qom/object.h | 8 ++++---- main-loop.c | 2 +- qapi/opts-visitor.c | 10 +++++----- qapi/qmp-input-visitor.c | 4 ++-- qemu-img.c | 4 ++-- qga/channel-posix.c | 25 +++++++++++++------------ qga/channel-win32.c | 26 +++++++++++++------------- qga/channel.h | 10 +++++----- qga/commands-posix.c | 6 +++--- qga/commands.c | 2 +- qga/guest-agent-command-state.c | 4 ++-- qga/guest-agent-core.h | 2 +- qga/main.c | 16 ++++++++-------- qom/container.c | 2 +- qom/object.c | 26 +++++++++++++------------- qtest.c | 8 ++++---- scripts/checkpatch.pl | 29 +++++++++++++++++++++++++++++ target-alpha/cpu.c | 4 ++-- target-arm/cpu.c | 2 +- target-arm/helper.c | 4 ++-- target-i386/cpu.c | 2 +- target-m68k/helper.c | 4 ++-- target-openrisc/cpu.c | 4 ++-- target-ppc/translate_init.c | 12 ++++++------ tests/libqtest.c | 20 ++++++++++---------- tests/test-visitor-serialization.c | 12 ++++++------ trace/simple.c | 8 ++++---- vl.c | 6 +++--- 35 files changed, 165 insertions(+), 137 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/3 Purge the silly GLib "Basic Types", except for gboolean
GLib chooses to define aliases for a whole bunch of bog-standard C names. GLib's documentation justifies them by "ease-of-use and portability". Baloney. Aliases for standar types are no more portable than the standard types themselves. And if you const void * so hard to use that you need to muddle the waters with an alias, I'd prefer you'd break some other code base instead of QEMU.
The following GLib aliases have crept into our code:
gboolean int
gpointer void *
gconstpointer const void *
gchar char
guchar unsigned char
gint int
guint unsigned
glong long
gdouble double
gsize size_t
G_MAXSIZE SIZE_MAX
gintptr int *Purge them all except for gboolean, which gets its own commit because it's even sillier than the others.
--- async.c | 6 ++---- coroutine-gthread.c | 8 ++++---- hw/9pfs/virtio-9p-coth.c | 2 +- hw/fw_cfg.c | 4 ++-- hw/qdev-monitor.c | 2 +- hw/qdev.c | 4 ++-- hw/xen_disk.c | 4 ++-- include/qom/object.h | 8 ++++---- main-loop.c | 2 +- qapi/opts-visitor.c | 8 ++++---- qapi/qmp-input-visitor.c | 4 ++-- qemu-img.c | 4 ++-- qga/channel-posix.c | 18 +++++++++--------- qga/channel-win32.c | 18 +++++++++--------- qga/channel.h | 10 +++++----- qga/commands-posix.c | 6 +++--- qga/commands.c | 2 +- qga/guest-agent-command-state.c | 4 ++-- qga/guest-agent-core.h | 2 +- qga/main.c | 14 +++++++------- qom/container.c | 2 +- qom/object.c | 26 +++++++++++++------------- qtest.c | 8 ++++---- target-alpha/cpu.c | 4 ++-- target-arm/cpu.c | 2 +- target-arm/helper.c | 4 ++-- target-i386/cpu.c | 2 +- target-m68k/helper.c | 4 ++-- target-openrisc/cpu.c | 4 ++-- target-ppc/translate_init.c | 12 ++++++------ tests/libqtest.c | 20 ++++++++++---------- tests/test-visitor-serialization.c | 12 ++++++------ trace/simple.c | 8 ++++---- vl.c | 6 +++--- 34 files changed, 121 insertions(+), 123 deletions(-)
async.c +2 -4
@@ -118,7 +118,7 @@ void qemu_bh_delete(QEMUBH *bh) }static gboolean -aio_ctx_prepare (GSource *source,gint *timeout) +aio_ctx_prepare (GSource *source,int *timeout) {AioContext *ctx = (AioContext *) source;QEMUBH *bh;
@@ -156,9 +156,7 @@ aio_ctx_check(GSource *source) }static gboolean -aio_ctx_dispatch (GSource *source, -GSourceFunc callback, -gpointer user_data) +aio_ctx_dispatch (GSource *source,GSourceFunc callback,void *user_data) {AioContext *ctx = (AioContext *) source;
coroutine-gthread.c +4 -4
@@ -50,7 +50,7 @@ static inline void init_coroutine_cond(void)* thread exit / coroutine key update using the free_on_thread_exit * field. */ -static void coroutine_destroy_notify (gpointer data) +static void coroutine_destroy_notify (void *data) {CoroutineGThread *co = data;if (co && co->free_on_thread_exit) {
@@ -76,7 +76,7 @@ static inline void set_coroutine_key(CoroutineGThread *co,g_private_replace (&coroutine_key, co); } -static inline GThread *create_thread (GThreadFunc func,gpointer data) +static inline GThread *create_thread (GThreadFunc func,void *data) {return g_thread_new ("coroutine" , func, data); }
@@ -104,7 +104,7 @@ static inline void set_coroutine_key(CoroutineGThread *co, free_on_thread_exit ? (GDestroyNotify)g_free : NULL); } -static inline GThread *create_thread (GThreadFunc func,gpointer data) +static inline GThread *create_thread (GThreadFunc func,void *data) {return g_thread_create_full (func, data,0 , TRUE, TRUE,G_THREAD_PRIORITY_NORMAL ,NULL );
@@ -141,7 +141,7 @@ static void coroutine_wait_runnable(CoroutineGThread *co)g_static_mutex_unlock (&coroutine_lock); } -static gpointer coroutine_thread (gpointer opaque) +static void *coroutine_thread (void *opaque) {CoroutineGThread *co = opaque;
hw/9pfs/virtio-9p-coth.c +1 -1
@@ -41,7 +41,7 @@ static void v9fs_qemu_process_req_done(void *arg) } } -static void v9fs_thread_routine (gpointer data,gpointer user_data) +static void v9fs_thread_routine (void *data,void *user_data) {ssize_t len;char byte =0 ;
hw/fw_cfg.c +2 -2
@@ -67,12 +67,12 @@ static char *read_splashfile(char *filename, int *file_sizep, int *file_typep) {GError *err =NULL ;gboolean res; -gchar *content; +char *content;int file_type =-1 ;unsigned int filehead =0 ;int bmp_bpp; - res =g_file_get_contents (filename, &content, (gsize *)file_sizep, &err); + res =g_file_get_contents (filename, &content, (size_t *)file_sizep, &err);if (res == FALSE) {error_report ("failed to read splash file '%s'" , filename);g_error_free (err);
hw/qdev-monitor.c +1 -1
@@ -474,7 +474,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) OBJECT(qdev), NULL); }else {static int anon_count; -gchar *name =g_strdup_printf ("device[%d]" , anon_count++); +char *name =g_strdup_printf ("device[%d]" , anon_count++);object_property_add_child (qdev_get_peripheral_anon (), name,OBJECT (qdev),NULL );g_free (name);
hw/qdev.c +2 -2
@@ -567,7 +567,7 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque,void qdev_property_add_legacy (DeviceState *dev,Property *prop,Error **errp) { -gchar *name, *type; +char *name, *type;/* Register pointer properties as legacy properties */ if (!prop->info->print && !prop->info->parse &&
@@ -653,7 +653,7 @@ static void device_set_realized(Object *obj, bool value, Error **err)if (!obj->parent && local_err ==NULL ) {static int unattached_count; -gchar *name =g_strdup_printf ("device[%d]" , unattached_count++); +char *name =g_strdup_printf ("device[%d]" , unattached_count++); object_property_add_child(container_get(qdev_get_machine(), "/unattached"),
hw/xen_disk.c +2 -2
@@ -151,14 +151,14 @@ static void ioreq_reset(struct ioreq *ioreq)qemu_iovec_reset (&ioreq->v); } -static gint int_cmp (gconstpointer a,gconstpointer b,gpointer user_data) +static int int_cmp (const void *a,const void *b,void *user_data) {uint ua =GPOINTER_TO_UINT (a);uint ub =GPOINTER_TO_UINT (b);return (ua > ub) - (ua < ub); } -static void destroy_grant (gpointer pgnt) +static void destroy_grant (void *pgnt) {PersistentGrant *grant = pgnt;XenGnttab gnt = grant->blkdev->xendev.gnttabdev;
include/qom/object.h +4 -4
@@ -219,8 +219,8 @@ typedef void (ObjectPropertyRelease)(Object *obj, typedef struct ObjectProperty { - gchar *name; - gchar *type; + char *name; + char *type; ObjectPropertyAccessor *get; ObjectPropertyAccessor *set; ObjectPropertyRelease *release;
@@ -842,7 +842,7 @@ Object *object_get_root(void);* Returns: The canonical path for a object. This is the path within the * composition tree starting from the root. */ -gchar *object_get_canonical_path (Object *obj); +char *object_get_canonical_path (Object *obj);/** * object_resolve_path:
@@ -900,7 +900,7 @@ Object *object_resolve_path_type(const char *path, const char *typename,* * Returns: The resolved object or NULL on path lookup failure. */ -Object *object_resolve_path_component (Object *parent,const gchar *part); +Object *object_resolve_path_component (Object *parent,const char *part);/** * object_property_add_child:
main-loop.c +1 -1
@@ -333,7 +333,7 @@ static int os_host_main_loop_wait(uint32_t timeout)int select_ret, g_poll_ret, ret, i;PollingEntry *pe;WaitObjects *w = &wait_objects; -gint poll_timeout; +int poll_timeout;static struct timeval tv0;/* XXX: need to suppress polling by better using win32 events */
qapi/opts-visitor.c +4 -4
@@ -47,7 +47,7 @@ struct OptsVisitorstatic void -destroy_list (gpointer list) +destroy_list (void *list) {g_queue_free (list); }
@@ -66,11 +66,11 @@ opts_visitor_insert(GHashTable *unprocessed_opts, const QemuOpt *opt)* "key_destroy_func" in opts_start_struct(). Thus cast away key * const-ness in order to suppress gcc's warning. */ -g_hash_table_insert (unprocessed_opts, (gpointer )opt->name, list); +g_hash_table_insert (unprocessed_opts, (void *)opt->name, list); }/* Similarly, destroy_list() doesn't call g_queue_free_full(). */ -g_queue_push_tail (list, (gpointer )opt); +g_queue_push_tail (list, (void *)opt); }
@@ -106,7 +106,7 @@ opts_start_struct(Visitor *v, void **obj, const char *kind,static gboolean -ghr_true (gpointer ign_key,gpointer ign_value,gpointer ign_user_data) +ghr_true (void *ign_key,void *ign_value,void *ign_user_data) {return TRUE; }
qapi/qmp-input-visitor.c +2 -2
@@ -62,7 +62,7 @@ static QObject *qmp_input_get_object(QmpInputVisitor *qiv,static void qdict_add_key (const char *key,QObject *obj,void *opaque) {GHashTable *h = opaque; -g_hash_table_insert (h, (gpointer ) key,NULL ); +g_hash_table_insert (h, (void *) key,NULL ); }static void qmp_input_push (QmpInputVisitor *qiv,QObject *obj,Error **errp)
@@ -88,7 +88,7 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp) }/** Only for qmp_input_pop. */ -static gboolean always_true (gpointer key,gpointer val,gpointer user_pkey) +static gboolean always_true (void *key,void *val,void *user_pkey) { *(const char **)user_pkey = (const char *)key;return TRUE;
qemu-img.c +2 -2
@@ -1315,7 +1315,7 @@ static void dump_human_image_info_list(ImageInfoList *list) } } -static gboolean str_equal_func (gconstpointer a,gconstpointer b) +static gboolean str_equal_func (const void *a,const void *b) {return strcmp (a, b) ==0 ; }
@@ -1352,7 +1352,7 @@ static ImageInfoList *collect_image_info_list(const char *filename, filename); goto err; } -g_hash_table_insert (filenames, (gpointer )filename,NULL ); +g_hash_table_insert (filenames, (void *)filename,NULL ); bs =bdrv_new_open (filename, fmt,BDRV_O_FLAGS |BDRV_O_NO_BACKING , false);
qga/channel-posix.c +9 -9
@@ -20,13 +20,13 @@ struct GAChannel {GIOChannel *client_channel;GAChannelMethod method;GAChannelCallback event_cb; -gpointer user_data; +void *user_data; };static int ga_channel_client_add (GAChannel *c,int fd);static gboolean ga_channel_listen_accept (GIOChannel *channel, -GIOCondition condition,gpointer data) +GIOCondition condition,void *data) {GAChannel *c = data;int ret, client_fd;
@@ -91,7 +91,7 @@ static void ga_channel_client_close(GAChannel *c) }static gboolean ga_channel_client_event (GIOChannel *channel, -GIOCondition condition,gpointer data) +GIOCondition condition,void *data) {GAChannel *c = data;gboolean client_cont;
@@ -127,7 +127,7 @@ static int ga_channel_client_add(GAChannel *c, int fd)return 0 ; } -static gboolean ga_channel_open (GAChannel *c,const gchar *path,GAChannelMethod method) +static gboolean ga_channel_open (GAChannel *c,const char *path,GAChannelMethod method) {int ret; c->method = method;
@@ -210,10 +210,10 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethodreturn true; } -GIOStatus ga_channel_write_all (GAChannel *c,const gchar *buf,gsize size) +GIOStatus ga_channel_write_all (GAChannel *c,const char *buf,size_t size) {GError *err =NULL ; -gsize written =0 ; +size_t written =0 ;GIOStatus status =G_IO_STATUS_NORMAL ;while (size) {
@@ -241,13 +241,13 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)return status; } -GIOStatus ga_channel_read (GAChannel *c,gchar *buf,gsize size,gsize *count) +GIOStatus ga_channel_read (GAChannel *c,char *buf,size_t size,size_t *count) {return g_io_channel_read_chars (c->client_channel, buf, size, count,NULL ); } -GAChannel *ga_channel_new (GAChannelMethod method,const gchar *path, -GAChannelCallback cb,gpointer opaque) +GAChannel *ga_channel_new (GAChannelMethod method,const char *path, +GAChannelCallback cb,void *opaque) {GAChannel *c =g_malloc0 (sizeof (GAChannel)); c->event_cb = cb;
qga/channel-win32.c +9 -9
@@ -9,7 +9,7 @@#include "qga/channel.h" typedef struct GAChannelReadState { - guint thread_id; + unsigned thread_id; uint8_t *buf; size_t buf_size; size_t cur; /* current buffer start */
@@ -21,7 +21,7 @@ typedef struct GAChannelReadState {struct GAChannel {HANDLE handle;GAChannelCallback cb; -gpointer user_data; +void *user_data;GAChannelReadState rstate;GIOCondition pending_events;/* TODO: use GAWatch.pollfd.revents */ GSource *source;
@@ -38,7 +38,7 @@ typedef struct GAWatch {* Called by glib prior to polling to set up poll events if polling is needed. * */ -static gboolean ga_channel_prepare (GSource *source,gint *timeout_ms) +static gboolean ga_channel_prepare (GSource *source,int *timeout_ms) {GAWatch *watch = (GAWatch *)source;GAChannel *c = (GAChannel *)watch->channel;
@@ -153,7 +153,7 @@ static gboolean ga_channel_check(GSource *source)* Called by glib after either prepare or check routines signal readiness */ static gboolean ga_channel_dispatch (GSource *source,GSourceFunc unused, -gpointer user_data) +void *user_data) {GAWatch *watch = (GAWatch *)source;GAChannel *c = (GAChannel *)watch->channel;
@@ -196,13 +196,13 @@ static GSource *ga_channel_create_watch(GAChannel *c)GAWatch *watch = (GAWatch *)source; watch->channel = c; - watch->pollfd.fd = (gintptr ) c->rstate.ov.hEvent; + watch->pollfd.fd = (int *) c->rstate.ov.hEvent;g_source_add_poll (source, &watch->pollfd);return source; } -GIOStatus ga_channel_read (GAChannel *c,char *buf,size_t size,gsize *count) +GIOStatus ga_channel_read (GAChannel *c,char *buf,size_t size,size_t *count) {GAChannelReadState *rs = &c->rstate;GIOStatus status;
@@ -285,7 +285,7 @@ GIOStatus ga_channel_write_all(GAChannel *c, const char *buf, size_t size) }static gboolean ga_channel_open (GAChannel *c,GAChannelMethod method, -const gchar *path) +const char *path) {if (!method ==GA_CHANNEL_VIRTIO_SERIAL ) {g_critical ("unsupported communication method" );
@@ -303,8 +303,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,return true; } -GAChannel *ga_channel_new (GAChannelMethod method,const gchar *path, -GAChannelCallback cb,gpointer opaque) +GAChannel *ga_channel_new (GAChannelMethod method,const char *path, +GAChannelCallback cb,void *opaque) {GAChannel *c =g_malloc0 (sizeof (GAChannel));SECURITY_ATTRIBUTES sec_attrs;
qga/channel.h +5 -5
@@ -22,12 +22,12 @@ typedef enum {GA_CHANNEL_UNIX_LISTEN , } GAChannelMethod; -typedef gboolean (*GAChannelCallback )(GIOCondition condition,gpointer opaque); +typedef gboolean (*GAChannelCallback )(GIOCondition condition,void *opaque); -GAChannel *ga_channel_new (GAChannelMethod method,const gchar *path, -GAChannelCallback cb,gpointer opaque); +GAChannel *ga_channel_new (GAChannelMethod method,const char *path, +GAChannelCallback cb,void *opaque);void ga_channel_free (GAChannel *c); -GIOStatus ga_channel_read (GAChannel *c,gchar *buf,gsize size,gsize *count); -GIOStatus ga_channel_write_all (GAChannel *c,const gchar *buf,gsize size); +GIOStatus ga_channel_read (GAChannel *c,char *buf,size_t size,size_t *count); +GIOStatus ga_channel_write_all (GAChannel *c,const char *buf,size_t size);#endif
qga/commands-posix.c +3 -3
@@ -214,7 +214,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, {GuestFileHandle *gfh =guest_file_handle_find (handle, err);GuestFileRead *read_data =NULL ; -guchar *buf; +unsigned char *buf;FILE *fh;size_t read_count;
@@ -255,8 +255,8 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, bool has_count, int64_t count, Error **err) { GuestFileWrite *write_data = NULL; -guchar *buf; -gsize buf_len; +unsigned char *buf; +size_t buf_len;int write_count;GuestFileHandle *gfh =guest_file_handle_find (handle, err);FILE *fh;
qga/commands.c +1 -1
@@ -20,7 +20,7 @@* to log for accounting purposes, check ga_logging_enabled() beforehand, * and use the QERR_QGA_LOGGING_DISABLED to generate an error */ -void slog (const gchar *fmt, ...) +void slog (const char *fmt, ...) {va_list ap;
qga/guest-agent-command-state.c +2 -2
@@ -33,7 +33,7 @@ void ga_command_state_add(GACommandState *cs, cs->groups =g_slist_append (cs->groups, cg); } -static void ga_command_group_init (gpointer opaque,gpointer unused) +static void ga_command_group_init (void *opaque,void *unused) {GACommandGroup *cg = opaque;
@@ -49,7 +49,7 @@ void ga_command_state_init_all(GACommandState *cs)g_slist_foreach (cs->groups, ga_command_group_init,NULL ); } -static void ga_command_group_cleanup (gpointer opaque,gpointer unused) +static void ga_command_group_cleanup (void *opaque,void *unused) {GACommandGroup *cg = opaque;
qga/guest-agent-core.h +1 -1
@@ -29,7 +29,7 @@ GACommandState *ga_command_state_new(void);bool ga_logging_enabled (GAState *s);void ga_disable_logging (GAState *s);void ga_enable_logging (GAState *s); -void slog (const gchar *fmt, ...); +void slog (const char *fmt, ...);void ga_set_response_delimited (GAState *s);bool ga_is_frozen (GAState *s);void ga_set_frozen (GAState *s);
qga/main.c +7 -7
@@ -230,8 +230,8 @@ void ga_enable_logging(GAState *s) s->logging_enabled = true; } -static void ga_log (const gchar *domain,GLogLevelFlags level, -const gchar *msg,gpointer opaque) +static void ga_log (const char *domain,GLogLevelFlags level, +const char *msg,void *opaque) {GAState *s = opaque;GTimeVal time;
@@ -314,7 +314,7 @@ static bool ga_open_pidfile(const char *pidfile) }#endif -static gint ga_strcmp (gconstpointer str1,gconstpointer str2) +static int ga_strcmp (const void *str1,const void *str2) {return strcmp (str1, str2); }
@@ -594,11 +594,11 @@ static void process_event(JSONMessageParser *parser, QList *tokens) }/* false return signals GAChannel to close the current client connection */ -static gboolean channel_event_cb (GIOCondition condition,gpointer data) +static gboolean channel_event_cb (GIOCondition condition,void *data) {GAState *s = data; -gchar buf[QGA_READ_COUNT_DEFAULT +1 ]; -gsize count; +char buf[QGA_READ_COUNT_DEFAULT +1 ]; +size_t count;GError *err =NULL ;GIOStatus status =ga_channel_read (s->channel, buf,QGA_READ_COUNT_DEFAULT , &count);if (err !=NULL ) {
@@ -636,7 +636,7 @@ static gboolean channel_event_cb(GIOCondition condition, gpointer data)return true; } -static gboolean channel_init (GAState *s,const gchar *method,const gchar *path) +static gboolean channel_init (GAState *s,const char *method,const char *path) {GAChannelMethod channel_method;
qom/container.c +1 -1
@@ -28,7 +28,7 @@ static void container_register_types(void)Object *container_get (Object *root,const char *path) {Object *obj, *child; -gchar **parts; +char **parts;int i; parts =g_strsplit (path,"/" ,0 );
qom/object.c +13 -13
@@ -540,8 +540,8 @@ typedef struct OCFDatavoid *opaque; } OCFData; -static void object_class_foreach_tramp (gpointer key,gpointer value, -gpointer opaque) +static void object_class_foreach_tramp (void *key,void *value, +void *opaque) {OCFData *data = opaque;TypeImpl *type = value;
@@ -868,7 +868,7 @@ static void object_get_child_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object *child = opaque; -gchar *path; +char *path; path =object_get_canonical_path (child);visit_type_str (v, &path, name, errp);
@@ -886,7 +886,7 @@ static void object_finalize_child_property(Object *obj, const char *name,void object_property_add_child (Object *obj,const char *name,Object *child,Error **errp) { -gchar *type; +char *type; type =g_strdup_printf ("child<%s>" ,object_get_typename (OBJECT (child)));
@@ -904,14 +904,14 @@ static void object_get_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; -gchar *path; +char *path;if (*child) { path =object_get_canonical_path (*child);visit_type_str (v, &path, name, errp);g_free (path); }else { - path = (gchar *)"" ; + path = (char *)"" ;visit_type_str (v, &path, name, errp); } }
@@ -924,7 +924,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,bool ambiguous = false;const char *type;char *path; -gchar *target_type; +char *target_type; type =object_property_get_type (obj, name,NULL );
@@ -967,7 +967,7 @@ void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) { - gchar *full_type; + char *full_type; full_type =g_strdup_printf ("link<%s>" , type);
@@ -979,7 +979,7 @@ void object_property_add_link(Object *obj, const char *name,g_free (full_type); } -gchar *object_get_canonical_path (Object *obj) +char *object_get_canonical_path (Object *obj) {Object *root =object_get_root ();char *newpath =NULL , *path =NULL ;
@@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj)return newpath; } -Object *object_resolve_path_component (Object *parent,const gchar *part) +Object *object_resolve_path_component (Object *parent,const char *part) {ObjectProperty *prop =object_property_find (parent, part,NULL );if (prop ==NULL ) {
@@ -1034,7 +1034,7 @@ Object *object_resolve_path_component(Object *parent, const gchar *part) }static Object *object_resolve_abs_path (Object *parent, -gchar **parts, +char **parts,const char *typename,int index) {
@@ -1057,7 +1057,7 @@ static Object *object_resolve_abs_path(Object *parent, }static Object *object_resolve_partial_path (Object *parent, -gchar **parts, +char **parts,const char *typename,bool *ambiguous) {
@@ -1098,7 +1098,7 @@ Object *object_resolve_path_type(const char *path, const char *typename, {bool partial_path = true;Object *obj; -gchar **parts; +char **parts; parts =g_strsplit (path,"/" ,0 );if (parts ==NULL || parts[0 ] ==NULL ) {
qtest.c +4 -4
@@ -187,9 +187,9 @@ static void qtest_irq_handler(void *opaque, int n, int level) } } -static void qtest_process_command (CharDriverState *chr,gchar **words) +static void qtest_process_command (CharDriverState *chr,char **words) { -const gchar *command; +const char *command;g_assert (words);
@@ -357,7 +357,7 @@ static void qtest_process_inbuf(CharDriverState *chr, GString *inbuf)while ((end =strchr (inbuf->str,'\n' )) !=NULL ) {size_t offset;GString *cmd; -gchar **words; +char **words; offset = end - inbuf->str;
@@ -376,7 +376,7 @@ static void qtest_read(void *opaque, const uint8_t *buf, int size) {CharDriverState *chr = opaque; -g_string_append_len (inbuf, (const gchar *)buf, size); +g_string_append_len (inbuf, (const char *)buf, size);qtest_process_inbuf (chr, inbuf); }
target-alpha/cpu.c +2 -2
@@ -32,7 +32,7 @@ static void alpha_cpu_realize(Object *obj, Error **errp) }/* Sort alphabetically by type name. */ -static gint alpha_cpu_list_compare (gconstpointer a,gconstpointer b) +static int alpha_cpu_list_compare (const void *a,const void *b) {ObjectClass *class_a = (ObjectClass *)a;ObjectClass *class_b = (ObjectClass *)b;
@@ -43,7 +43,7 @@ static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)return strcmp (name_a, name_b); } -static void alpha_cpu_list_entry (gpointer data,gpointer user_data) +static void alpha_cpu_list_entry (void *data,void *user_data) {ObjectClass *oc = data;CPUListState *s = user_data;
target-arm/cpu.c +1 -1
@@ -25,7 +25,7 @@#endif #include "sysemu/sysemu.h" -static void cp_reg_reset (gpointer key,gpointer value,gpointer opaque) +static void cp_reg_reset (void *key,void *value,void *opaque) {/* Reset a single ARMCPRegInfo register */ ARMCPRegInfo *ri = value;
target-arm/helper.c +2 -2
@@ -1293,7 +1293,7 @@ ARMCPU *cpu_arm_init(const char *cpu_model) }/* Sort alphabetically by type name, except for "any". */ -static gint arm_cpu_list_compare (gconstpointer a,gconstpointer b) +static int arm_cpu_list_compare (const void *a,const void *b) {ObjectClass *class_a = (ObjectClass *)a;ObjectClass *class_b = (ObjectClass *)b;
@@ -1310,7 +1310,7 @@ static gint arm_cpu_list_compare(gconstpointer a, gconstpointer b) } } -static void arm_cpu_list_entry (gpointer data,gpointer user_data) +static void arm_cpu_list_entry (void *data,void *user_data) {ObjectClass *oc = data;CPUListState *s = user_data;
target-i386/cpu.c +1 -1
@@ -1585,7 +1585,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)x86_def_t def1, *def = &def1;Error *error =NULL ;char *name, *features; -gchar **model_pieces; +char **model_pieces;memset (def,0 ,sizeof (*def));
target-m68k/helper.c +2 -2
@@ -26,7 +26,7 @@#define SIGNBIT (1u << 31)/* Sort alphabetically, except for "any". */ -static gint m68k_cpu_list_compare (gconstpointer a,gconstpointer b) +static int m68k_cpu_list_compare (const void *a,const void *b) {ObjectClass *class_a = (ObjectClass *)a;ObjectClass *class_b = (ObjectClass *)b;
@@ -43,7 +43,7 @@ static gint m68k_cpu_list_compare(gconstpointer a, gconstpointer b) } } -static void m68k_cpu_list_entry (gpointer data,gpointer user_data) +static void m68k_cpu_list_entry (void *data,void *user_data) {ObjectClass *c = data;CPUListState *s = user_data;
target-openrisc/cpu.c +2 -2
@@ -176,7 +176,7 @@ typedef struct OpenRISCCPUList { } OpenRISCCPUList;/* Sort alphabetically by type name, except for "any". */ -static gint openrisc_cpu_list_compare (gconstpointer a,gconstpointer b) +static int openrisc_cpu_list_compare (const void *a,const void *b) {ObjectClass *class_a = (ObjectClass *)a;ObjectClass *class_b = (ObjectClass *)b;
@@ -193,7 +193,7 @@ static gint openrisc_cpu_list_compare(gconstpointer a, gconstpointer b) } } -static void openrisc_cpu_list_entry (gpointer data,gpointer user_data) +static void openrisc_cpu_list_entry (void *data,void *user_data) {ObjectClass *oc = data;OpenRISCCPUList *s = user_data;
target-ppc/translate_init.c +6 -6
@@ -10234,7 +10234,7 @@ static void ppc_cpu_realize(Object *obj, Error **errp)#endif } -static gint ppc_cpu_compare_class_pvr (gconstpointer a,gconstpointer b) +static int ppc_cpu_compare_class_pvr (const void *a,const void *b) {ObjectClass *oc = (ObjectClass *)a;uint32_t pvr = *(uint32_t *)b;
@@ -10264,7 +10264,7 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr)return pcc; } -static gint ppc_cpu_compare_class_name (gconstpointer a,gconstpointer b) +static int ppc_cpu_compare_class_name (const void *a,const void *b) {ObjectClass *oc = (ObjectClass *)a;const char *name = b;
@@ -10354,7 +10354,7 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model) }/* Sort by PVR, ordering special case "host" last. */ -static gint ppc_cpu_list_compare (gconstpointer a,gconstpointer b) +static int ppc_cpu_list_compare (const void *a,const void *b) {ObjectClass *oc_a = (ObjectClass *)a;ObjectClass *oc_b = (ObjectClass *)b;
@@ -10379,7 +10379,7 @@ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b) } } -static void ppc_cpu_list_entry (gpointer data,gpointer user_data) +static void ppc_cpu_list_entry (void *data,void *user_data) {ObjectClass *oc = data;CPUListState *s = user_data;
@@ -10403,7 +10403,7 @@ void ppc_cpu_list(FILE *f, fprintf_function cpu_fprintf)g_slist_free (list); } -static void ppc_cpu_defs_entry (gpointer data,gpointer user_data) +static void ppc_cpu_defs_entry (void *data,void *user_data) {ObjectClass *oc = data;CpuDefinitionInfoList **first = user_data;
@@ -10450,7 +10450,7 @@ static void ppc_cpu_register_model(const ppc_def_t *def) type_info.name =g_strdup_printf ("%s-" TYPE_POWERPC_CPU , def->name),type_register (&type_info); -g_free ((gpointer )type_info.name); +g_free ((void *)type_info.name); }/* CPUClass::reset() */
tests/libqtest.c +10 -10
@@ -39,7 +39,7 @@ struct QTestStateint qmp_fd;bool irq_level[MAX_IRQ ];GString *rx; -gchar *pid_file; +char *pid_file;char *socket_path, *qmp_socket_path; };
@@ -105,8 +105,8 @@ QTestState *qtest_init(const char *extra_args) {QTestState *s;int sock, qmpsock, ret, i; -gchar *pid_file; -gchar *command; +char *pid_file; +char *command;const char *qemu_binary;pid_t pid;
@@ -179,7 +179,7 @@ void qtest_quit(QTestState *s)static void socket_sendf (int fd,const char *fmt,va_list ap) { -gchar *str; +char *str;size_t size, offset; str =g_strdup_vprintf (fmt, ap);
@@ -240,10 +240,10 @@ static GString *qtest_recv_line(QTestState *s)return line; } -static gchar **qtest_rsp (QTestState *s,int expected_args) +static char **qtest_rsp (QTestState *s,int expected_args) {GString *line; -gchar **words; +char **words;int i; redo:
@@ -341,7 +341,7 @@ bool qtest_get_irq(QTestState *s, int num)static int64_t qtest_clock_rsp (QTestState *s) { -gchar **words; +char **words;int64_t clock; words =qtest_rsp (s,2 ); clock =g_ascii_strtoll (words[1 ],NULL ,0 );
@@ -402,7 +402,7 @@ void qtest_outl(QTestState *s, uint16_t addr, uint32_t value)static uint32_t qtest_in (QTestState *s,const char *cmd,uint16_t addr) { -gchar **args; +char **args;uint32_t value;qtest_sendf (s,"%s 0x%x\n" , cmd, addr);
@@ -444,7 +444,7 @@ static int hex2nib(char ch)void qtest_memread (QTestState *s,uint64_t addr,void *data,size_t size) {uint8_t *ptr = data; -gchar **args; +char **args;size_t i;qtest_sendf (s,"read 0x%" PRIx64" 0x%zx\n" , addr, size);
@@ -460,7 +460,7 @@ void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size)void qtest_add_func (const char *str,void (*fn)) { -gchar *path =g_strdup_printf ("/%s/%s" ,qtest_get_arch (), str); +char *path =g_strdup_printf ("/%s/%s" ,qtest_get_arch (), str);g_test_add_func (path, fn); }
tests/test-visitor-serialization.c +6 -6
@@ -230,17 +230,17 @@ typedef struct TestArgs { } TestArgs;#define FLOAT_STRING_PRECISION 6/* corresponding to n in %.nf formatting */ -static gsize calc_float_string_storage (double value) +static size_t calc_float_string_storage (double value) {int whole_value = value; -gsize i =0 ; +size_t i =0 ;do { i++; }while (whole_value /=10 );return i +2 +FLOAT_STRING_PRECISION ; } -static void test_primitives (gconstpointer opaque) +static void test_primitives (const void *opaque) {TestArgs *args = (TestArgs *) opaque;const SerializeOps *ops = args->ops;
@@ -277,7 +277,7 @@ static void test_primitives(gconstpointer opaque)g_free (args); } -static void test_struct (gconstpointer opaque) +static void test_struct (const void *opaque) {TestArgs *args = (TestArgs *) opaque;const SerializeOps *ops = args->ops;
@@ -299,7 +299,7 @@ static void test_struct(gconstpointer opaque)g_free (args); } -static void test_nested_struct (gconstpointer opaque) +static void test_nested_struct (const void *opaque) {TestArgs *args = (TestArgs *) opaque;const SerializeOps *ops = args->ops;
@@ -321,7 +321,7 @@ static void test_nested_struct(gconstpointer opaque)g_free (args); } -static void test_nested_struct_list (gconstpointer opaque) +static void test_nested_struct_list (const void *opaque) {TestArgs *args = (TestArgs *) opaque;const SerializeOps *ops = args->ops;
trace/simple.c +4 -4
@@ -152,7 +152,7 @@ static void wait_for_trace_records_available(void)g_static_mutex_unlock (&trace_lock); } -static gpointer writeout_thread (gpointer opaque) +static void *writeout_thread (void *opaque) {TraceRecord *recordptr;union {
@@ -173,7 +173,7 @@ static gpointer writeout_thread(gpointer opaque) dropped.rec.reserved =0 ;while (1 ) { dropped_count = dropped_events; -if (g_atomic_int_compare_and_exchange ((gint *)&dropped_events, +if (g_atomic_int_compare_and_exchange ((int *)&dropped_events, dropped_count,0 )) {break ; }
@@ -220,11 +220,11 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasiif (new_idx - writeout_idx >TRACE_BUF_LEN ) {/* Trace Buffer Full, Event dropped ! */ -g_atomic_int_inc ((gint *)&dropped_events); +g_atomic_int_inc ((int *)&dropped_events);return -ENOSPC ; } -if (g_atomic_int_compare_and_exchange ((gint *)&trace_idx, +if (g_atomic_int_compare_and_exchange ((int *)&trace_idx, old_idx, new_idx)) {break ; }
vl.c +3 -3
@@ -2641,21 +2641,21 @@ static const QEMUOption *lookup_opt(int argc, char **argv,return popt; } -static gpointer malloc_and_trace (gsize n_bytes) +static void *malloc_and_trace (size_t n_bytes) {void *ptr =malloc (n_bytes);trace_g_malloc (n_bytes, ptr);return ptr; } -static gpointer realloc_and_trace (gpointer mem,gsize n_bytes) +static void *realloc_and_trace (void *mem,size_t n_bytes) {void *ptr =realloc (mem, n_bytes);trace_g_realloc (mem, n_bytes, ptr);return ptr; } -static void free_and_trace (gpointer mem) +static void free_and_trace (void *mem) {trace_g_free (mem);free (mem);
Signature · 1 line
1.7.11.7
PATCH 2/3 Purge GLib's gboolean, it's a trap for the unwary
In reply to Markus ArmbrusterDespite its name, gboolean is an alias for int, *not* for _Bool. If you forget that, and compare gboolean values to TRUE, you're in trouble.
Instead of blindly replacing gboolean by int, replace it by int exactly where that's needed for type-correctness, and by bool everywhere else.
--- async.c | 6 +++--- hw/fw_cfg.c | 2 +- hw/xen_disk.c | 2 +- qapi/opts-visitor.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qemu-img.c | 2 +- qga/channel-posix.c | 13 +++++++------ qga/channel-win32.c | 10 +++++----- qga/channel.h | 2 +- qga/main.c | 6 +++--- 10 files changed, 24 insertions(+), 23 deletions(-)
async.c +3 -3
@@ -117,7 +117,7 @@ void qemu_bh_delete(QEMUBH *bh) bh->deleted =1 ; } -static gboolean +static int aio_ctx_prepare (GSource *source,int *timeout) {AioContext *ctx = (AioContext *) source;
@@ -141,7 +141,7 @@ aio_ctx_prepare(GSource *source, int *timeout)return false; } -static gboolean +static int aio_ctx_check (GSource *source) {AioContext *ctx = (AioContext *) source;
@@ -155,7 +155,7 @@ aio_ctx_check(GSource *source)return aio_pending (ctx); } -static gboolean +static int aio_ctx_dispatch (GSource *source,GSourceFunc callback,void *user_data) {AioContext *ctx = (AioContext *) source;
hw/fw_cfg.c +1 -1
@@ -66,7 +66,7 @@ struct FWCfgState {static char *read_splashfile (char *filename,int *file_sizep,int *file_typep) {GError *err =NULL ; -gboolean res; +bool res;char *content;int file_type =-1 ;unsigned int filehead =0 ;
hw/xen_disk.c +1 -1
@@ -113,7 +113,7 @@ struct XenBlkDev {int requests_finished;/* Persistent grants extension */ -gboolean feature_persistent; +bool feature_persistent;GTree *persistent_gnts;unsigned int persistent_gnt_count;unsigned int max_grants;
qapi/opts-visitor.c +1 -1
@@ -105,7 +105,7 @@ opts_start_struct(Visitor *v, void **obj, const char *kind, } -static gboolean +static int ghr_true (void *ign_key,void *ign_value,void *ign_user_data) {return TRUE;
qapi/qmp-input-visitor.c +1 -1
@@ -88,7 +88,7 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp) }/** Only for qmp_input_pop. */ -static gboolean always_true (void *key,void *val,void *user_pkey) +static int always_true (void *key,void *val,void *user_pkey) { *(const char **)user_pkey = (const char *)key;return TRUE;
qemu-img.c +1 -1
@@ -1315,7 +1315,7 @@ static void dump_human_image_info_list(ImageInfoList *list) } } -static gboolean str_equal_func (const void *a,const void *b) +static int str_equal_func (const void *a,const void *b) {return strcmp (a, b) ==0 ; }
qga/channel-posix.c +7 -6
@@ -25,8 +25,8 @@ struct GAChannel {static int ga_channel_client_add (GAChannel *c,int fd); -static gboolean ga_channel_listen_accept (GIOChannel *channel, -GIOCondition condition,void *data) +static int ga_channel_listen_accept (GIOChannel *channel, +GIOCondition condition,void *data) {GAChannel *c = data;int ret, client_fd;
@@ -90,11 +90,11 @@ static void ga_channel_client_close(GAChannel *c) } } -static gboolean ga_channel_client_event (GIOChannel *channel, -GIOCondition condition,void *data) +static int ga_channel_client_event (GIOChannel *channel, +GIOCondition condition,void *data) {GAChannel *c = data; -gboolean client_cont; +bool client_cont;g_assert (c);if (c->event_cb) {
@@ -127,7 +127,8 @@ static int ga_channel_client_add(GAChannel *c, int fd)return 0 ; } -static gboolean ga_channel_open (GAChannel *c,const char *path,GAChannelMethod method) +static bool ga_channel_open (GAChannel *c,const char *path, +GAChannelMethod method) {int ret; c->method = method;
qga/channel-win32.c +5 -5
@@ -38,7 +38,7 @@ typedef struct GAWatch {* Called by glib prior to polling to set up poll events if polling is needed. * */ -static gboolean ga_channel_prepare (GSource *source,int *timeout_ms) +static int ga_channel_prepare (GSource *source,int *timeout_ms) {GAWatch *watch = (GAWatch *)source;GAChannel *c = (GAChannel *)watch->channel;
@@ -95,7 +95,7 @@ out:/* * Called by glib after an outstanding read request is completed. */ -static gboolean ga_channel_check (GSource *source) +static int ga_channel_check (GSource *source) {GAWatch *watch = (GAWatch *)source;GAChannel *c = (GAChannel *)watch->channel;
@@ -152,13 +152,13 @@ static gboolean ga_channel_check(GSource *source)/* * Called by glib after either prepare or check routines signal readiness */ -static gboolean ga_channel_dispatch (GSource *source,GSourceFunc unused, +static int ga_channel_dispatch (GSource *source,GSourceFunc unused,void *user_data) {GAWatch *watch = (GAWatch *)source;GAChannel *c = (GAChannel *)watch->channel;GAChannelReadState *rs = &c->rstate; -gboolean success; +bool success;g_debug ("dispatch" ); success = c->cb (watch->pollfd.revents, c->user_data);
@@ -284,7 +284,7 @@ GIOStatus ga_channel_write_all(GAChannel *c, const char *buf, size_t size)return status; } -static gboolean ga_channel_open (GAChannel *c,GAChannelMethod method, +static bool ga_channel_open (GAChannel *c,GAChannelMethod method,const char *path) {if (!method ==GA_CHANNEL_VIRTIO_SERIAL ) {
qga/channel.h +1 -1
@@ -22,7 +22,7 @@ typedef enum {GA_CHANNEL_UNIX_LISTEN , } GAChannelMethod; -typedef gboolean (*GAChannelCallback )(GIOCondition condition,void *opaque); +typedef bool (*GAChannelCallback )(GIOCondition condition,void *opaque);GAChannel *ga_channel_new (GAChannelMethod method,const char *path,GAChannelCallback cb,void *opaque);
qga/main.c +3 -3
@@ -115,7 +115,7 @@ static void quit_handler(int sig) }#ifndef _WIN32 -static gboolean register_signal_handlers (void ) +static bool register_signal_handlers (void ) {struct sigaction sigact;int ret;
@@ -594,7 +594,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens) }/* false return signals GAChannel to close the current client connection */ -static gboolean channel_event_cb (GIOCondition condition,void *data) +static bool channel_event_cb (GIOCondition condition,void *data) {GAState *s = data;char buf[QGA_READ_COUNT_DEFAULT +1 ];
@@ -636,7 +636,7 @@ static gboolean channel_event_cb(GIOCondition condition, void *data)return true; } -static gboolean channel_init (GAState *s,const char *method,const char *path) +static bool channel_init (GAState *s,const char *method,const char *path) {GAChannelMethod channel_method;
Signature · 1 line
1.7.11.7
PATCH 3/3 checkpatch: Keep out the GLib silliness we just purged
In reply to Markus Armbruster--- scripts/checkpatch.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
scripts/checkpatch.pl +29 -0
@@ -2876,6 +2876,35 @@ sub process { if ($rawline =~ /\b(?:Qemu|QEmu)\b/) { WARN("use QEMU instead of Qemu or QEmu\n" . $herecurr); } + + if ($line =~ /\b(gboolean|gpointer|gconstpointer|gchar|guchar + |gint|G_MININT|G_MAXINT|guint|G_MAXUINT|gshort + |G_MINSHORT|G_MAXSHORT|gushort|G_MAXUSHORT + |glong|G_MINLONG|G_MAXLONG|gulong|G_MAXULONG + |gint8|G_MININT8|G_MAXINT8|guint8|G_MAXUINT8 + |gint16|G_MININT16|G_MAXINT16|G_GINT16_MODIFIER + |G_GINT16_FORMAT|guint16|G_MAXUINT16 + |G_GUINT16_FORMAT|gint32|G_MININT32|G_MAXINT32 + |G_GINT32_MODIFIER|G_GINT32_FORMAT|guint32 + |G_MAXUINT32|G_GUINT32_FORMAT|gint64|G_MININT64 + |G_MAXINT64|G_GINT64_MODIFIER|G_GINT64_FORMAT + |G_GINT64_CONSTANT|guint64|G_MAXUINT64 + |G_GUINT64_FORMAT|G_GUINT64_CONSTANT|gfloat + |G_MINFLOAT|G_MAXFLOAT|gdouble|G_MINDOUBLE + |G_MAXDOUBLE|gsize|G_MAXSIZE|G_GSIZE_MODIFIER + |G_GSIZE_FORMAT|gssize|G_MINSSIZE|G_MAXSSIZE + |G_GSSIZE_FORMAT|goffset|G_MINOFFSET + |G_MAXOFFSET|G_GOFFSET_MODIFIER + |G_GOFFSET_FORMAT|G_GOFFSET_CONSTANT|gintptr + |G_GINTPTR_MODIFIER|G_GINTPTR_FORMAT|guintptr + |G_GUINTPTR_FORMAT|G_STRUCT_MEMBER + |G_STRUCT_MEMBER_P|G_STRUCT_OFFSET + |G_CONST_RETURN|G_N_ELEMENTS|GINT_TO_POINTER + |GPOINTER_TO_INT|GUINT_TO_POINTER + |GPOINTER_TO_UINT|GSIZE_TO_POINTER + |GPOINTER_TO_SIZE)\b/x) { + WARN("Please use standard C names instead of glib aliases like $1\n" . $herecurr); + } } # If we have no input at all, then there is nothing to report on
Signature · 1 line
1.7.11.7
Quoted 6 lines · Markus Armbruster
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purged
Changing QEMU code to work around checkpatch's failing is insane.
When interacting with glib, use glib types. Not using those types just makes the code more difficult to understand.
Regards,
Anthony Liguori
Quoted 40 lines
async.c | 12 +++++------- coroutine-gthread.c | 8 ++++---- hw/9pfs/virtio-9p-coth.c | 2 +- hw/fw_cfg.c | 6 +++--- hw/qdev-monitor.c | 2 +- hw/qdev.c | 4 ++-- hw/xen_disk.c | 6 +++--- include/qom/object.h | 8 ++++---- main-loop.c | 2 +- qapi/opts-visitor.c | 10 +++++----- qapi/qmp-input-visitor.c | 4 ++-- qemu-img.c | 4 ++-- qga/channel-posix.c | 25 +++++++++++++------------ qga/channel-win32.c | 26 +++++++++++++------------- qga/channel.h | 10 +++++----- qga/commands-posix.c | 6 +++--- qga/commands.c | 2 +- qga/guest-agent-command-state.c | 4 ++-- qga/guest-agent-core.h | 2 +- qga/main.c | 16 ++++++++-------- qom/container.c | 2 +- qom/object.c | 26 +++++++++++++------------- qtest.c | 8 ++++---- scripts/checkpatch.pl | 29 +++++++++++++++++++++++++++++ target-alpha/cpu.c | 4 ++-- target-arm/cpu.c | 2 +- target-arm/helper.c | 4 ++-- target-i386/cpu.c | 2 +- target-m68k/helper.c | 4 ++-- target-openrisc/cpu.c | 4 ++-- target-ppc/translate_init.c | 12 ++++++------ tests/libqtest.c | 20 ++++++++++---------- tests/test-visitor-serialization.c | 12 ++++++------ trace/simple.c | 8 ++++---- vl.c | 6 +++--- 35 files changed, 165 insertions(+), 137 deletions(-)Signature · 1 line
1.7.11.7
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Markus Armbruster
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purged
Quoted 4 lines
Changing QEMU code to work around checkpatch's failing is insane.
When interacting with glib, use glib types. Not using those types just makes the code more difficult to understand.
While the types are indeed useless and even cause problems (gboolean), I agree with Anthony. It's the same as using DWORD for Win32 APIs.
Maybe a smaller patch would make sense that minimizes the use of the types to only GLib API calls and the variables nearby. Also if there are real conversion problems with gboolean, those should be fixed.
Quoted 45 lines
Regards,
Anthony Liguori
Quoted 40 lines
async.c | 12 +++++------- coroutine-gthread.c | 8 ++++---- hw/9pfs/virtio-9p-coth.c | 2 +- hw/fw_cfg.c | 6 +++--- hw/qdev-monitor.c | 2 +- hw/qdev.c | 4 ++-- hw/xen_disk.c | 6 +++--- include/qom/object.h | 8 ++++---- main-loop.c | 2 +- qapi/opts-visitor.c | 10 +++++----- qapi/qmp-input-visitor.c | 4 ++-- qemu-img.c | 4 ++-- qga/channel-posix.c | 25 +++++++++++++------------ qga/channel-win32.c | 26 +++++++++++++------------- qga/channel.h | 10 +++++----- qga/commands-posix.c | 6 +++--- qga/commands.c | 2 +- qga/guest-agent-command-state.c | 4 ++-- qga/guest-agent-core.h | 2 +- qga/main.c | 16 ++++++++-------- qom/container.c | 2 +- qom/object.c | 26 +++++++++++++------------- qtest.c | 8 ++++---- scripts/checkpatch.pl | 29 +++++++++++++++++++++++++++++ target-alpha/cpu.c | 4 ++-- target-arm/cpu.c | 2 +- target-arm/helper.c | 4 ++-- target-i386/cpu.c | 2 +- target-m68k/helper.c | 4 ++-- target-openrisc/cpu.c | 4 ++-- target-ppc/translate_init.c | 12 ++++++------ tests/libqtest.c | 20 ++++++++++---------- tests/test-visitor-serialization.c | 12 ++++++------ trace/simple.c | 8 ++++---- vl.c | 6 +++--- 35 files changed, 165 insertions(+), 137 deletions(-)--
1.7.11.7
Quoted 10 lines · Blue Swirl
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Markus Armbruster
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purged
Quoted 7 lines
Quoted 4 lines
Changing QEMU code to work around checkpatch's failing is insane.
When interacting with glib, use glib types. Not using those types just makes the code more difficult to understand.
While the types are indeed useless and even cause problems (gboolean), I agree with Anthony. It's the same as using DWORD for Win32 APIs.
Actually it is far from DWORD. DWORD is like uint32_t, where no standard C type matches (since these depends on the word size etc). So in Win32, these DWORDs are justified.
With GLib, things are sillier than that, since they redefine _standard_ C types, without gaining anything in portability.
/mjt
Quoted 21 lines · Michael Tokarev
Quoted 20 lines · Blue Swirl
Quoted 15 lines · Anthony Liguori
Quoted 6 lines · Markus Armbruster
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purgedChanging QEMU code to work around checkpatch's failing is insane.
When interacting with glib, use glib types. Not using those types just makes the code more difficult to understand.
Quoted 7 lines
Quoted 2 lines
While the types are indeed useless and even cause problems (gboolean), I agree with Anthony. It's the same as using DWORD for Win32 APIs.
Actually it is far from DWORD. DWORD is like
uint32_t, where no standard C type matches (since these depends on the word size etc). So in Win32, these DWORDs are justified.
I think they are historic remnants of Win16. The machine word size has not been 16 bits since ages and so double word should be 2 * 32 = 64 bits on Win32, QWORD should be 256 bits on Win64.
MS could have started using the standard types at some point: uint32_t if the API needs 32 bits, long or intptr_t for machine words etc. I don't agree with their compatibility strategy, but I don't appreciate very much the Linux version (no ABI breakages ever) either.
Quoted 5 lines
With GLib, things are sillier than that, since they redefine _standard_ C types, without gaining anything in portability.
/mjt
Quoted 19 lines · Michael Tokarev
Quoted 10 lines · Blue Swirl
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Markus Armbruster
See PATCH 1/3 for rationale.
Markus Armbruster (3):
Purge the silly GLib "Basic Types", except for gboolean Purge GLib's gboolean, it's a trap for the unwary
checkpatch: Keep out the GLib silliness we just purgedQuoted 7 lines
Quoted 4 lines
Changing QEMU code to work around checkpatch's failing is insane.
When interacting with glib, use glib types. Not using those types just makes the code more difficult to understand.
While the types are indeed useless and even cause problems (gboolean), I agree with Anthony. It's the same as using DWORD for Win32 APIs.
Quoted 6 lines
Actually it is far from DWORD. DWORD is like
uint32_t, where no standard C type matches (since these depends on the word size etc). So in Win32, these DWORDs are justified.With GLib, things are sillier than that, since they redefine _standard_ C types, without gaining anything in portability.
glib predates "standard C types". They were only introduced in C99 and weren't widely available until a few years later.
There are reasons for all of it. For instance, there was a time when not all C compilers supported const so if you wanted to use it you had to #define around it. gconstpointer was a trick to make use of const while still supporting older compilers. Likewise, bool is a relatively new thing so gboolean made sense at the time. The lack of stdint led to g[u]int{8,16,32,64} and once you have all of that, gint and guint are pretty obvious.
We should not use these types pervasively in QEMU, of course preferring more modern standard C99, but when glib takes a callback of:
gboolean (*GSourceFunc)(gpointer data)
Then the most readable thing to do is to write your callback following that signature.
Regards,
Anthony Liguori
Quoted 2 lines
/mjt