From 3f3a7472b3f7dbf70aef2021589837bb38adc7c0 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Mon, 4 Feb 2019 13:45:41 +0100 Subject: [PATCH] Fixing signedness in glib/gvariant.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit glib/gvariant.c: In function ‘g_variant_new_strv’: glib/gvariant.c:1563:17: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘gssize’ {aka ‘long int’} [-Werror=sign-compare] for (i = 0; i < length; i++) ^ glib/gvariant.c: In function ‘g_variant_new_objv’: glib/gvariant.c:1699:17: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘gssize’ {aka ‘long int’} [-Werror=sign-compare] for (i = 0; i < length; i++) ^ glib/gvariant.c: In function ‘g_variant_new_bytestring_array’: glib/gvariant.c:1939:17: error: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘gssize’ {aka ‘long int’} [-Werror=sign-compare] for (i = 0; i < length; i++) ^ --- glib/gvariant.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index 0b6edc2ab..db56560a6 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -1552,19 +1552,20 @@ g_variant_new_strv (const gchar * const *strv, gssize length) { GVariant **strings; - gsize i; + gsize i, length_unsigned; g_return_val_if_fail (length == 0 || strv != NULL, NULL); if (length < 0) length = g_strv_length ((gchar **) strv); + length_unsigned = length; - strings = g_new (GVariant *, length); - for (i = 0; i < length; i++) + strings = g_new (GVariant *, length_unsigned); + for (i = 0; i < length_unsigned; i++) strings[i] = g_variant_ref_sink (g_variant_new_string (strv[i])); return g_variant_new_from_children (G_VARIANT_TYPE_STRING_ARRAY, - strings, length, TRUE); + strings, length_unsigned, TRUE); } /** @@ -1688,19 +1689,20 @@ g_variant_new_objv (const gchar * const *strv, gssize length) { GVariant **strings; - gsize i; + gsize i, length_unsigned; g_return_val_if_fail (length == 0 || strv != NULL, NULL); if (length < 0) length = g_strv_length ((gchar **) strv); + length_unsigned = length; - strings = g_new (GVariant *, length); - for (i = 0; i < length; i++) + strings = g_new (GVariant *, length_unsigned); + for (i = 0; i < length_unsigned; i++) strings[i] = g_variant_ref_sink (g_variant_new_object_path (strv[i])); return g_variant_new_from_children (G_VARIANT_TYPE_OBJECT_PATH_ARRAY, - strings, length, TRUE); + strings, length_unsigned, TRUE); } /** @@ -1928,19 +1930,20 @@ g_variant_new_bytestring_array (const gchar * const *strv, gssize length) { GVariant **strings; - gsize i; + gsize i, length_unsigned; g_return_val_if_fail (length == 0 || strv != NULL, NULL); if (length < 0) length = g_strv_length ((gchar **) strv); + length_unsigned = length; - strings = g_new (GVariant *, length); - for (i = 0; i < length; i++) + strings = g_new (GVariant *, length_unsigned); + for (i = 0; i < length_unsigned; i++) strings[i] = g_variant_ref_sink (g_variant_new_bytestring (strv[i])); return g_variant_new_from_children (G_VARIANT_TYPE_BYTESTRING_ARRAY, - strings, length, TRUE); + strings, length_unsigned, TRUE); } /**