From ec36370dcbca1412d111abda1ced2f08842eb5c9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 25 Apr 2024 00:41:34 +0100 Subject: [PATCH] girepository: Fix various implicit conversions from size_t to smaller types Basically various trivial instances of the following MSVC compiler warning: ``` ../gio/gio-tool-set.c(50): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data ``` Signed-off-by: Philip Withnall --- girepository/gibaseinfo.c | 4 +++- girepository/gicallableinfo.c | 2 +- girepository/gifieldinfo.c | 4 ++-- girepository/girnode.c | 2 +- girepository/girwriter.c | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index ccc5aed37..d85106f65 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -223,12 +223,14 @@ gi_base_info_type_register_static (const char *type_name, { GTypeInfo info; + g_assert (instance_size <= G_MAXUINT16); + info.class_size = sizeof (GIBaseInfoClass); info.base_init = NULL; info.base_finalize = NULL; info.class_init = class_init; info.class_finalize = NULL; - info.instance_size = instance_size; + info.instance_size = (guint16) instance_size; info.n_preallocs = 0; info.instance_init = NULL; info.value_table = NULL; diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 49430e9a8..23d31f1a4 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -651,7 +651,7 @@ gi_callable_info_invoke (GICallableInfo *info, GITypeInfo *rinfo; GITypeTag rtag; GIArgInfo *ainfo; - size_t n_args, n_invoke_args, in_pos, out_pos, i; + unsigned int n_args, n_invoke_args, in_pos, out_pos, i; void **args; gboolean success = FALSE; GError *local_error = NULL; diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 819ccf72b..24b2a5e6d 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -190,7 +190,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, void *mem, GIArgument *value) { - int offset; + size_t offset; GITypeInfo *type_info; gboolean result = FALSE; @@ -385,7 +385,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, void *mem, const GIArgument *value) { - int offset; + size_t offset; GITypeInfo *type_info; gboolean result = FALSE; diff --git a/girepository/girnode.c b/girepository/girnode.c index efc022d72..b3ea89323 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -571,7 +571,7 @@ gi_ir_node_get_size (GIIrNode *node) g_assert (size <= G_MAXUINT32); - return size; + return (guint32) size; } static void diff --git a/girepository/girwriter.c b/girepository/girwriter.c index a0307a29d..d0b5d0803 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1338,7 +1338,8 @@ gi_ir_writer_write (GIRepository *repository, gboolean show_all) { FILE *ofile; - size_t i, j; + size_t i; + unsigned int j; char **dependencies; Xml *xml;