diff options
author | Philip Withnall <withnall@endlessm.com> | 2019-09-21 10:45:36 +0200 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2019-09-21 10:48:23 +0200 |
commit | 55f9c6d2f422a12ecc84ada71dc3a596329b40e3 (patch) | |
tree | f9e7d672a48a27b1aed90076ca4e25929866bae7 /gio/gdbusconnection.c | |
parent | 3ad375a629c91a27d0165a31f0ed298fd553de0a (diff) | |
download | glib-55f9c6d2f422a12ecc84ada71dc3a596329b40e3.tar.gz |
gatomic: Add various casts to use of g_atomic_*()s to fix warnings
When compiling GLib with `-Wsign-conversion`, we get various warnings
about the atomic calls. A lot of these were fixed by
3ad375a629c91a27d0165a31f0ed298fd553de0a, but some remain. Fix them by
adding appropriate casts at the call sites.
Note that `g_atomic_int_{and,or,xor}()` actually all operate on `guint`s
rather than `gint`s (which is what the rest of the `g_atomic_int_*()`
functions operate on). I can’t find any written reasoning for this, but
assume that it’s because signedness is irrelevant when you’re using an
integer as a bit field. It’s unfortunate that they’re named a
`g_atomic_int_*()` rather than `g_atomic_uint_*()` functions.
Tested by compiling GLib as:
```
CFLAGS=-Wsign-conversion jhbuild make -ac |& grep atomic
```
I’m not going to add `-Wsign-conversion` to the set of default warnings
for building GLib, because it mostly produces false positives throughout
the rest of GLib.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #1565
Diffstat (limited to 'gio/gdbusconnection.c')
-rw-r--r-- | gio/gdbusconnection.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index f1f0921d4..3411033f3 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -3148,7 +3148,7 @@ g_dbus_connection_add_filter (GDBusConnection *connection, CONNECTION_LOCK (connection); data = g_new0 (FilterData, 1); - data->id = g_atomic_int_add (&_global_filter_id, 1); /* TODO: overflow etc. */ + data->id = (guint) g_atomic_int_add (&_global_filter_id, 1); /* TODO: overflow etc. */ data->ref_count = 1; data->filter_function = filter_function; data->user_data = user_data; @@ -3508,7 +3508,7 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection, subscriber.callback = callback; subscriber.user_data = user_data; subscriber.user_data_free_func = user_data_free_func; - subscriber.id = g_atomic_int_add (&_global_subscriber_id, 1); /* TODO: overflow etc. */ + subscriber.id = (guint) g_atomic_int_add (&_global_subscriber_id, 1); /* TODO: overflow etc. */ subscriber.context = g_main_context_ref_thread_default (); /* see if we've already have this rule */ @@ -5198,7 +5198,7 @@ g_dbus_connection_register_object (GDBusConnection *connection, } ei = g_new0 (ExportedInterface, 1); - ei->id = g_atomic_int_add (&_global_registration_id, 1); /* TODO: overflow etc. */ + ei->id = (guint) g_atomic_int_add (&_global_registration_id, 1); /* TODO: overflow etc. */ ei->eo = eo; ei->user_data = user_data; ei->user_data_free_func = user_data_free_func; @@ -6858,7 +6858,7 @@ g_dbus_connection_register_subtree (GDBusConnection *connection, es->vtable = _g_dbus_subtree_vtable_copy (vtable); es->flags = flags; - es->id = g_atomic_int_add (&_global_subtree_registration_id, 1); /* TODO: overflow etc. */ + es->id = (guint) g_atomic_int_add (&_global_subtree_registration_id, 1); /* TODO: overflow etc. */ es->user_data = user_data; es->user_data_free_func = user_data_free_func; es->context = g_main_context_ref_thread_default (); |