Merge branch 'wsign-conversion2' into 'main'

Enable -Wsign-conversion for gobject directory

Closes #3405

See merge request GNOME/glib!4593
This commit is contained in:
Philip Withnall 2025-04-22 21:31:41 +00:00
commit 988db0e89d
31 changed files with 261 additions and 185 deletions

View File

@ -182,7 +182,7 @@ g_bsearch_array_get_index (GBSearchArray *barray,
const GBSearchConfig *bconfig,
gconstpointer node_in_array)
{
guint distance = ((guint8*) node_in_array) - G_BSEARCH_ARRAY_NODES (barray);
size_t distance = (size_t) (((guint8*) node_in_array) - G_BSEARCH_ARRAY_NODES (barray));
g_return_val_if_fail (node_in_array != NULL, barray->n_nodes);

View File

@ -214,6 +214,38 @@ g_string_new_len (const gchar *init,
}
}
/**
* g_string_copy:
* @string: a string
*
* Copies the [struct@GLib.String] instance and its contents.
*
* This will preserve the allocation length of the [struct@GLib.String] in the
* copy.
*
* Returns: (transfer full): a copy of @string
* Since: 2.86
*/
GString *
g_string_copy (GString *string)
{
GString *copy = NULL;
g_return_val_if_fail (string != NULL, NULL);
copy = g_slice_new (GString);
copy->allocated_len = string->allocated_len;
copy->len = string->len;
/* We cant just strdup(string->str) here because it may contain embedded nuls. */
copy->str = g_malloc (string->allocated_len);
if (string->str != NULL && string->len > 0)
memcpy (copy->str, string->str, string->len);
copy->str[copy->len] = '\0';
return g_steal_pointer (&copy);
}
/**
* g_string_free:
* @string: (transfer full): a #GString

View File

@ -58,6 +58,8 @@ GString* g_string_new_len (const gchar *init,
gssize len);
GLIB_AVAILABLE_IN_ALL
GString* g_string_sized_new (gsize dfl_size);
GLIB_AVAILABLE_IN_2_86
GString *g_string_copy (GString *string);
GLIB_AVAILABLE_IN_ALL
gchar* (g_string_free) (GString *string,
gboolean free_segment);

View File

@ -767,35 +767,70 @@ test_string_new_take_null (void)
g_string_free (g_steal_pointer (&string), TRUE);
}
static void
test_string_copy (void)
{
GString *string1 = NULL, *string2 = NULL;
string1 = g_string_new ("hello");
string2 = g_string_copy (string1);
g_assert_cmpstr (string1->str, ==, string2->str);
g_assert_true (string1->str != string2->str);
g_assert_cmpuint (string1->len, ==, string2->len);
g_assert_cmpuint (string2->allocated_len, ==, string2->allocated_len);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
string1 = g_string_sized_new (100);
string2 = g_string_copy (string1);
g_assert_cmpstr (string1->str, ==, string2->str);
g_assert_true (string1->str != string2->str);
g_assert_cmpuint (string1->len, ==, string2->len);
g_assert_cmpuint (string2->allocated_len, ==, string2->allocated_len);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
string1 = g_string_sized_new (200);
g_string_append_len (string1, "test with embedded\0nuls", 25);
string2 = g_string_copy (string1);
g_assert_cmpmem (string1->str, string1->len, string2->str, string2->len);
g_assert_true (string1->str != string2->str);
g_assert_cmpuint (string1->len, ==, string2->len);
g_assert_cmpuint (string2->allocated_len, ==, string2->allocated_len);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/string/test-string-chunks", test_string_chunks);
g_test_add_func ("/string/test-string-chunk-insert", test_string_chunk_insert);
g_test_add_func ("/string/test-string-new", test_string_new);
g_test_add_func ("/string/test-string-printf", test_string_printf);
g_test_add_func ("/string/test-string-assign", test_string_assign);
g_test_add_func ("/string/test-string-append-c", test_string_append_c);
g_test_add_func ("/string/test-string-append", test_string_append);
g_test_add_func ("/string/test-string-append-vprintf", test_string_append_vprintf);
g_test_add_func ("/string/test-string-prepend-c", test_string_prepend_c);
g_test_add_func ("/string/test-string-prepend", test_string_prepend);
g_test_add_func ("/string/test-string-insert", test_string_insert);
g_test_add_func ("/string/test-string-insert-unichar", test_string_insert_unichar);
g_test_add_func ("/string/test-string-equal", test_string_equal);
g_test_add_func ("/string/test-string-truncate", test_string_truncate);
g_test_add_func ("/string/test-string-overwrite", test_string_overwrite);
g_test_add_func ("/string/test-string-nul-handling", test_string_nul_handling);
g_test_add_func ("/string/test-string-up-down", test_string_up_down);
g_test_add_func ("/string/test-string-set-size", test_string_set_size);
g_test_add_func ("/string/test-string-to-bytes", test_string_to_bytes);
g_test_add_func ("/string/test-string-replace", test_string_replace);
g_test_add_func ("/string/test-string-steal", test_string_steal);
g_test_add_func ("/string/test-string-new-take", test_string_new_take);
g_test_add_func ("/string/test-string-new-take/null", test_string_new_take_null);
g_test_add_func ("/string/chunks", test_string_chunks);
g_test_add_func ("/string/chunk-insert", test_string_chunk_insert);
g_test_add_func ("/string/new", test_string_new);
g_test_add_func ("/string/printf", test_string_printf);
g_test_add_func ("/string/assign", test_string_assign);
g_test_add_func ("/string/append-c", test_string_append_c);
g_test_add_func ("/string/append", test_string_append);
g_test_add_func ("/string/append-vprintf", test_string_append_vprintf);
g_test_add_func ("/string/prepend-c", test_string_prepend_c);
g_test_add_func ("/string/prepend", test_string_prepend);
g_test_add_func ("/string/insert", test_string_insert);
g_test_add_func ("/string/insert-unichar", test_string_insert_unichar);
g_test_add_func ("/string/equal", test_string_equal);
g_test_add_func ("/string/truncate", test_string_truncate);
g_test_add_func ("/string/overwrite", test_string_overwrite);
g_test_add_func ("/string/nul-handling", test_string_nul_handling);
g_test_add_func ("/string/up-down", test_string_up_down);
g_test_add_func ("/string/set-size", test_string_set_size);
g_test_add_func ("/string/to-bytes", test_string_to_bytes);
g_test_add_func ("/string/replace", test_string_replace);
g_test_add_func ("/string/steal", test_string_steal);
g_test_add_func ("/string/new-take", test_string_new_take);
g_test_add_func ("/string/new-take/null", test_string_new_take_null);
g_test_add_func ("/string/copy", test_string_copy);
return g_test_run();
}

View File

@ -1250,7 +1250,7 @@ g_object_bind_property_full (gpointer source,
if ((flags & G_BINDING_INVERT_BOOLEAN) &&
(transform_to != NULL || transform_from != NULL))
{
flags &= ~G_BINDING_INVERT_BOOLEAN;
flags &= (unsigned) ~G_BINDING_INVERT_BOOLEAN;
}
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (source), source_property);

View File

@ -96,12 +96,6 @@ _g_boxed_type_init (void)
g_assert (type == G_TYPE_BOXED);
}
static GString *
gstring_copy (GString *src_gstring)
{
return g_string_new_len (src_gstring->str, src_gstring->len);
}
static void
gstring_free (GString *gstring)
{
@ -113,7 +107,7 @@ G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free)
G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
G_DEFINE_BOXED_TYPE (GDate, g_date, g_date_copy, g_date_free)
/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free)
G_DEFINE_BOXED_TYPE (GString, g_gstring, g_string_copy, gstring_free)
G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_unref)
G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)

View File

@ -95,11 +95,11 @@
#define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
#define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
#define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
#define CLOSURE_N_MFUNCS(cl) (((cl)->n_guards << 1L))
#define CLOSURE_N_MFUNCS(cl) ((size_t) ((cl)->n_guards << 1L))
/* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
#define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
#define CLOSURE_N_NOTIFIERS(cl) ((size_t) (CLOSURE_N_MFUNCS (cl) + \
(cl)->n_fnotifiers + \
(cl)->n_inotifiers)
(cl)->n_inotifiers))
/* A copy of the flags bitfield from the beginning of `struct _GClosure`, which
* is in union with an int for atomic access to all fields at the same time.
@ -223,7 +223,7 @@ g_closure_new_simple (guint sizeof_closure,
gpointer data)
{
GClosure *closure;
gint private_size;
size_t private_size;
gchar *allocated;
g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
@ -1316,7 +1316,7 @@ value_to_ffi_type (const GValue *gvalue,
case G_TYPE_FLAGS:
g_assert (enum_tmpval != NULL);
rettype = &ffi_type_uint;
*enum_tmpval = g_value_get_flags (gvalue);
*enum_tmpval = (int) g_value_get_flags (gvalue);
*value = enum_tmpval;
*tmpval_used = TRUE;
break;
@ -1560,10 +1560,10 @@ g_cclosure_marshal_generic (GClosure *closure,
{
ffi_type *rtype;
void *rvalue;
int n_args;
size_t n_args;
ffi_type **atypes;
void **args;
int i;
size_t i;
ffi_cif cif;
GCClosure *cc = (GCClosure*) closure;
gint *enum_tmpval;
@ -1659,17 +1659,22 @@ g_cclosure_marshal_generic_va (GClosure *closure,
{
ffi_type *rtype;
void *rvalue;
int n_args;
size_t n_args;
size_t unsigned_n_params;
ffi_type **atypes;
void **args;
va_arg_storage *storage;
int i;
size_t i;
ffi_cif cif;
GCClosure *cc = (GCClosure*) closure;
gint *enum_tmpval;
gboolean tmpval_used = FALSE;
va_list args_copy;
g_return_if_fail (n_params >= 0);
unsigned_n_params = (size_t) n_params;
enum_tmpval = g_alloca (sizeof (gint));
if (return_value && G_VALUE_TYPE (return_value))
{
@ -1682,10 +1687,10 @@ g_cclosure_marshal_generic_va (GClosure *closure,
rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
n_args = n_params + 2;
n_args = unsigned_n_params + 2;
atypes = g_alloca (sizeof (ffi_type *) * n_args);
args = g_alloca (sizeof (gpointer) * n_args);
storage = g_alloca (sizeof (va_arg_storage) * n_params);
storage = g_alloca (sizeof (va_arg_storage) * unsigned_n_params);
if (G_CCLOSURE_SWAP_DATA (closure))
{
@ -1705,7 +1710,7 @@ g_cclosure_marshal_generic_va (GClosure *closure,
va_copy (args_copy, args_list);
/* Box non-primitive arguments */
for (i = 0; i < n_params; i++)
for (i = 0; i < unsigned_n_params; i++)
{
GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
GType fundamental = G_TYPE_FUNDAMENTAL (type);
@ -1738,7 +1743,7 @@ g_cclosure_marshal_generic_va (GClosure *closure,
ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
/* Unbox non-primitive arguments */
for (i = 0; i < n_params; i++)
for (i = 0; i < unsigned_n_params; i++)
{
GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
GType fundamental = G_TYPE_FUNDAMENTAL (type);

View File

@ -948,7 +948,7 @@ g_object_base_class_init (GObjectClass *class)
GObjectClass *pclass = g_type_class_peek_parent (class);
/* Don't inherit HAS_DERIVED_CLASS flag from parent class */
class->flags &= ~CLASS_HAS_DERIVED_CLASS_FLAG;
class->flags &= (unsigned) ~CLASS_HAS_DERIVED_CLASS_FLAG;
if (pclass)
pclass->flags |= CLASS_HAS_DERIVED_CLASS_FLAG;
@ -1657,21 +1657,21 @@ g_object_interface_list_properties (gpointer g_iface,
static inline guint
object_get_optional_flags (GObject *object)
{
return g_atomic_int_get (object_get_optional_flags_p (object));
return (guint) g_atomic_int_get ((gint *) object_get_optional_flags_p (object));
}
static inline void
object_set_optional_flags (GObject *object,
guint flags)
{
g_atomic_int_or (object_get_optional_flags_p (object), flags);
g_atomic_int_or ((gint *) object_get_optional_flags_p (object), (int) flags);
}
static inline void
object_unset_optional_flags (GObject *object,
guint flags)
{
g_atomic_int_and (object_get_optional_flags_p (object), ~flags);
g_atomic_int_and ((gint *) object_get_optional_flags_p (object), (int) ~flags);
}
gboolean
@ -3891,7 +3891,7 @@ g_object_is_floating (gpointer _object)
{
GObject *object = _object;
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
return floating_flag_handler (object, 0);
return (floating_flag_handler (object, 0) != 0);
}
/**
@ -3922,7 +3922,7 @@ gpointer
g_return_val_if_fail (G_IS_OBJECT (object), object);
g_return_val_if_fail (g_atomic_int_get (&object->ref_count) >= 1, object);
g_object_ref (object);
was_floating = floating_flag_handler (object, -1);
was_floating = (floating_flag_handler (object, -1) != 0);
if (was_floating)
g_object_unref (object);
return object;

View File

@ -54,7 +54,7 @@
/* --- defines --- */
#define PARAM_FLOATING_FLAG 0x2
#define G_PARAM_USER_MASK (~0U << G_PARAM_USER_SHIFT)
#define G_PARAM_USER_MASK ((GParamFlags) (~0U << G_PARAM_USER_SHIFT))
#define PSPEC_APPLIES_TO_VALUE(pspec, value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
/* --- prototypes --- */
@ -956,7 +956,7 @@ param_spec_pool_hash (gconstpointer key_spec)
guint h = (guint) key->owner_type;
for (p = key->name; *p; p++)
h = (h << 5) - h + *p;
h = (guint) (h << 5) - h + (guint) *p;
return h;
}
@ -1182,11 +1182,11 @@ g_param_spec_pool_lookup (GParamSpecPool *pool,
/* strip type prefix */
if (delim && delim[1] == ':')
{
guint l = delim - param_name;
size_t l = (size_t) (delim - param_name);
gchar stack_buffer[32], *buffer = l < 32 ? stack_buffer : g_new (gchar, l + 1);
GType type;
strncpy (buffer, param_name, delim - param_name);
strncpy (buffer, param_name, l);
buffer[l] = 0;
type = g_type_from_name (buffer);
if (l >= 32)
@ -1311,7 +1311,7 @@ pool_depth_list (gpointer key,
GSList **slists = data[0];
GType owner_type = (GType) data[1];
GHashTable *ht = data[2];
int *count = data[3];
unsigned int *count = data[3];
if (g_type_is_a (owner_type, pspec->owner_type) &&
should_list_pspec (pspec, owner_type, ht))
@ -1350,7 +1350,7 @@ pool_depth_list_for_interface (gpointer key,
GSList **slists = data[0];
GType owner_type = (GType) data[1];
GHashTable *ht = data[2];
int *count = data[3];
unsigned int *count = data[3];
if (pspec->owner_type == owner_type &&
should_list_pspec (pspec, owner_type, ht))
@ -1382,7 +1382,7 @@ g_param_spec_pool_list (GParamSpecPool *pool,
GSList **slists, *node;
gpointer data[4];
guint d, i;
int n_pspecs = 0;
unsigned int n_pspecs = 0;
g_return_val_if_fail (pool != NULL, NULL);
g_return_val_if_fail (owner_type > 0, NULL);

View File

@ -152,8 +152,8 @@ param_int_init (GParamSpec *pspec)
{
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
ispec->minimum = 0x7fffffff;
ispec->maximum = 0x80000000;
ispec->minimum = (int) 0x7fffffff;
ispec->maximum = (int) 0x80000000;
ispec->default_value = 0;
}
@ -253,11 +253,11 @@ param_long_init (GParamSpec *pspec)
GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
#if SIZEOF_LONG == 4
lspec->minimum = 0x7fffffff;
lspec->maximum = 0x80000000;
lspec->minimum = (glong) 0x7fffffff;
lspec->maximum = (glong) 0x80000000;
#else /* SIZEOF_LONG != 4 (8) */
lspec->minimum = 0x7fffffffffffffff;
lspec->maximum = 0x8000000000000000;
lspec->minimum = (glong) 0x7fffffffffffffff;
lspec->maximum = (glong) 0x8000000000000000;
#endif
lspec->default_value = 0;
}
@ -763,7 +763,7 @@ param_string_validate (GParamSpec *pspec,
{
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
gchar *string = value->data[0].v_pointer;
guint changed = 0;
guint n_changed = 0;
if (string && string[0])
{
@ -775,10 +775,10 @@ param_string_validate (GParamSpec *pspec,
{
value->data[0].v_pointer = g_strdup (string);
string = value->data[0].v_pointer;
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[1].v_uint &= (unsigned) ~G_VALUE_NOCOPY_CONTENTS;
}
string[0] = sspec->substitutor;
changed++;
n_changed++;
}
if (sspec->cset_nth)
for (s = string + 1; *s; s++)
@ -789,10 +789,10 @@ param_string_validate (GParamSpec *pspec,
value->data[0].v_pointer = g_strdup (string);
s = (gchar*) value->data[0].v_pointer + (s - string);
string = value->data[0].v_pointer;
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[1].v_uint &= (unsigned) ~G_VALUE_NOCOPY_CONTENTS;
}
*s = sspec->substitutor;
changed++;
n_changed++;
}
}
if (sspec->null_fold_if_empty && string && string[0] == 0)
@ -800,20 +800,20 @@ param_string_validate (GParamSpec *pspec,
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
g_free (value->data[0].v_pointer);
else
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[1].v_uint &= (unsigned) ~G_VALUE_NOCOPY_CONTENTS;
value->data[0].v_pointer = NULL;
changed++;
n_changed++;
string = value->data[0].v_pointer;
}
if (sspec->ensure_non_null && !string)
{
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[1].v_uint &= (unsigned) ~G_VALUE_NOCOPY_CONTENTS;
value->data[0].v_pointer = g_strdup ("");
changed++;
n_changed++;
string = value->data[0].v_pointer;
}
return changed;
return (n_changed > 0);
}
static gboolean
@ -883,16 +883,16 @@ param_param_validate (GParamSpec *pspec,
{
/* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
GParamSpec *param = value->data[0].v_pointer;
guint changed = 0;
guint n_changed = 0;
if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
{
g_param_spec_unref (param);
value->data[0].v_pointer = NULL;
changed++;
n_changed++;
}
return changed;
return (n_changed > 0);
}
static void
@ -1015,7 +1015,7 @@ param_value_array_validate (GParamSpec *pspec,
{
GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
GValueArray *value_array = value->data[0].v_pointer;
guint changed = 0;
guint n_changed = 0;
if (!value->data[0].v_pointer && aspec->fixed_n_elements)
value_array = value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
@ -1023,7 +1023,7 @@ param_value_array_validate (GParamSpec *pspec,
if (value->data[0].v_pointer)
{
/* ensure array size validity */
changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
n_changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
/* ensure array values validity against a present element spec */
if (aspec->element_spec)
@ -1042,18 +1042,18 @@ param_value_array_validate (GParamSpec *pspec,
g_value_unset (element);
g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
g_param_value_set_default (element_spec, element);
changed++;
n_changed++;
}
else
{
/* validate array value against element_spec */
changed += g_param_value_validate (element_spec, element);
n_changed += g_param_value_validate (element_spec, element) ? 1 : 0;
}
}
}
}
return changed;
return (n_changed > 0);
}
static gint
@ -1128,16 +1128,16 @@ param_object_validate (GParamSpec *pspec,
{
GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
GObject *object = value->data[0].v_pointer;
guint changed = 0;
guint n_changed = 0;
if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
{
g_object_unref (object);
value->data[0].v_pointer = NULL;
changed++;
n_changed++;
}
return changed;
return (n_changed > 0);
}
static gint
@ -1242,15 +1242,15 @@ param_gtype_validate (GParamSpec *pspec,
{
GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
GType gtype = GPOINTER_TO_TYPE (value->data[0].v_pointer);
guint changed = 0;
guint n_changed = 0;
if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
{
value->data[0].v_pointer = GTYPE_TO_POINTER (tspec->is_a_type);
changed++;
n_changed++;
}
return changed;
return (n_changed > 0);
}
static gint

View File

@ -1056,7 +1056,7 @@ signal_parse_name (const gchar *name,
else if (colon[1] == ':')
{
gchar buffer[32];
guint l = colon - name;
size_t l = (size_t) (colon - name);
if (colon[2] == '\0')
return 0;
@ -2808,7 +2808,7 @@ g_signal_handler_find (gpointer instance,
gulong handler_seq_no = 0;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0);
g_return_val_if_fail ((mask & (unsigned) ~G_SIGNAL_MATCH_MASK) == 0, 0);
if (mask & G_SIGNAL_MATCH_MASK)
{
@ -2894,7 +2894,7 @@ g_signal_handlers_block_matched (gpointer instance,
guint n_handlers = 0;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0);
g_return_val_if_fail ((mask & (unsigned) ~G_SIGNAL_MATCH_MASK) == 0, 0);
if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA))
{
@ -2950,7 +2950,7 @@ g_signal_handlers_unblock_matched (gpointer instance,
guint n_handlers = 0;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0);
g_return_val_if_fail ((mask & (unsigned) ~G_SIGNAL_MATCH_MASK) == 0, 0);
if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA))
{
@ -3005,7 +3005,7 @@ g_signal_handlers_disconnect_matched (gpointer instance,
guint n_handlers = 0;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0);
g_return_val_if_fail ((mask & (unsigned) ~G_SIGNAL_MATCH_MASK) == 0, 0);
if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA))
{
@ -3240,7 +3240,7 @@ accumulate (GSignalInvocationHint *ihint,
continue_emission = accumulator->func (ihint, return_accu, handler_return, accumulator->data);
g_value_reset (handler_return);
ihint->run_type &= ~G_SIGNAL_ACCUMULATOR_FIRST_RUN;
ihint->run_type &= (unsigned) ~G_SIGNAL_ACCUMULATOR_FIRST_RUN;
return continue_emission;
}
@ -3853,9 +3853,9 @@ signal_emit_unlocked_R (SignalNode *node,
if (!(old_flags & G_HOOK_FLAG_IN_CALL))
{
g_atomic_int_compare_and_exchange (&hook->flags,
old_flags | G_HOOK_FLAG_IN_CALL,
old_flags);
g_atomic_int_compare_and_exchange ((gint *) &hook->flags,
(gint) old_flags | G_HOOK_FLAG_IN_CALL,
(gint) old_flags);
}
hook_returns[i] = !!need_destroy;
@ -3929,7 +3929,7 @@ signal_emit_unlocked_R (SignalNode *node,
goto EMIT_RESTART;
}
emission.ihint.run_type &= ~G_SIGNAL_RUN_FIRST;
emission.ihint.run_type &= (unsigned) ~G_SIGNAL_RUN_FIRST;
emission.ihint.run_type |= G_SIGNAL_RUN_LAST;
if ((node->flags & G_SIGNAL_RUN_LAST) && class_closure)
@ -4003,7 +4003,7 @@ signal_emit_unlocked_R (SignalNode *node,
EMIT_CLEANUP:
emission.ihint.run_type &= ~G_SIGNAL_RUN_LAST;
emission.ihint.run_type &= (unsigned) ~G_SIGNAL_RUN_LAST;
emission.ihint.run_type |= G_SIGNAL_RUN_CLEANUP;
if ((node->flags & G_SIGNAL_RUN_CLEANUP) && class_closure)

View File

@ -121,7 +121,8 @@ g_child_watch_closure_callback (GPid pid,
#ifdef G_OS_UNIX
g_value_init (&params[0], G_TYPE_ULONG);
g_value_set_ulong (&params[0], pid);
G_STATIC_ASSERT (sizeof (pid) <= sizeof (unsigned long));
g_value_set_ulong (&params[0], (gulong) pid);
#endif
#ifdef G_OS_WIN32
g_value_init (&params[0], G_TYPE_POINTER);

View File

@ -125,9 +125,9 @@
* larger alignment than this, but we don't need to
* do better than malloc.
*/
#define STRUCT_ALIGNMENT (2 * sizeof (gsize))
#define STRUCT_ALIGNMENT (2u * sizeof (gsize))
#define ALIGN_STRUCT(offset) \
((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
(((size_t) (offset) + (STRUCT_ALIGNMENT - 1u)) & -STRUCT_ALIGNMENT)
/* --- typedefs --- */
@ -442,7 +442,7 @@ type_node_any_new_W (TypeNode *pnode,
else
{
node->supers[0] = type;
memcpy (node->supers + 1, pnode->supers, sizeof (GType) * (1 + pnode->n_supers + 1));
memcpy (node->supers + 1, pnode->supers, sizeof (GType) * (1u + pnode->n_supers + 1u));
node->is_abstract = (type_flags & G_TYPE_FLAG_ABSTRACT) != 0;
node->is_classed = pnode->is_classed;
@ -1239,7 +1239,7 @@ type_data_ref_Wm (TypeNode *node)
static gboolean
iface_node_has_available_offset_L (TypeNode *iface_node,
gsize offset,
int for_index)
size_t for_index)
{
guint8 *offsets;
@ -1263,8 +1263,7 @@ find_free_iface_offset_L (IFaceEntries *entries)
IFaceEntry *entry;
TypeNode *iface_node;
gsize offset;
int i;
int n_entries;
size_t i, n_entries;
n_entries = IFACE_ENTRIES_N_ENTRIES (entries);
offset = 0;
@ -1290,7 +1289,7 @@ find_free_iface_offset_L (IFaceEntries *entries)
static void
iface_node_set_offset_L (TypeNode *iface_node,
gsize offset,
int index)
size_t index)
{
guint8 *offsets, *old_offsets;
gsize new_size, old_size;
@ -1821,8 +1820,8 @@ g_type_create_instance (GType type)
GTypeInstance *instance;
GTypeClass *class;
gchar *allocated;
gint private_size;
gint ivar_size;
size_t private_size;
size_t ivar_size;
guint i;
node = lookup_type_node_I (type);
@ -1928,8 +1927,8 @@ g_type_free_instance (GTypeInstance *instance)
TypeNode *node;
GTypeClass *class;
gchar *allocated;
gint private_size;
gint ivar_size;
size_t private_size;
size_t ivar_size;
g_return_if_fail (instance != NULL && instance->g_class != NULL);
@ -3629,7 +3628,7 @@ type_add_flags_W (TypeNode *node,
{
guint dflags;
g_return_if_fail ((flags & ~TYPE_FLAG_MASK) == 0);
g_return_if_fail ((flags & (unsigned) ~TYPE_FLAG_MASK) == 0);
g_return_if_fail (node != NULL);
if ((flags & TYPE_FLAG_MASK) && node->is_classed && node->data && node->data->class.class)
@ -3726,7 +3725,7 @@ _g_type_test_flags (GType type,
node = lookup_type_node_I (type);
if (node)
{
if ((flags & ~NODE_FLAG_MASK) == 0)
if ((flags & (unsigned) ~NODE_FLAG_MASK) == 0)
{
if ((flags & G_TYPE_FLAG_CLASSED) && !node->is_classed)
return FALSE;
@ -4601,7 +4600,7 @@ g_type_add_instance_private (GType class_gtype,
* should make the migration fully transparent even if we're effectively
* copying this macro into everybody's code.
*/
return private_size;
return (gint) private_size;
}
/* semi-private function, should only be used by G_DEFINE_TYPE_EXTENDED */
@ -4611,7 +4610,7 @@ g_type_class_adjust_private_offset (gpointer g_class,
{
GType class_gtype = ((GTypeClass *) g_class)->g_type;
TypeNode *node = lookup_type_node_I (class_gtype);
gssize private_size;
size_t private_size;
g_return_if_fail (private_size_or_offset != NULL);

View File

@ -62,7 +62,7 @@
* as described above.
*/
#define GROUP_N_VALUES (8) /* power of 2 !! */
#define GROUP_N_VALUES (8u) /* power of 2 !! */
/* --- functions --- */
@ -99,6 +99,7 @@ value_array_grow (GValueArray *value_array,
{
guint i = value_array->n_prealloced;
/* round up to the next multiple of GROUP_N_VALUES */
value_array->n_prealloced = (value_array->n_values + GROUP_N_VALUES - 1) & ~(GROUP_N_VALUES - 1);
value_array->values = g_renew (GValue, value_array->values, value_array->n_prealloced);
if (!zero_init)

View File

@ -147,7 +147,7 @@ libgobject = library('gobject-2.0',
install : true,
include_directories : [configinc],
dependencies : [libffi_dep, libglib_dep],
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'],
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION', warning_sign_conversion_args],
gnu_symbol_visibility : 'hidden',
link_args : glib_link_flags,
)

View File

@ -100,7 +100,7 @@ test_object_test_iface_init (gpointer giface,
TestIfaceClass *iface = giface;
g_assert (iface_data == GUINT_TO_POINTER (42));
g_assert_cmpint (G_TYPE_FROM_INTERFACE (iface), ==, TEST_TYPE_IFACE);
g_assert_cmpuint (G_TYPE_FROM_INTERFACE (iface), ==, TEST_TYPE_IFACE);
/* assert iface_base_init() was already called */
g_assert_cmpuint (iface_base_init_count, >, 0);

View File

@ -75,8 +75,8 @@ my_test_flags_get_type (void)
if (G_UNLIKELY(flags_type == 0))
{
static const GFlagsValue values[] = {
{ LOWEST_FLAG, "LOWEST_FLAG", "lowest" },
{ HIGHEST_FLAG, "HIGHEST_FLAG", "highest" },
{ (unsigned) LOWEST_FLAG, "LOWEST_FLAG", "lowest" },
{ (unsigned) HIGHEST_FLAG, "HIGHEST_FLAG", "highest" },
{ 0, NULL, NULL }
};
@ -146,7 +146,7 @@ my_test_set_property (GObject *object,
static void
check_flags_validation (void)
{
guint test_flags[] = {
MyFlagsEnum test_flags[] = {
NO_FLAG,
LOWEST_FLAG,
HIGHEST_FLAG,
@ -166,7 +166,7 @@ check_flags_validation (void)
/* This check will fail in case of gint -> glong conversion
* in value_flags_enum_collect_value() */
g_assert_cmpint (flag_read, ==, flag_set);
g_assert_cmpuint (flag_read, ==, flag_set);
g_object_unref (test);
}

View File

@ -396,9 +396,9 @@ static DEFINE_TYPE (DerivedObject, derived_object,
static void
assert_in_properties (GParamSpec *param_spec,
GParamSpec **properties,
gint n_properties)
size_t n_properties)
{
gint i;
size_t i;
gboolean found = FALSE;
for (i = 0; i < n_properties; i++)

View File

@ -179,7 +179,7 @@ test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_deps = [libm, thread_dep, libglib_dep, libgobject_dep]
test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"', '-UG_DISABLE_ASSERT']
test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"', '-UG_DISABLE_ASSERT', warning_sign_conversion_args]
test_cpp_args = test_cargs
foreach test_name, extra_args : gobject_tests

View File

@ -195,13 +195,13 @@ test_param_spec_ulong (void)
g_param_value_set_default (pspec, &value);
g_assert_true (G_VALUE_TYPE (&value) == G_TYPE_ULONG);
g_assert_cmpint (g_value_get_ulong (&value), ==, 30);
g_assert_cmpuint (g_value_get_ulong (&value), ==, 30);
g_assert_true (g_param_value_defaults (pspec, &value));
g_value_set_ulong (&value, 0);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_ulong (&value), ==, 20);
g_assert_cmpuint (g_value_get_ulong (&value), ==, 20);
g_param_spec_unref (pspec);
}
@ -239,13 +239,13 @@ test_param_spec_uint64 (void)
g_param_value_set_default (pspec, &value);
g_assert_true (G_VALUE_TYPE (&value) == G_TYPE_UINT64);
g_assert_cmpint (g_value_get_uint64 (&value), ==, 30);
g_assert_cmpuint (g_value_get_uint64 (&value), ==, 30);
g_assert_true (g_param_value_defaults (pspec, &value));
g_value_set_uint64 (&value, 0);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_uint64 (&value), ==, 20);
g_assert_cmpuint (g_value_get_uint64 (&value), ==, 20);
g_param_spec_unref (pspec);
}
@ -522,12 +522,12 @@ test_param_spec_gtype (void)
g_value_set_gtype (&value, G_TYPE_INT);
g_assert_false (g_param_value_is_valid (pspec, &value));
g_assert_true (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_gtype (&value), ==, G_TYPE_PARAM);
g_assert_cmpuint (g_value_get_gtype (&value), ==, G_TYPE_PARAM);
g_value_set_gtype (&value, G_TYPE_PARAM_INT);
g_assert_true (g_param_value_is_valid (pspec, &value));
g_assert_false (g_param_value_validate (pspec, &value));
g_assert_cmpint (g_value_get_gtype (&value), ==, G_TYPE_PARAM_INT);
g_assert_cmpuint (g_value_get_gtype (&value), ==, G_TYPE_PARAM_INT);
g_param_spec_unref (pspec);
}
@ -823,7 +823,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_INT, type)); \
g_value_init (&src, G_TYPE_INT); \
g_value_init (&dest, type); \
g_value_set_int (&src, value); \
g_value_set_int (&src, (int) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -834,7 +834,7 @@ test_value_transform (void)
* https://bugzilla.gnome.org/show_bug.cgi?id=659870
* for why it is broken.
*/
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpuint, char, 124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
@ -855,7 +855,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_UINT, type)); \
g_value_init (&src, G_TYPE_UINT); \
g_value_init (&dest, type); \
g_value_set_uint (&src, value); \
g_value_set_uint (&src, (unsigned int) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -880,7 +880,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_LONG, type)); \
g_value_init (&src, G_TYPE_LONG); \
g_value_init (&dest, type); \
g_value_set_long (&src, value); \
g_value_set_long (&src, (long) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -905,7 +905,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_ULONG, type)); \
g_value_init (&src, G_TYPE_ULONG); \
g_value_init (&dest, type); \
g_value_set_ulong (&src, value); \
g_value_set_ulong (&src, (gulong) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -930,7 +930,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_INT64, type)); \
g_value_init (&src, G_TYPE_INT64); \
g_value_init (&dest, type); \
g_value_set_int64 (&src, value); \
g_value_set_int64 (&src, (gint64) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -955,7 +955,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_UINT64, type)); \
g_value_init (&src, G_TYPE_UINT64); \
g_value_init (&dest, type); \
g_value_set_uint64 (&src, value); \
g_value_set_uint64 (&src, (guint64) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -980,7 +980,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_FLOAT, type)); \
g_value_init (&src, G_TYPE_FLOAT); \
g_value_init (&dest, type); \
g_value_set_float (&src, value); \
g_value_set_float (&src, (float) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -1005,7 +1005,7 @@ test_value_transform (void)
g_assert_true (g_value_type_transformable (G_TYPE_DOUBLE, type)); \
g_value_init (&src, G_TYPE_DOUBLE); \
g_value_init (&dest, type); \
g_value_set_double (&src, value); \
g_value_set_double (&src, (double) value); \
g_assert_true (g_value_transform (&src, &dest)); \
cmpfunc (g_value_get_##getter (&dest), ==, value); \
g_value_unset (&src); \
@ -1376,10 +1376,10 @@ static void test_implementation_class_init (TestImplementationClass *class)
}
typedef struct {
gint change_this_flag;
gint change_this_type;
gint use_this_flag;
gint use_this_type;
guint change_this_flag;
guint change_this_type;
guint use_this_flag;
guint use_this_type;
} TestParamImplementData;
static void
@ -1433,7 +1433,7 @@ test_param_implement (void)
continue;
}
test_path = g_strdup_printf ("/param/implement/subprocess/%d-%d-%d-%d",
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%u",
change_this_flag, change_this_type,
use_this_flag, use_this_type);
g_test_trap_subprocess (test_path, G_TIME_SPAN_SECOND,
@ -1545,8 +1545,8 @@ param_int_init (GParamSpec *pspec)
{
GParamSpecInt *ispec = (GParamSpecInt *)pspec;
ispec->minimum = 0x7fffffff;
ispec->maximum = 0x80000000;
ispec->minimum = (int) 0x7fffffff;
ispec->maximum = (int) 0x80000000;
ispec->default_value = 0;
}
@ -1686,7 +1686,7 @@ main (int argc, char *argv[])
for (data.use_this_flag = 0; data.use_this_flag < 16; data.use_this_flag++)
for (data.use_this_type = 0; data.use_this_type < 4; data.use_this_type++)
{
test_path = g_strdup_printf ("/param/implement/subprocess/%d-%d-%d-%d",
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%u",
data.change_this_flag, data.change_this_type,
data.use_this_flag, data.use_this_type);
test_data = g_memdup2 (&data, sizeof (TestParamImplementData));

View File

@ -23,7 +23,7 @@ typedef struct _GTestClass GTestClass;
struct _GTest
{
GObject object;
gint id;
unsigned int id;
gint dummy;
gint count;

View File

@ -19,7 +19,7 @@ typedef struct _GTestClass GTestClass;
struct _GTest
{
GObject object;
gint id;
unsigned int id;
gint dummy;
gint count;

View File

@ -48,10 +48,10 @@ test_type_query (void)
GTypeQuery query;
g_type_query (G_TYPE_ENUM, &query);
g_assert_cmpint (query.type, ==, G_TYPE_ENUM);
g_assert_cmpuint (query.type, ==, G_TYPE_ENUM);
g_assert_cmpstr (query.type_name, ==, "GEnum");
g_assert_cmpint (query.class_size, ==, sizeof (GEnumClass));
g_assert_cmpint (query.instance_size, ==, 0);
g_assert_cmpuint (query.class_size, ==, sizeof (GEnumClass));
g_assert_cmpuint (query.instance_size, ==, 0);
}
typedef struct _MyObject MyObject;
@ -790,7 +790,7 @@ test_weak_ref_many (void)
/* We register them in a somewhat juggled order. That's because below, we will clear them
* again, and we don't want to always clear them in the same order as they were registered.
* For that, we calculate the actual index by jumping around by adding a prime number. */
j = (g_test_rand_int () % (N + 1));
j = ((guint) g_test_rand_int () % (N + 1));
for (i = 0; i < N; i++)
{
j = (j + PRIME) % N;
@ -805,7 +805,7 @@ test_weak_ref_many (void)
g_assert_null (g_weak_ref_get (&weak_ref1));
}
n = g_test_rand_int () % (N + 1u);
n = (guint) g_test_rand_int () % (N + 1u);
for (i = 0; i < N; i++)
g_weak_ref_set (&weak_refs[i], i < n ? NULL : obj);
@ -972,9 +972,9 @@ test_weak_ref_concurrent (gconstpointer testdata)
for (i = 0; i < CONCURRENT_N_THREADS; i++)
{
const guint32 rnd_seed[] = {
g_test_rand_int (),
g_test_rand_int (),
g_test_rand_int (),
(guint32) g_test_rand_int (),
(guint32) g_test_rand_int (),
(guint32) g_test_rand_int (),
};
thread_data[i] = (ConcurrentThreadData){

View File

@ -147,7 +147,7 @@ test_disconnect_many_random (void)
for (i = 0; i < n_handlers; i++)
{
j = g_test_rand_int_range (0, n_handlers);
j = (guint) g_test_rand_int_range (0, (int) n_handlers);
id = handlers[i];
handlers[i] = handlers[j];
handlers[j] = id;
@ -189,7 +189,7 @@ test_disconnect_2_signals (void)
for (i = 0; i < n_handlers; i++)
{
j = g_test_rand_int_range (0, n_handlers);
j = (guint) g_test_rand_int_range (0, (int) n_handlers);
id = handlers[i];
handlers[i] = handlers[j];
handlers[j] = id;
@ -240,7 +240,7 @@ test_disconnect_2_objects (void)
for (i = 0; i < n_handlers; i++)
{
j = g_test_rand_int_range (0, n_handlers);
j = (guint) g_test_rand_int_range (0, (int) n_handlers);
id = handlers[i];
handlers[i] = handlers[j];
handlers[j] = id;
@ -282,7 +282,7 @@ test_block_many (void)
for (i = 0; i < n_handlers; i++)
{
j = g_test_rand_int_range (0, n_handlers);
j = (guint) g_test_rand_int_range (0, (int) n_handlers);
id = handlers[i];
handlers[i] = handlers[j];
handlers[j] = id;

View File

@ -590,7 +590,7 @@ test_signal_group_properties (void)
"target", &target,
"target-type", &gtype,
NULL);
g_assert_cmpint (gtype, ==, signal_target_get_type ());
g_assert_cmpuint (gtype, ==, signal_target_get_type ());
g_assert_null (target);
target = g_object_new (signal_target_get_type (), NULL);

View File

@ -217,7 +217,7 @@ my_test_do_signal3 (GTest * test)
static void
my_test_do_prop (GTest * test)
{
test->value = g_random_int ();
test->value = (int) g_random_int ();
g_object_notify (G_OBJECT (test), "test-prop");
}

View File

@ -118,7 +118,7 @@ static const GEnumValue my_enum_values[] =
typedef enum {
MY_FLAGS_FIRST_BIT = (1 << 0),
MY_FLAGS_THIRD_BIT = (1 << 2),
MY_FLAGS_LAST_BIT = (1 << 31)
MY_FLAGS_LAST_BIT = (1u << 31)
} MyFlags;
static const GFlagsValue my_flag_values[] =
@ -1509,7 +1509,7 @@ test_introspection (void)
g_assert_cmpstr (query.signal_name, ==, "simple");
g_assert_true (query.itype == test_get_type ());
g_assert_cmpint (query.signal_flags, ==, G_SIGNAL_RUN_LAST);
g_assert_cmpint (query.return_type, ==, G_TYPE_NONE);
g_assert_cmpuint (query.return_type, ==, G_TYPE_NONE);
g_assert_cmpuint (query.n_params, ==, 0);
g_free (ids);
@ -1705,7 +1705,7 @@ test_clear_signal_handler (void)
if (g_test_undefined ())
{
handler = g_random_int_range (0x01, 0xFF);
handler = (gulong) g_random_int_range (0x01, 0xFF);
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*instance '* has no handler with id *'");
g_clear_signal_handler (&handler, test_obj);
@ -2074,11 +2074,11 @@ test_weak_ref_disconnect (void)
&state,
(GClosureNotify) weak_ref_disconnect_notify,
0);
g_assert_cmpint (state.handler, >, 0);
g_assert_cmpuint (state.handler, >, 0);
g_object_unref (test);
g_assert_cmpint (state.handler, ==, 0);
g_assert_cmpuint (state.handler, ==, 0);
g_assert_null (g_weak_ref_get (&state.wr));
g_weak_ref_clear (&state.wr);
}

View File

@ -220,8 +220,8 @@ test_threaded_object_init (void)
}
typedef struct {
MyTester0 *strong;
guint unref_delay;
MyTester0 *strong;
gulong unref_delay;
} UnrefInThreadData;
static gpointer
@ -269,7 +269,7 @@ test_threaded_weak_ref (void)
gpointer weak;
#endif
MyTester0 *strengthened;
guint get_delay;
gulong get_delay;
GThread *thread;
GError *error = NULL;
@ -290,8 +290,8 @@ test_threaded_weak_ref (void)
* timing. Ideally, we want each side to win half the races; on
* smcv's laptop, these timings are about right.
*/
data.unref_delay = g_random_int_range (SLEEP_MIN_USEC / 2, SLEEP_MAX_USEC / 2);
get_delay = g_random_int_range (SLEEP_MIN_USEC, SLEEP_MAX_USEC);
data.unref_delay = (gulong) g_random_int_range (SLEEP_MIN_USEC / 2, SLEEP_MAX_USEC / 2);
get_delay = (gulong) g_random_int_range (SLEEP_MIN_USEC, SLEEP_MAX_USEC);
/* One half of the race is to unref the shared object */
thread = g_thread_create (unref_in_thread, &data, TRUE, &error);

View File

@ -3,7 +3,7 @@
static void
test_registration_serial (void)
{
gint serial1, serial2, serial3;
guint serial1, serial2, serial3;
serial1 = g_type_get_type_registration_serial ();
g_pointer_type_register_static ("my+pointer");
@ -118,10 +118,10 @@ test_interface_prerequisite (void)
g_free (prereqs);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (baa_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (boo_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (baa_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (boo_get_type ()), ==, G_TYPE_INVALID);
g_assert_cmpint (g_type_interface_instantiatable_prerequisite (bozo_get_type ()), ==, G_TYPE_INITIALLY_UNOWNED);
g_assert_cmpuint (g_type_interface_instantiatable_prerequisite (bozo_get_type ()), ==, G_TYPE_INITIALLY_UNOWNED);
}
typedef struct {

View File

@ -72,7 +72,7 @@ test_enum_transformation (void)
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_ULONG);
g_value_transform (&orig, &xform);
g_assert_cmpint (g_value_get_ulong (&xform), ==, 1);
g_assert_cmpuint (g_value_get_ulong (&xform), ==, 1);
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_INT64);
@ -82,7 +82,7 @@ test_enum_transformation (void)
memset (&xform, 0, sizeof (GValue));
g_value_init (&xform, G_TYPE_UINT64);
g_value_transform (&orig, &xform);
g_assert_cmpint (g_value_get_uint64 (&xform), ==, 1);
g_assert_cmpuint (g_value_get_uint64 (&xform), ==, 1);
}
@ -633,9 +633,9 @@ test_valuearray_basic (void)
a = g_value_array_new (20);
g_value_init (&v, G_TYPE_INT);
for (i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
{
g_value_set_int (&v, i);
g_value_set_int (&v, j);
g_value_array_append (a, &v);
}
@ -646,9 +646,9 @@ test_valuearray_basic (void)
for (i = 20; i < 100; i+= 5)
g_value_array_remove (a, 100 - i);
for (i = 100; i < 150; i++)
for (int j = 100; j < 150; j++)
{
g_value_set_int (&v, i);
g_value_set_int (&v, j);
g_value_array_prepend (a, &v);
}
@ -692,7 +692,7 @@ test_value_array_sort_with_data (void)
/* Add some values and try sorting them. */
g_value_init (&v, G_TYPE_INT);
for (unsigned int i = 0; i < 100; i++)
for (int i = 0; i < 100; i++)
{
g_value_set_int (&v, 100 - i);
g_value_array_append (a, &v);

View File

@ -660,6 +660,13 @@ if have_cxx
add_project_arguments(cxx.get_supported_arguments(warning_cxx_args), language: 'cpp')
endif
# FIXME: This is checked and implemented separately from warning_common_args for
# now because it causes so many warnings. Adding it as a variable in various
# directories allows us to gradually tighten up support for it. Eventually, the
# warning can be enabled unconditionally in warning_c_args, and this variable
# removed. See https://gitlab.gnome.org/GNOME/glib/-/issues/3405
warning_sign_conversion_args = cc.get_supported_arguments(['-Wsign-conversion'])
# FIXME: We cannot build some of the GResource tests with -z nodelete, which
# means we cannot use that flag in add_project_link_arguments(), and must add
# it to the relevant targets manually. We do the same with -Bsymbolic-functions