girepository: Fix straightforward -Wsign-conversion warnings

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall
2025-04-11 22:04:09 +01:00
parent 4b7f0a8f50
commit f44511bc54
10 changed files with 37 additions and 37 deletions

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

@@ -976,12 +976,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;

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

@@ -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

@@ -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;