From 030f4f003cb86a4569ac159f9d7a21ee5a83b9a9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 12 Dec 2023 18:07:25 +0000 Subject: [PATCH] giobjectinfo: Fix int signedness in APIs Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giobjectinfo.c | 38 ++++++++++++++++++------------------- girepository/giobjectinfo.h | 28 +++++++++++++-------------- girepository/girwriter.c | 15 +++++++-------- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index d44816c8f..846505b7d 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -60,19 +60,18 @@ */ static gint32 gi_object_info_get_field_offset (GIObjectInfo *info, - gint n) + guint n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; guint32 offset; - gint i; FieldBlob *field_blob; offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2; - for (i = 0; i < n; i++) + for (guint i = 0; i < n; i++) { field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; offset += header->field_blob_size; @@ -234,7 +233,7 @@ gi_object_info_get_type_init_function_name (GIObjectInfo *info) * * Returns: number of interfaces */ -gint +guint gi_object_info_get_n_interfaces (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -260,7 +259,7 @@ gi_object_info_get_n_interfaces (GIObjectInfo *info) */ GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, - gint n) + guint n) { GIRealInfo *rinfo = (GIRealInfo *)info; ObjectBlob *blob; @@ -282,7 +281,7 @@ gi_object_info_get_interface (GIObjectInfo *info, * * Returns: number of fields */ -gint +guint gi_object_info_get_n_fields (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -308,7 +307,7 @@ gi_object_info_get_n_fields (GIObjectInfo *info) */ GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -329,7 +328,7 @@ gi_object_info_get_field (GIObjectInfo *info, * * Returns: number of properties */ -gint +guint gi_object_info_get_n_properties (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -354,7 +353,7 @@ gi_object_info_get_n_properties (GIObjectInfo *info) */ GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -385,7 +384,7 @@ gi_object_info_get_property (GIObjectInfo *info, * * Returns: number of methods */ -gint +guint gi_object_info_get_n_methods (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -411,7 +410,7 @@ gi_object_info_get_n_methods (GIObjectInfo *info) */ GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -536,7 +535,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info, * * Returns: number of signals */ -gint +guint gi_object_info_get_n_signals (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -562,7 +561,7 @@ gi_object_info_get_n_signals (GIObjectInfo *info) */ GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -600,11 +599,10 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, const gchar *name) { - gint n_signals; - gint i; + guint n_signals; n_signals = gi_object_info_get_n_signals (info); - for (i = 0; i < n_signals; i++) + for (guint i = 0; i < n_signals; i++) { GISignalInfo *siginfo = gi_object_info_get_signal (info, i); @@ -628,7 +626,7 @@ gi_object_info_find_signal (GIObjectInfo *info, * * Returns: number of virtual functions */ -gint +guint gi_object_info_get_n_vfuncs (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -654,7 +652,7 @@ gi_object_info_get_n_vfuncs (GIObjectInfo *info) */ GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -790,7 +788,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, * * Returns: number of constants */ -gint +guint gi_object_info_get_n_constants (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -816,7 +814,7 @@ gi_object_info_get_n_constants (GIObjectInfo *info) */ GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, - gint n) + guint n) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index 943a1baa0..c0d4bc5f7 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -98,32 +98,32 @@ GI_AVAILABLE_IN_ALL GIObjectInfo * gi_object_info_get_parent (GIObjectInfo *info); GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_interfaces (GIObjectInfo *info); +guint gi_object_info_get_n_interfaces (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_fields (GIObjectInfo *info); +guint gi_object_info_get_n_fields (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_properties (GIObjectInfo *info); +guint gi_object_info_get_n_properties (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_methods (GIObjectInfo *info); +guint gi_object_info_get_n_methods (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, @@ -137,11 +137,11 @@ GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *in GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_signals (GIObjectInfo *info); +guint gi_object_info_get_n_signals (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL @@ -150,11 +150,11 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_vfuncs (GIObjectInfo *info); +guint gi_object_info_get_n_vfuncs (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, @@ -166,11 +166,11 @@ GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *inf GIObjectInfo **implementor); GI_AVAILABLE_IN_ALL -gint gi_object_info_get_n_constants (GIObjectInfo *info); +guint gi_object_info_get_n_constants (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, - gint n); + guint n); GI_AVAILABLE_IN_ALL GIStructInfo * gi_object_info_get_class_struct (GIObjectInfo *info); diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 0741807ab..164031f32 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1040,7 +1040,6 @@ write_object_info (const gchar *ns, gboolean is_final; GIObjectInfo *pnode; GIStructInfo *class_struct; - gint i; name = gi_base_info_get_name ((GIBaseInfo *)info); deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info); @@ -1101,7 +1100,7 @@ write_object_info (const gchar *ns, if (gi_object_info_get_n_interfaces (info) > 0) { - for (i = 0; i < gi_object_info_get_n_interfaces (info); i++) + for (guint i = 0; i < gi_object_info_get_n_interfaces (info); i++) { GIInterfaceInfo *imp = gi_object_info_get_interface (info, i); xml_start_element (file, "implements"); @@ -1111,42 +1110,42 @@ write_object_info (const gchar *ns, } } - for (i = 0; i < gi_object_info_get_n_fields (info); i++) + for (guint i = 0; i < gi_object_info_get_n_fields (info); i++) { GIFieldInfo *field = gi_object_info_get_field (info, i); write_field_info (ns, field, NULL, file); gi_base_info_unref ((GIBaseInfo *)field); } - for (i = 0; i < gi_object_info_get_n_methods (info); i++) + for (guint i = 0; i < gi_object_info_get_n_methods (info); i++) { GIFunctionInfo *function = gi_object_info_get_method (info, i); write_function_info (ns, function, file); gi_base_info_unref ((GIBaseInfo *)function); } - for (i = 0; i < gi_object_info_get_n_properties (info); i++) + for (guint i = 0; i < gi_object_info_get_n_properties (info); i++) { GIPropertyInfo *prop = gi_object_info_get_property (info, i); write_property_info (ns, prop, file); gi_base_info_unref ((GIBaseInfo *)prop); } - for (i = 0; i < gi_object_info_get_n_signals (info); i++) + for (guint i = 0; i < gi_object_info_get_n_signals (info); i++) { GISignalInfo *signal = gi_object_info_get_signal (info, i); write_signal_info (ns, signal, file); gi_base_info_unref ((GIBaseInfo *)signal); } - for (i = 0; i < gi_object_info_get_n_vfuncs (info); i++) + for (guint i = 0; i < gi_object_info_get_n_vfuncs (info); i++) { GIVFuncInfo *vfunc = gi_object_info_get_vfunc (info, i); write_vfunc_info (ns, vfunc, file); gi_base_info_unref ((GIBaseInfo *)vfunc); } - for (i = 0; i < gi_object_info_get_n_constants (info); i++) + for (guint i = 0; i < gi_object_info_get_n_constants (info); i++) { GIConstantInfo *constant = gi_object_info_get_constant (info, i); write_constant_info (ns, constant, file);