Merge branch 'wip/pwithnall/wsign-conversion2a' into 'main'

gobject, girepository: Fix several -Wsign-conversion warnings on macOS

See merge request GNOME/glib!4606
This commit is contained in:
Michael Catanzaro
2025-05-05 18:36:32 +00:00
17 changed files with 57 additions and 51 deletions

View File

@@ -641,7 +641,7 @@ gi_repository_dump (const char *input_filename,
if (input == NULL)
{
int saved_errno = errno;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (saved_errno),
g_set_error (error, G_FILE_ERROR, (int) g_file_error_from_errno (saved_errno),
"Failed to open %s: %s", input_filename, g_strerror (saved_errno));
g_module_close (self);
@@ -653,7 +653,7 @@ gi_repository_dump (const char *input_filename,
if (output == NULL)
{
int saved_errno = errno;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (saved_errno),
g_set_error (error, G_FILE_ERROR, (int) g_file_error_from_errno (saved_errno),
"Failed to open %s: %s", output_filename, g_strerror (saved_errno));
fclose (input);
@@ -735,7 +735,7 @@ gi_repository_dump (const char *input_filename,
{
int saved_errno = errno;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (saved_errno),
g_set_error (error, G_FILE_ERROR, (int) g_file_error_from_errno (saved_errno),
"Error closing input file %s: %s", input_filename,
g_strerror (saved_errno));
caught_error = TRUE;
@@ -745,7 +745,7 @@ gi_repository_dump (const char *input_filename,
{
int saved_errno = errno;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (saved_errno),
g_set_error (error, G_FILE_ERROR, (int) g_file_error_from_errno (saved_errno),
"Error closing output file %s: %s", output_filename,
g_strerror (saved_errno));
caught_error = TRUE;

View File

@@ -60,8 +60,8 @@ gi_arg_info_get_direction (GIArgInfo *info)
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_ARG_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_DIRECTION_OUT);
g_return_val_if_fail (GI_IS_ARG_INFO (info), GI_DIRECTION_OUT);
blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
@@ -218,8 +218,8 @@ gi_arg_info_get_ownership_transfer (GIArgInfo *info)
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_ARG_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_TRANSFER_NOTHING);
g_return_val_if_fail (GI_IS_ARG_INFO (info), GI_TRANSFER_NOTHING);
blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
@@ -251,8 +251,8 @@ gi_arg_info_get_scope (GIArgInfo *info)
GIRealInfo *rinfo = (GIRealInfo *)info;
ArgBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_ARG_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_SCOPE_TYPE_INVALID);
g_return_val_if_fail (GI_IS_ARG_INFO (info), GI_SCOPE_TYPE_INVALID);
blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];

View File

@@ -297,8 +297,8 @@ gi_callable_info_get_caller_owns (GICallableInfo *info)
GIRealInfo *rinfo = (GIRealInfo*) info;
SignatureBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_TRANSFER_NOTHING);
g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), GI_TRANSFER_NOTHING);
blob = (SignatureBlob *)&rinfo->typelib->data[signature_offset (info)];
@@ -327,8 +327,8 @@ gi_callable_info_get_instance_ownership_transfer (GICallableInfo *info)
GIRealInfo *rinfo = (GIRealInfo*) info;
SignatureBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_TRANSFER_NOTHING);
g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), GI_TRANSFER_NOTHING);
blob = (SignatureBlob *)&rinfo->typelib->data[signature_offset (info)];

View File

@@ -116,8 +116,8 @@ gi_function_info_get_flags (GIFunctionInfo *info)
GIRealInfo *rinfo;
FunctionBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_FUNCTION_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_FUNCTION_INFO_FLAGS_NONE);
g_return_val_if_fail (GI_IS_FUNCTION_INFO (info), GI_FUNCTION_INFO_FLAGS_NONE);
rinfo = (GIRealInfo *)info;
blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset];

View File

@@ -124,8 +124,8 @@ gi_property_info_get_ownership_transfer (GIPropertyInfo *info)
GIRealInfo *rinfo = (GIRealInfo *)info;
PropertyBlob *blob;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_PROPERTY_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_TRANSFER_NOTHING);
g_return_val_if_fail (GI_IS_PROPERTY_INFO (info), GI_TRANSFER_NOTHING);
blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset];

View File

@@ -198,13 +198,13 @@ gi_repository_get_library_path_macos (void)
if (cmd->cmd == LC_SEGMENT)
{
struct segment_command *seg = (struct segment_command *) cmd;
if (((intptr_t) ptr >= (seg->vmaddr + offset)) && ((intptr_t) ptr < (seg->vmaddr + offset + seg->vmsize)))
if (((intptr_t) ptr >= ((intptr_t) seg->vmaddr + offset)) && ((intptr_t) ptr < ((intptr_t) seg->vmaddr + offset + (intptr_t) seg->vmsize)))
return _dyld_get_image_name (i);
}
if (cmd->cmd == LC_SEGMENT_64)
{
struct segment_command_64 *seg = (struct segment_command_64 *) cmd;
if (((uintptr_t ) ptr >= (seg->vmaddr + offset)) && ((uintptr_t ) ptr < (seg->vmaddr + offset + seg->vmsize)))
if (((intptr_t) ptr >= ((intptr_t) seg->vmaddr + offset)) && ((intptr_t) ptr < ((intptr_t) seg->vmaddr + offset + (intptr_t) seg->vmsize)))
return _dyld_get_image_name (i);
}
/* Jump to the next command */

View File

@@ -147,7 +147,7 @@ struct _GIIrNodeType
uint8_t is_ghashtable : 1;
uint8_t is_interface : 1;
uint8_t is_error : 1;
int tag;
GITypeTag tag;
char *unparsed; /* (owned) */

View File

@@ -499,7 +499,7 @@ static IntegerAliasInfo integer_aliases[] = {
typedef struct {
const char *str;
int tag;
GITypeTag tag;
gboolean pointer;
} BasicTypeInfo;

View File

@@ -221,7 +221,7 @@ write_type_info (const char *ns,
GITypeInfo *info,
Xml *file)
{
int tag;
GITypeTag tag;
GITypeInfo *type;
gboolean is_pointer;

View File

@@ -373,15 +373,15 @@ gi_type_info_get_array_type (GITypeInfo *info)
GIRealInfo *rinfo = (GIRealInfo *)info;
SimpleTypeBlob *type;
g_return_val_if_fail (info != NULL, -1);
g_return_val_if_fail (GI_IS_TYPE_INFO (info), -1);
g_return_val_if_fail (info != NULL, GI_ARRAY_TYPE_C);
g_return_val_if_fail (GI_IS_TYPE_INFO (info), GI_ARRAY_TYPE_C);
type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0))
{
ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset];
g_return_val_if_fail (blob->tag == GI_TYPE_TAG_ARRAY, -1);
g_return_val_if_fail (blob->tag == GI_TYPE_TAG_ARRAY, GI_ARRAY_TYPE_C);
return blob->array_type;
}

View File

@@ -366,6 +366,7 @@ typedef enum {
/**
* GIFieldInfoFlags:
* @GI_FIELD_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_FIELD_IS_READABLE: field is readable.
* @GI_FIELD_IS_WRITABLE: field is writable.
*
@@ -376,12 +377,14 @@ typedef enum {
typedef enum
{
GI_FIELD_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_FIELD_IS_READABLE = 1 << 0,
GI_FIELD_IS_WRITABLE = 1 << 1
} GIFieldInfoFlags;
/**
* GIVFuncInfoFlags:
* @GI_VFUNC_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type
* @GI_VFUNC_MUST_OVERRIDE: overrides
* @GI_VFUNC_MUST_NOT_OVERRIDE: does not override
@@ -392,6 +395,7 @@ typedef enum
*/
typedef enum
{
GI_VFUNC_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_VFUNC_MUST_CHAIN_UP = 1 << 0,
GI_VFUNC_MUST_OVERRIDE = 1 << 1,
GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2,
@@ -399,6 +403,7 @@ typedef enum
/**
* GIFunctionInfoFlags:
* @GI_FUNCTION_INFO_FLAGS_NONE: no flags set (since: 2.86)
* @GI_FUNCTION_IS_METHOD: is a method.
* @GI_FUNCTION_IS_CONSTRUCTOR: is a constructor.
* @GI_FUNCTION_IS_GETTER: is a getter of a [class@GIRepository.PropertyInfo].
@@ -411,6 +416,7 @@ typedef enum
*/
typedef enum
{
GI_FUNCTION_INFO_FLAGS_NONE GI_AVAILABLE_ENUMERATOR_IN_2_86 = 0,
GI_FUNCTION_IS_METHOD = 1 << 0,
GI_FUNCTION_IS_CONSTRUCTOR = 1 << 1,
GI_FUNCTION_IS_GETTER = 1 << 2,

View File

@@ -920,7 +920,7 @@ g_closure_invoke (GClosure *closure,
marshal_data);
if (!in_marshal)
closure_invoke_notifiers (closure, POST_NOTIFY);
ATOMIC_SET (closure, in_marshal, in_marshal);
ATOMIC_SET (closure, in_marshal, (guint) in_marshal);
}
g_closure_unref (closure);
}
@@ -984,7 +984,7 @@ _g_closure_invoke_va (GClosure *closure,
n_params, param_types);
if (!in_marshal)
closure_invoke_notifiers (closure, POST_NOTIFY);
ATOMIC_SET (closure, in_marshal, in_marshal);
ATOMIC_SET (closure, in_marshal, (guint) in_marshal);
}
g_closure_unref (closure);
}

View File

@@ -755,7 +755,7 @@ node_update_single_va_closure (SignalNode *node)
node->single_va_closure_is_valid = TRUE;
node->single_va_closure = closure;
node->single_va_closure_is_after = is_after;
node->single_va_closure_is_after = (guint) is_after;
}
static inline void

View File

@@ -736,7 +736,7 @@ g_signal_group_connect_closure_ (GSignalGroup *self,
handler->signal_id = signal_id;
handler->signal_detail = signal_detail;
handler->closure = g_closure_ref (closure);
handler->connect_after = after;
handler->connect_after = (guint) after;
g_closure_sink (closure);

View File

@@ -1444,7 +1444,7 @@ type_add_interface_Wm (TypeNode *node,
*/
if (node->data)
{
InitState class_state = g_atomic_int_get (&node->data->class.init_state);
InitState class_state = (InitState) g_atomic_int_get (&node->data->class.init_state);
if (class_state >= BASE_IFACE_INIT)
type_iface_vtable_base_init_Wm (iface, node);

View File

@@ -116,7 +116,7 @@ my_test_get_property (GObject *object,
switch (prop_id)
{
case PROP_FLAGS:
g_value_set_flags (value, test->flags);
g_value_set_flags (value, (guint) test->flags);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -135,7 +135,7 @@ my_test_set_property (GObject *object,
switch (prop_id)
{
case PROP_FLAGS:
test->flags = g_value_get_flags (value);
test->flags = (MyFlagsEnum) g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -157,7 +157,7 @@ check_flags_validation (void)
for (i = 0; i < G_N_ELEMENTS (test_flags); i++)
{
guint flag_set = test_flags[i];
guint flag_set = (guint) test_flags[i];
GObject *test = g_object_new (G_TYPE_TEST,
"flags", flag_set,
NULL);

View File

@@ -1164,7 +1164,7 @@ test_interface_default_init (TestInterfaceInterface *iface)
continue;
/* we think that this is impossible. make sure. */
pspec = g_param_spec_object ("xyz", "xyz", "xyz", types[i], j);
pspec = g_param_spec_object ("xyz", "xyz", "xyz", types[i], (GParamFlags) j);
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*assertion*pspec->flags*failed*");
@@ -1176,7 +1176,7 @@ test_interface_default_init (TestInterfaceInterface *iface)
/* install the property */
g_snprintf (prop_name, sizeof prop_name, "%s-%s", names[i], perms[j]);
pspec = g_param_spec_object (prop_name, prop_name, prop_name, types[i], j);
pspec = g_param_spec_object (prop_name, prop_name, prop_name, types[i], (GParamFlags) j);
g_object_interface_install_property (iface, pspec);
}
}
@@ -1320,8 +1320,8 @@ static gint valid_impl_flags[16][16] = {
static guint change_this_flag;
static guint change_this_type;
static guint use_this_flag;
static guint use_this_type;
static GParamFlags use_this_flag;
static size_t use_this_type_index;
typedef GObjectClass TestImplementationClass;
typedef GObject TestImplementation;
@@ -1371,15 +1371,15 @@ static void test_implementation_class_init (TestImplementationClass *class)
g_error ("Interface property does not exist");
g_snprintf (prop_name, sizeof prop_name, "%s-%s", names[change_this_type], perms[change_this_flag]);
pspec = g_param_spec_object (prop_name, prop_name, prop_name, types[use_this_type], use_this_flag);
pspec = g_param_spec_object (prop_name, prop_name, prop_name, types[use_this_type_index], use_this_flag);
g_object_class_install_property (class, 1, pspec);
}
typedef struct {
guint change_this_flag;
guint change_this_type;
guint use_this_flag;
guint use_this_type;
GParamFlags use_this_flag;
size_t use_this_type_index;
} TestParamImplementData;
static void
@@ -1401,7 +1401,7 @@ test_param_implement_child (gconstpointer user_data)
change_this_flag = data->change_this_flag;
change_this_type = data->change_this_type;
use_this_flag = data->use_this_flag;
use_this_type = data->use_this_type;
use_this_type_index = data->use_this_type_index;
g_type_class_ref (test_implementation_get_type ());
}
@@ -1421,7 +1421,7 @@ test_param_implement (void)
for (change_this_flag = 0; change_this_flag < 16; change_this_flag++)
for (change_this_type = 0; change_this_type < 3; change_this_type++)
for (use_this_flag = 0; use_this_flag < 16; use_this_flag++)
for (use_this_type = 0; use_this_type < 4; use_this_type++)
for (use_this_type_index = 0; use_this_type_index < 4; use_this_type_index++)
{
if (!g_test_undefined ())
{
@@ -1429,13 +1429,13 @@ test_param_implement (void)
if (valid_impl_flags[change_this_flag][use_this_flag] != 'v')
continue;
if (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type] != 'v')
if (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type_index] != 'v')
continue;
}
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%u",
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%" G_GSIZE_FORMAT,
change_this_flag, change_this_type,
use_this_flag, use_this_type);
use_this_flag, use_this_type_index);
g_test_trap_subprocess (test_path, G_TIME_SPAN_SECOND,
G_TEST_SUBPROCESS_DEFAULT);
g_free (test_path);
@@ -1445,7 +1445,7 @@ test_param_implement (void)
{
case 0:
/* make sure the other table agrees */
g_assert_cmpint (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type], ==, 0);
g_assert_cmpint (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type_index], ==, 0);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*Interface property does not exist*");
continue;
@@ -1470,7 +1470,7 @@ test_param_implement (void)
}
/* Next, we check if there should have been a type error. */
switch (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type])
switch (valid_impl_types[change_this_type * 16 + change_this_flag][use_this_type_index])
{
case 0:
/* this should have been caught above */
@@ -1684,11 +1684,11 @@ main (int argc, char *argv[])
for (data.change_this_flag = 0; data.change_this_flag < 16; data.change_this_flag++)
for (data.change_this_type = 0; data.change_this_type < 3; data.change_this_type++)
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++)
for (data.use_this_type_index = 0; data.use_this_type_index < 4; data.use_this_type_index++)
{
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%u",
test_path = g_strdup_printf ("/param/implement/subprocess/%u-%u-%u-%" G_GSIZE_FORMAT,
data.change_this_flag, data.change_this_type,
data.use_this_flag, data.use_this_type);
data.use_this_flag, data.use_this_type_index);
test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
g_test_add_data_func_full (test_path, g_steal_pointer (&test_data), test_param_implement_child, g_free);
g_free (test_path);