girepository: Use expected signed types for iterating

We are using various indexes types, but not always using the correct
sign or size, so let's adapt this to ensure we're consistent with the
values we're comparing with.
This commit is contained in:
Marco Trevisan (Treviño) 2024-01-16 01:57:09 +01:00
parent 91a3399027
commit 25ae968fc2
10 changed files with 35 additions and 37 deletions

View File

@ -51,14 +51,14 @@
GIFunctionInfo *
gi_base_info_find_method (GIBaseInfo *base,
uint32_t offset,
unsigned n_methods,
uint16_t n_methods,
const char *name)
{
/* FIXME hash */
GIRealInfo *rinfo = (GIRealInfo*)base;
Header *header = (Header *)rinfo->typelib->data;
for (unsigned i = 0; i < n_methods; i++)
for (uint16_t i = 0; i < n_methods; i++)
{
FunctionBlob *fblob = (FunctionBlob *)&rinfo->typelib->data[offset];
const char *fname = (const char *)&rinfo->typelib->data[fblob->name];

View File

@ -323,10 +323,10 @@ GISignalInfo *
gi_interface_info_find_signal (GIInterfaceInfo *info,
const char *name)
{
unsigned int n_signals;
uint32_t n_signals;
n_signals = gi_interface_info_get_n_signals (info);
for (unsigned int i = 0; i < n_signals; i++)
for (uint32_t i = 0; i < n_signals; i++)
{
GISignalInfo *siginfo = gi_interface_info_get_signal (info, i);

View File

@ -72,7 +72,7 @@ gi_object_info_get_field_offset (GIObjectInfo *info,
offset = rinfo->offset + header->object_blob_size
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2;
for (unsigned int i = 0; i < n; i++)
for (size_t i = 0; i < n; i++)
{
field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
offset += header->field_blob_size;

View File

@ -233,10 +233,10 @@ void gi_type_info_init (GIBaseInfo *info,
GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base,
uint32_t offset,
unsigned n_methods,
uint16_t n_methods,
const char *name);
GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo,
uint32_t offset,
unsigned n_vfuncs,
uint16_t n_vfuncs,
const char *name);

View File

@ -531,7 +531,7 @@ get_typelib_dependencies_transitive (GIRepository *repository,
immediate_dependencies = get_typelib_dependencies (typelib);
for (unsigned int i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++)
for (size_t i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++)
{
char *dependency;
const char *last_dash;
@ -1153,7 +1153,7 @@ gi_repository_get_loaded_namespaces (GIRepository *repository)
{
GList *l, *list = NULL;
char **names;
int i;
size_t i;
repository = get_repository (repository);

View File

@ -175,8 +175,7 @@ gi_callable_info_get_ffi_arg_types (GICallableInfo *callable_info,
{
ffi_type **arg_types;
gboolean is_method, throws;
size_t n_invoke_args;
unsigned int n_args, i, offset;
size_t n_args, n_invoke_args, i, offset;
g_return_val_if_fail (callable_info != NULL, NULL);

View File

@ -1047,7 +1047,7 @@ find_entry_node (GIIrTypelibBuild *build,
{
GIIrModule *module = build->module;
GList *l;
unsigned int i;
size_t i;
unsigned int n_names;
char **names;
GIIrNode *result = NULL;
@ -1220,7 +1220,7 @@ serialize_type (GIIrTypelibBuild *build,
GIIrNodeType *node,
GString *str)
{
int i;
size_t i;
if (GI_TYPE_TAG_IS_BASIC (node->tag))
{

View File

@ -383,7 +383,9 @@ find_attribute (const char *name,
const char **attribute_names,
const char **attribute_values)
{
for (int i = 0; attribute_names[i] != NULL; i++)
size_t i;
for (i = 0; attribute_names[i] != NULL; i++)
if (strcmp (attribute_names[i], name) == 0)
return attribute_values[i];
@ -484,8 +486,8 @@ static BasicTypeInfo basic_types[] = {
static const BasicTypeInfo *
parse_basic (const char *str)
{
unsigned int i;
unsigned int n_basic = G_N_ELEMENTS (basic_types);
size_t i;
size_t n_basic = G_N_ELEMENTS (basic_types);
for (i = 0; i < n_basic; i++)
{

View File

@ -198,7 +198,7 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib,
const char *name)
{
Section *dirindex;
int i, n_entries;
size_t i, n_entries;
const char *entry_name;
DirEntry *entry;
@ -247,9 +247,8 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib,
const char *gtype_name)
{
Header *header = (Header *)typelib->data;
unsigned int i;
for (i = 1; i <= header->n_local_entries; i++)
for (size_t i = 1; i <= header->n_local_entries; i++)
{
RegisteredTypeBlob *blob;
const char *type;
@ -400,11 +399,11 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib,
GQuark error_domain)
{
Header *header = (Header *)typelib->data;
unsigned int n_entries = header->n_local_entries;
size_t n_entries = header->n_local_entries;
const char *domain_string = g_quark_to_string (error_domain);
DirEntry *entry;
for (unsigned int i = 1; i <= n_entries; i++)
for (size_t i = 1; i <= n_entries; i++)
{
EnumBlob *blob;
const char *enum_domain_string;
@ -743,11 +742,11 @@ validate_param_type_blob (GITypelib *typelib,
uint32_t offset,
uint32_t signature_offset,
gboolean return_type,
int n_params,
unsigned int n_params,
GError **error)
{
ParamTypeBlob *blob;
int i;
unsigned int i;
blob = (ParamTypeBlob*)&typelib->data[offset];
@ -967,7 +966,7 @@ validate_signature_blob (GITypelib *typelib,
return FALSE;
}
for (unsigned int i = 0; i < blob->n_arguments; i++)
for (size_t i = 0; i < blob->n_arguments; i++)
{
if (!validate_arg_blob (typelib,
offset + sizeof (SignatureBlob) +
@ -1336,7 +1335,7 @@ validate_signal_blob (GITypelib *typelib,
GError **error)
{
SignalBlob *blob;
int n_signals;
size_t n_signals;
if (typelib->len < offset + sizeof (SignalBlob))
{
@ -1405,7 +1404,7 @@ validate_vfunc_blob (GITypelib *typelib,
GError **error)
{
VFuncBlob *blob;
int n_vfuncs;
size_t n_vfuncs;
if (typelib->len < offset + sizeof (VFuncBlob))
{
@ -1464,7 +1463,7 @@ validate_struct_blob (ValidateContext *ctx,
{
GITypelib *typelib = ctx->typelib;
StructBlob *blob;
int i;
size_t i;
uint32_t field_offset;
if (typelib->len < offset + sizeof (StructBlob))
@ -1561,7 +1560,6 @@ validate_enum_blob (ValidateContext *ctx,
{
GITypelib *typelib = ctx->typelib;
EnumBlob *blob;
int i;
uint32_t offset2;
if (typelib->len < offset + sizeof (EnumBlob))
@ -1622,7 +1620,7 @@ validate_enum_blob (ValidateContext *ctx,
push_context (ctx, get_string_nofail (typelib, blob->name));
for (i = 0; i < blob->n_values; i++, offset2 += sizeof (ValueBlob))
for (size_t i = 0; i < blob->n_values; i++, offset2 += sizeof (ValueBlob))
{
if (!validate_value_blob (typelib,
offset2,
@ -1650,7 +1648,7 @@ validate_enum_blob (ValidateContext *ctx,
#endif
}
for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob))
for (size_t i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob))
{
if (!validate_function_blob (ctx, offset2, BLOB_TYPE_ENUM, error))
return FALSE;
@ -1669,7 +1667,7 @@ validate_object_blob (ValidateContext *ctx,
GITypelib *typelib = ctx->typelib;
Header *header;
ObjectBlob *blob;
int i;
size_t i;
uint32_t offset2;
uint16_t n_field_callbacks;
@ -1871,7 +1869,7 @@ validate_interface_blob (ValidateContext *ctx,
GITypelib *typelib = ctx->typelib;
Header *header;
InterfaceBlob *blob;
int i;
size_t i;
uint32_t offset2;
header = (Header *)typelib->data;
@ -2071,7 +2069,7 @@ validate_directory (ValidateContext *ctx,
GITypelib *typelib = ctx->typelib;
Header *header = (Header *)typelib->data;
DirEntry *entry;
int i;
size_t i;
if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry))
{
@ -2341,7 +2339,6 @@ gi_typelib_do_dlopen (GITypelib *typelib)
if (shlib_str != NULL && shlib_str[0] != '\0')
{
char **shlibs;
int i;
/* shared-library is a comma-separated list of libraries */
shlibs = g_strsplit (shlib_str, ",", 0);
@ -2350,7 +2347,7 @@ gi_typelib_do_dlopen (GITypelib *typelib)
* again with g_module_open(), the same file handle will be returned. See bug:
* http://bugzilla.gnome.org/show_bug.cgi?id=555294
*/
for (i = 0; shlibs[i]; i++)
for (size_t i = 0; shlibs[i]; i++)
{
GModule *module;

View File

@ -48,13 +48,13 @@
GIVFuncInfo *
gi_base_info_find_vfunc (GIRealInfo *rinfo,
uint32_t offset,
unsigned n_vfuncs,
uint16_t n_vfuncs,
const char *name)
{
/* FIXME hash */
Header *header = (Header *)rinfo->typelib->data;
for (unsigned i = 0; i < n_vfuncs; i++)
for (uint16_t i = 0; i < n_vfuncs; i++)
{
VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset];
const char *fname = (const char *)&rinfo->typelib->data[fblob->name];