Merge branch 'wsign-conversion3' into 'main'

Enable -Wsign-conversion for girepository, gthread, gmodule

See merge request GNOME/glib!4594
This commit is contained in:
Philip Withnall
2025-04-22 21:47:03 +00:00
24 changed files with 242 additions and 86 deletions

View File

@@ -3,6 +3,7 @@
custom_c_args = [
'-DG_LOG_DOMAIN="GLib-GirCompiler"',
warning_sign_conversion_args,
]
if cc.get_id() != 'msvc'

View File

@@ -3,6 +3,7 @@
custom_c_args = [
'-DG_LOG_DOMAIN="GLib-GirDecompiler"',
warning_sign_conversion_args,
]
if cc.get_id() != 'msvc'

View File

@@ -286,7 +286,7 @@ gi_arg_info_get_closure_index (GIArgInfo *info,
has_closure_index = (blob->closure >= 0);
if (out_closure_index != NULL)
*out_closure_index = has_closure_index ? blob->closure : 0;
*out_closure_index = has_closure_index ? (unsigned int) blob->closure : 0;
return has_closure_index;
}
@@ -317,7 +317,7 @@ gi_arg_info_get_destroy_index (GIArgInfo *info,
has_destroy_index = (blob->destroy >= 0);
if (out_destroy_index != NULL)
*out_destroy_index = has_destroy_index ? blob->destroy : 0;
*out_destroy_index = has_destroy_index ? (unsigned int) blob->destroy : 0;
return has_destroy_index;
}

View File

@@ -80,7 +80,7 @@ signature_offset (GICallableInfo *info)
g_assert_not_reached ();
}
if (sigoff >= 0)
return *(uint32_t *)&rinfo->typelib->data[rinfo->offset + sigoff];
return *(uint32_t *)&rinfo->typelib->data[rinfo->offset + (unsigned) sigoff];
return 0;
}
@@ -354,8 +354,8 @@ gi_callable_info_get_n_args (GICallableInfo *info)
uint32_t offset;
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, 0);
g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), 0);
offset = signature_offset (info);
blob = (SignatureBlob *)&rinfo->typelib->data[offset];
@@ -710,7 +710,7 @@ gi_callable_info_invoke (GICallableInfo *info,
}
for (i = 0; i < n_args; i++)
{
int offset = (is_method ? 1 : 0);
size_t offset = (is_method ? 1 : 0);
ainfo = gi_callable_info_get_arg ((GICallableInfo *)info, i);
switch (gi_arg_info_get_direction (ainfo))
{

View File

@@ -149,7 +149,7 @@ gi_interface_info_get_property (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ n * header->property_blob_size;
return (GIPropertyInfo *) gi_base_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
@@ -207,7 +207,7 @@ gi_interface_info_get_method (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ blob->n_properties * header->property_blob_size
+ n * header->function_blob_size;
@@ -239,7 +239,7 @@ gi_interface_info_find_method (GIInterfaceInfo *info,
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ blob->n_properties * header->property_blob_size;
return gi_base_info_find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
@@ -296,7 +296,7 @@ gi_interface_info_get_signal (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ n * header->signal_blob_size;
@@ -392,7 +392,7 @@ gi_interface_info_get_vfunc (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size
@@ -433,7 +433,7 @@ gi_interface_info_find_vfunc (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + blob->n_prerequisites % 2) * 2
+ (blob->n_prerequisites + blob->n_prerequisites % 2u) * 2u
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size;
@@ -492,7 +492,7 @@ gi_interface_info_get_constant (GIInterfaceInfo *info,
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->interface_blob_size
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
+ (blob->n_prerequisites + (blob->n_prerequisites % 2u)) * 2u
+ blob->n_properties * header->property_blob_size
+ blob->n_methods * header->function_blob_size
+ blob->n_signals * header->signal_blob_size

View File

@@ -70,7 +70,7 @@ gi_object_info_get_field_offset (GIObjectInfo *info,
FieldBlob *field_blob;
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2;
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u;
for (size_t i = 0; i < n; i++)
{
@@ -383,7 +383,7 @@ gi_object_info_get_property (GIObjectInfo *info,
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ n * header->property_blob_size;
@@ -444,7 +444,7 @@ gi_object_info_get_method (GIObjectInfo *info,
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size
@@ -484,7 +484,7 @@ gi_object_info_find_method (GIObjectInfo *info,
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size +
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size;
@@ -528,8 +528,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
if (result == NULL)
{
int n_interfaces;
int i;
unsigned int n_interfaces, i;
n_interfaces = gi_object_info_get_n_interfaces (info);
for (i = 0; i < n_interfaces; ++i)
@@ -588,7 +587,7 @@ object_get_signal_offset (GIObjectInfo *info, unsigned int n)
ObjectBlob *blob = (ObjectBlob *) &rinfo->typelib->data[rinfo->offset];
return rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size
@@ -723,7 +722,7 @@ gi_object_info_get_vfunc (GIObjectInfo *info,
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size
@@ -771,7 +770,7 @@ gi_object_info_find_vfunc (GIObjectInfo *info,
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size
@@ -822,8 +821,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
if (result == NULL)
{
int n_interfaces;
int i;
unsigned int n_interfaces, i;
n_interfaces = gi_object_info_get_n_interfaces (info);
for (i = 0; i < n_interfaces; ++i)
@@ -902,7 +900,7 @@ gi_object_info_get_constant (GIObjectInfo *info,
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
+ (blob->n_interfaces + blob->n_interfaces % 2u) * 2u
+ blob->n_fields * header->field_blob_size
+ blob->n_field_callbacks * header->callback_blob_size
+ blob->n_properties * header->property_blob_size

View File

@@ -604,7 +604,8 @@ load_dependencies_recurse (GIRepository *repository,
const char *dependency_version;
last_dash = strrchr (dependency, '-');
dependency_namespace = g_strndup (dependency, last_dash - dependency);
g_assert (last_dash != NULL); /* get_typelib_dependencies() guarantees this */
dependency_namespace = g_strndup (dependency, (size_t) (last_dash - dependency));
dependency_version = last_dash+1;
if (!gi_repository_require (repository, dependency_namespace, dependency_version,
@@ -782,7 +783,8 @@ get_typelib_dependencies_transitive (GIRepository *repository,
/* Recurse for this namespace. */
last_dash = strrchr (dependency, '-');
dependency_namespace = g_strndup (dependency, last_dash - dependency);
g_assert (last_dash != NULL); /* get_typelib_dependencies() guarantees this */
dependency_namespace = g_strndup (dependency, (size_t) (last_dash - dependency));
typelib = get_registered (repository, dependency_namespace, NULL);
g_return_if_fail (typelib != NULL);
@@ -973,12 +975,12 @@ gi_repository_get_n_infos (GIRepository *repository,
GITypelib *typelib;
unsigned int n_interfaces = 0;
g_return_val_if_fail (GI_IS_REPOSITORY (repository), -1);
g_return_val_if_fail (namespace != NULL, -1);
g_return_val_if_fail (GI_IS_REPOSITORY (repository), 0);
g_return_val_if_fail (namespace != NULL, 0);
typelib = get_registered (repository, namespace, NULL);
g_return_val_if_fail (typelib != NULL, -1);
g_return_val_if_fail (typelib != NULL, 0);
n_interfaces = ((Header *)typelib->data)->n_local_entries;
@@ -1739,7 +1741,12 @@ enumerate_namespace_versions (const char *namespace,
name_end = strrchr (entry, '.');
last_dash = strrchr (entry, '-');
version = g_strndup (last_dash+1, name_end-(last_dash+1));
/* These are guaranteed by the suffix and prefix checks above: */
g_assert (name_end != NULL);
g_assert (last_dash != NULL);
version = g_strndup (last_dash + 1, (size_t) (name_end - (last_dash + 1u)));
if (!parse_version (version, &major, &minor))
{
g_free (version);

View File

@@ -250,7 +250,7 @@ node_cmp_offset_func (const void *a,
{
const GIIrNode *na = a;
const GIIrNode *nb = b;
return na->offset - nb->offset;
return (int) na->offset - (int) nb->offset;
}
static void

View File

@@ -1523,8 +1523,6 @@ gi_ir_node_build_typelib (GIIrNode *node,
array->dimensions.length = type->length;
else if (array->has_size)
array->dimensions.size = type->size;
else
array->dimensions.length = -1;
pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type);
*offset2 += sizeof (ArrayTypeBlob);
@@ -2197,7 +2195,8 @@ gi_ir_node_build_typelib (GIIrNode *node,
blob->n_fields = 0;
blob->n_functions = 0;
blob->discriminator_offset = union_->discriminator_offset;
g_assert (union_->discriminator_offset <= G_MAXINT32);
blob->discriminator_offset = (int32_t) union_->discriminator_offset;
if (union_->copy_func)
blob->copy_func = gi_ir_write_string (union_->copy_func, strings, data, offset2);

View File

@@ -356,7 +356,7 @@ get_field_size_alignment (GIIrTypelibBuild *build,
return success;
}
#define GI_ALIGN(n, align) (((n) + (align) - 1) & ~((align) - 1))
#define GI_ALIGN(n, align) (((n) + (align) - 1u) & ~((align) - 1u))
static gboolean
compute_struct_field_offsets (GIIrTypelibBuild *build,

View File

@@ -454,11 +454,12 @@ push_node (ParseContext *ctx, GIIrNode *node)
ctx->node_stack = g_slist_prepend (ctx->node_stack, node);
}
static GIIrNodeType * parse_type_internal (GIIrModule *module,
const char *str,
char **next,
gboolean in_glib,
gboolean in_gobject);
static GIIrNodeType * parse_type_internal (GIIrModule *module,
const char *str,
char **next,
gboolean in_glib,
gboolean in_gobject,
GError **error);
typedef struct {
const char *str;
@@ -575,11 +576,12 @@ parse_basic (const char *str)
}
static GIIrNodeType *
parse_type_internal (GIIrModule *module,
const char *str,
char **next,
gboolean in_glib,
gboolean in_gobject)
parse_type_internal (GIIrModule *module,
const char *str,
char **next,
gboolean in_glib,
gboolean in_gobject,
GError **error)
{
const BasicTypeInfo *basic;
GIIrNodeType *type;
@@ -685,7 +687,14 @@ parse_type_internal (GIIrModule *module,
(str)++;
end = strchr (str, '>');
tmp = g_strndup (str, end - str);
if (end == NULL)
{
g_set_error (error, G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
"Failed to parse type %s", type->unparsed);
goto error;
}
tmp = g_strndup (str, (size_t) (end - str));
type->errors = g_strsplit (tmp, ",", 0);
g_free (tmp);
@@ -707,7 +716,7 @@ parse_type_internal (GIIrModule *module,
*str == ':')
(str)++;
type->giinterface = g_strndup (start, str - start);
type->giinterface = g_strndup (start, (size_t) (str - start));
}
if (next)
@@ -716,7 +725,8 @@ parse_type_internal (GIIrModule *module,
g_free (temporary_type);
return type;
/* error: */
error:
g_assert (error == NULL || *error != NULL);
gi_ir_node_free ((GIIrNode *)type);
g_free (temporary_type);
return NULL;
@@ -791,7 +801,9 @@ is_pointer_or_disguised_structure (ParseContext *ctx,
}
static GIIrNodeType *
parse_type (ParseContext *ctx, const char *type)
parse_type (ParseContext *ctx,
const char *type,
GError **error)
{
GIIrNodeType *node;
const BasicTypeInfo *basic;
@@ -805,11 +817,11 @@ parse_type (ParseContext *ctx, const char *type)
if (basic == NULL)
type = resolve_aliases (ctx, type);
node = parse_type_internal (ctx->current_module, type, NULL, in_glib, in_gobject);
node = parse_type_internal (ctx->current_module, type, NULL, in_glib, in_gobject, error);
if (node)
g_debug ("Parsed type: %s => %d", type, node->tag);
else
g_critical ("Failed to parse type: '%s'", type);
g_debug ("Failed to parse type: '%s'", type);
return node;
}
@@ -1517,7 +1529,8 @@ start_field (GMarkupParseContext *context,
}
else
{
field->type = parse_type (ctx, "gpointer");
field->type = parse_type (ctx, "gpointer", NULL);
g_assert (field->type != NULL); /* parsing `gpointer` should never fail */
}
((GIIrNode *)field)->name = g_strdup (name);
@@ -2211,22 +2224,20 @@ start_type (GMarkupParseContext *context,
size = find_attribute ("fixed-size", attribute_names, attribute_values);
typenode->has_length = len != NULL;
if (!typenode->has_length)
typenode->length = -1;
else if (g_ascii_string_to_unsigned (len, 10, 0, G_MAXUINT, &parsed_uint, error))
if (typenode->has_length &&
g_ascii_string_to_unsigned (len, 10, 0, G_MAXUINT, &parsed_uint, error))
typenode->length = parsed_uint;
else
else if (typenode->has_length)
{
gi_ir_node_free ((GIIrNode *) typenode);
return FALSE;
}
typenode->has_size = size != NULL;
if (!typenode->has_size)
typenode->size = -1;
else if (g_ascii_string_to_unsigned (size, 10, 0, G_MAXSIZE, &parsed_uint, error))
if (typenode->has_size &&
g_ascii_string_to_unsigned (size, 10, 0, G_MAXSIZE, &parsed_uint, error))
typenode->size = parsed_uint;
else
else if (typenode->has_size)
{
gi_ir_node_free ((GIIrNode *) typenode);
return FALSE;
@@ -2243,9 +2254,7 @@ start_type (GMarkupParseContext *context,
} else {
typenode->zero_terminated = FALSE;
typenode->has_length = FALSE;
typenode->length = -1;
typenode->has_size = FALSE;
typenode->size = -1;
}
}
else
@@ -2276,7 +2285,9 @@ start_type (GMarkupParseContext *context,
pointer_depth > 0)
pointer_depth--;
typenode = parse_type (ctx, name);
typenode = parse_type (ctx, name, error);
if (typenode == NULL)
return FALSE;
/* A "pointer" structure is one where the c:type is a typedef that
* to a pointer to a structure; we used to call them "disguised"
@@ -2320,14 +2331,17 @@ end_type_top (ParseContext *ctx)
typenode->tag == GI_TYPE_TAG_GSLIST)
{
if (typenode->parameter_type1 == NULL)
typenode->parameter_type1 = parse_type (ctx, "gpointer");
typenode->parameter_type1 = parse_type (ctx, "gpointer", NULL);
g_assert (typenode->parameter_type1 != NULL); /* parsing `gpointer` should never fail */
}
else if (typenode->tag == GI_TYPE_TAG_GHASH)
{
if (typenode->parameter_type1 == NULL)
{
typenode->parameter_type1 = parse_type (ctx, "gpointer");
typenode->parameter_type2 = parse_type (ctx, "gpointer");
typenode->parameter_type1 = parse_type (ctx, "gpointer", NULL);
g_assert (typenode->parameter_type1 != NULL); /* parsing `gpointer` should never fail */
typenode->parameter_type2 = parse_type (ctx, "gpointer", NULL);
g_assert (typenode->parameter_type2 != NULL); /* same */
}
}
@@ -2977,6 +2991,7 @@ start_discriminator (GMarkupParseContext *context,
const char *type;
const char *offset;
guint64 parsed_offset;
GIIrNodeType *discriminator_type = NULL;
if (!(strcmp (element_name, "discriminator") == 0 &&
ctx->state == STATE_UNION))
@@ -2995,8 +3010,11 @@ start_discriminator (GMarkupParseContext *context,
return FALSE;
}
((GIIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type
= parse_type (ctx, type);
discriminator_type = parse_type (ctx, type, error);
if (discriminator_type == NULL)
return FALSE;
((GIIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type = g_steal_pointer (&discriminator_type);
if (g_ascii_string_to_unsigned (offset, 10, 0, G_MAXSIZE, &parsed_offset, error))
((GIIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset = parsed_offset;
@@ -3062,7 +3080,14 @@ parse_include (GMarkupParseContext *context,
return FALSE;
}
module = gi_ir_parser_parse_string (ctx->parser, name, girpath, buffer, length, &error);
if (length > G_MAXSSIZE)
{
g_printerr ("Input file %s too big\n", girpath);
g_free (girpath);
return FALSE;
}
module = gi_ir_parser_parse_string (ctx->parser, name, girpath, buffer, (gssize) length, &error);
g_free (buffer);
if (error != NULL)
{
@@ -3904,7 +3929,7 @@ cleanup (GMarkupParseContext *context,
* @namespace: the namespace of the string
* @filename: (nullable) (type filename): Path to parsed file, or `NULL`
* @buffer: (array length=length): the data containing the XML
* @length: length of the data, in bytes
* @length: length of the data, in bytes, or `-1` if nul terminated
* @error: return location for a [type@GLib.Error], or `NULL`
*
* Parse a string that holds a complete GIR XML file, and return a list of a
@@ -4043,7 +4068,19 @@ gi_ir_parser_parse_file (GIIrParser *parser,
return NULL;
}
module = gi_ir_parser_parse_string (parser, namespace, filename, buffer, length, error);
if (length > G_MAXSSIZE)
{
g_free (namespace);
g_free (buffer);
g_set_error (error,
G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
"Input file too big");
return NULL;
}
module = gi_ir_parser_parse_string (parser, namespace, filename, buffer, (gssize) length, error);
g_free (namespace);

View File

@@ -87,7 +87,7 @@ get_dir_entry_checked (GITypelib *typelib,
return FALSE;
}
offset = header->directory + (index - 1) * header->entry_blob_size;
offset = header->directory + (index - 1u) * header->entry_blob_size;
if (typelib->len < offset + sizeof (DirEntry))
{
@@ -161,7 +161,8 @@ gi_typelib_get_dir_entry (GITypelib *typelib,
{
Header *header = (Header *)typelib->data;
return (DirEntry *)&typelib->data[header->directory + (index - 1) * header->entry_blob_size];
/* this deliberately doesnt check for underflow of @index; see get_dir_entry_checked() for that */
return (DirEntry *)&typelib->data[header->directory + (index - 1u) * header->entry_blob_size];
}
static Section *
@@ -303,7 +304,7 @@ strsplit_iter_next (StrSplitIter *iter,
if (next)
{
iter->s = next + iter->sep_len;
len = next - s;
len = (size_t) (next - s);
}
else
{
@@ -1718,7 +1719,7 @@ validate_object_blob (ValidateContext *ctx,
}
if (typelib->len < offset + sizeof (ObjectBlob) +
(blob->n_interfaces + blob->n_interfaces % 2) * 2 +
(blob->n_interfaces + blob->n_interfaces % 2u) * 2u +
blob->n_fields * sizeof (FieldBlob) +
blob->n_properties * sizeof (PropertyBlob) +
blob->n_methods * sizeof (FunctionBlob) +
@@ -1875,7 +1876,7 @@ validate_interface_blob (ValidateContext *ctx,
return FALSE;
if (typelib->len < offset + sizeof (InterfaceBlob) +
(blob->n_prerequisites + blob->n_prerequisites % 2) * 2 +
(blob->n_prerequisites + blob->n_prerequisites % 2u) * 2u +
blob->n_properties * sizeof (PropertyBlob) +
blob->n_methods * sizeof (FunctionBlob) +
blob->n_signals * sizeof (SignalBlob) +

View File

@@ -169,7 +169,7 @@ gi_union_info_get_discriminator_offset (GIUnionInfo *info,
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
size_t discriminator_offset;
discriminator_offset = (blob->discriminated) ? blob->discriminator_offset : 0;
discriminator_offset = (blob->discriminated) ? (size_t) blob->discriminator_offset : 0;
if (out_offset != NULL)
*out_offset = discriminator_offset;

View File

@@ -224,7 +224,8 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
GIObjectInfo *object_info;
GIStructInfo *struct_info;
GIFieldInfo *field_info = NULL;
int length, i, offset;
size_t offset;
unsigned int length, i;
void *implementor_class, *implementor_vtable;
void *func = NULL;

View File

@@ -3,6 +3,7 @@
custom_c_args = [
'-DG_LOG_DOMAIN="GLib-GirInspector"',
warning_sign_conversion_args,
]
if cc.get_id() != 'msvc'

View File

@@ -89,6 +89,7 @@ gir_c_args = [
'-DGOBJECT_INTROSPECTION_LIBDIR="@0@"'.format(glib_libdir),
'-DGOBJECT_INTROSPECTION_DATADIR="@0@"'.format(glib_datadir),
'-DGOBJECT_INTROSPECTION_RELATIVE_LIBDIR="@0@"'.format(get_option('libdir')),
warning_sign_conversion_args,
]
custom_c_args = []

View File

@@ -0,0 +1,106 @@
/*
* Copyright 2025 GNOME Foundation, Inc.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* - Philip Withnall <pwithnall@gnome.org>
*/
#include "config.h"
#include "girepository.h"
#include "girparser-private.h"
static void
test_type_parsing (void)
{
const char *buffer_template = "<?xml version='1.0'?>"
"<repository version='1.2'"
" xmlns='http://www.gtk.org/introspection/core/1.0'"
" xmlns:c='http://www.gtk.org/introspection/c/1.0'>"
"<package name='TestNamespace-1.0'/>"
"<namespace name='TestNamespace' version='1.0'"
" c:identifier-prefixes='test'"
" c:symbol-prefixes='test'>"
"<function name='dummy' c:identifier='dummy'>"
"<return-value transfer-ownership='none'>"
"<type name='%s'/>"
"</return-value>"
"<parameters>"
"</parameters>"
"</function>"
"</namespace>"
"</repository>";
const struct
{
const char *type;
gboolean expected_success;
}
vectors[] =
{
{ "GLib.Error", TRUE },
{ "GLib.Error<IOError,FileError>", TRUE },
{ "GLib.Error<IOError", FALSE },
};
g_test_summary ("Test parsing different valid and invalid types");
for (size_t i = 0; i < G_N_ELEMENTS (vectors); i++)
{
GIIrParser *parser = NULL;
GIIrModule *module;
GError *local_error = NULL;
char *buffer = NULL;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
buffer = g_strdup_printf (buffer_template, vectors[i].type);
#pragma GCC diagnostic pop
parser = gi_ir_parser_new ();
module = gi_ir_parser_parse_string (parser, "TestNamespace",
"TestNamespace-1.0.gir",
buffer, -1,
&local_error);
if (vectors[i].expected_success)
{
g_assert_no_error (local_error);
g_assert_nonnull (module);
}
else
{
g_assert_error (local_error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT);
g_assert_null (module);
}
g_clear_error (&local_error);
g_clear_pointer (&parser, gi_ir_parser_free);
g_free (buffer);
}
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/ir-parser/type-parsing", test_type_parsing);
return g_test_run ();
}

View File

@@ -50,6 +50,9 @@ if enable_gir
'dependencies': [libffi_dep],
'depends': glib_gir_testing_dep,
},
'ir-parser' : {
'dependencies': [libgirepository_internals_dep],
},
'object-info' : {
'depends': gio_gir_testing_dep,
},
@@ -91,7 +94,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, libgirepository_dep]
test_cargs = ['-DG_LOG_DOMAIN="GIRepository"', '-UG_DISABLE_ASSERT']
test_cargs = ['-DG_LOG_DOMAIN="GIRepository"', '-UG_DISABLE_ASSERT', warning_sign_conversion_args]
test_cpp_args = test_cargs
foreach test_name, extra_args : girepository_tests

View File

@@ -52,7 +52,7 @@ set_error (GError **error,
gchar *message;
va_list args;
win32_error = g_win32_error_message (GetLastError ());
win32_error = g_win32_error_message ((gint) GetLastError ());
va_start (args, format);
detail = g_strdup_vprintf (format, args);

View File

@@ -481,7 +481,7 @@ g_module_open_full (const gchar *file_name,
_g_module_debug_init ();
if (module_debug_flags & G_MODULE_DEBUG_BIND_NOW_MODULES)
flags &= ~G_MODULE_BIND_LAZY;
flags &= (unsigned) ~G_MODULE_BIND_LAZY;
if (!file_name)
{

View File

@@ -96,7 +96,7 @@ libgmodule = library('gmodule-2.0',
install : true,
include_directories : [configinc, gmoduleinc],
dependencies : [libdl_dep, libglib_dep],
c_args : ['-DG_LOG_DOMAIN="GModule"', '-DGMODULE_COMPILATION'],
c_args : ['-DG_LOG_DOMAIN="GModule"', '-DGMODULE_COMPILATION', warning_sign_conversion_args],
gnu_symbol_visibility : 'hidden',
link_args : [glib_link_flags],
)

View File

@@ -75,7 +75,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, libgmodule_dep]
test_cargs = ['-DG_LOG_DOMAIN="GModule"', '-UG_DISABLE_ASSERT']
test_cargs = ['-DG_LOG_DOMAIN="GModule"', '-UG_DISABLE_ASSERT', warning_sign_conversion_args]
test_cpp_args = test_cargs
foreach test_name, extra_args : gmodule_tests

View File

@@ -19,7 +19,7 @@ libgthread = library('gthread-2.0',
darwin_versions : darwin_versions,
install : true,
dependencies : [libglib_dep],
c_args : ['-DG_LOG_DOMAIN="GThread"', glib_c_args_internal],
c_args : ['-DG_LOG_DOMAIN="GThread"', glib_c_args_internal, warning_sign_conversion_args],
gnu_symbol_visibility : 'hidden',
link_args : glib_link_flags,
)

View File

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