mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
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
3ad375a629
, 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
This commit is contained in:
@@ -603,7 +603,7 @@ g_bus_watch_name (GBusType bus_type,
|
||||
|
||||
client = g_new0 (Client, 1);
|
||||
client->ref_count = 1;
|
||||
client->id = g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->id = (guint) g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->name = g_strdup (name);
|
||||
client->flags = flags;
|
||||
client->name_appeared_handler = name_appeared_handler;
|
||||
@@ -665,7 +665,7 @@ guint g_bus_watch_name_on_connection (GDBusConnection *connection,
|
||||
|
||||
client = g_new0 (Client, 1);
|
||||
client->ref_count = 1;
|
||||
client->id = g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->id = (guint) g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->name = g_strdup (name);
|
||||
client->flags = flags;
|
||||
client->name_appeared_handler = name_appeared_handler;
|
||||
|
Reference in New Issue
Block a user