From 33c29686690ee16fa437d64a479793e9fdc212e3 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 14 May 2021 10:47:40 +0200 Subject: [PATCH 1/5] Fix always false statement warning in glib/gdatetime.c glib/gdatetime.c:896:27: warning: comparison is always false due to limited range of data type if ((gint64) tv->tv_sec > G_MAXINT64 - 1 || ^ --- glib/gdatetime.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glib/gdatetime.c b/glib/gdatetime.c index a31afe713..429cadefc 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -893,8 +893,9 @@ static GDateTime * g_date_time_new_from_timeval (GTimeZone *tz, const GTimeVal *tv) { - if ((gint64) tv->tv_sec > G_MAXINT64 - 1 || - !UNIX_TO_INSTANT_IS_VALID ((gint64) tv->tv_sec + 1)) + gint64 tv_sec = tv->tv_sec; + + if (tv_sec > G_MAXINT64 - 1 || !UNIX_TO_INSTANT_IS_VALID (tv_sec + 1)) return NULL; return g_date_time_from_instant (tz, tv->tv_usec + From 74c3c5b75d5d3a942128429a88573f8d2df24649 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 14 May 2021 10:51:46 +0200 Subject: [PATCH 2/5] Fix signedness warning in glib/gcharset.c glib/gcharset.c:380:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' else if (modifier - dot < sizeof (buf)) ^ --- glib/gcharset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gcharset.c b/glib/gcharset.c index 9f91a9b48..48cb0ffae 100644 --- a/glib/gcharset.c +++ b/glib/gcharset.c @@ -377,7 +377,7 @@ g_get_console_charset (const char **charset) modifier = strchr (dot, '@'); if (modifier == NULL) raw = dot; - else if (modifier - dot < sizeof (buf)) + else if ((gsize) (modifier - dot) < sizeof (buf)) { memcpy (buf, dot, modifier - dot); buf[modifier - dot] = '\0'; From affa41179a29c3ff5322ae902a7d7ee794d1ef25 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 14 May 2021 11:26:39 +0200 Subject: [PATCH 3/5] Fix signedness warning in glib/ghostutils.c glib/ghostutils.c: In function 'punycode_encode': glib/ghostutils.c:141:35: warning: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'glong' {aka 'long int'} for (j = num_basic_chars = 0; j < input_length; j++) ^ glib/ghostutils.c:158:24: warning: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'glong' {aka 'long int'} while (handled_chars < input_length) ^ glib/ghostutils.c:161:36: warning: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'glong' {aka 'long int'} for (m = G_MAXUINT, j = 0; j < input_length; j++) ^ glib/ghostutils.c:172:21: warning: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'glong' {aka 'long int'} for (j = 0; j < input_length; j++) ^ --- glib/ghostutils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/glib/ghostutils.c b/glib/ghostutils.c index dff4a1997..24a7d37bb 100644 --- a/glib/ghostutils.c +++ b/glib/ghostutils.c @@ -128,15 +128,18 @@ punycode_encode (const gchar *input_utf8, { guint delta, handled_chars, num_basic_chars, bias, j, q, k, t, digit; gunichar n, m, *input; - glong input_length; + glong written_chars; + gsize input_length; gboolean success = FALSE; /* Convert from UTF-8 to Unicode code points */ input = g_utf8_to_ucs4 (input_utf8, input_utf8_length, NULL, - &input_length, NULL); + &written_chars, NULL); if (!input) return FALSE; + input_length = (gsize) (written_chars > 0 ? written_chars : 0); + /* Copy basic chars */ for (j = num_basic_chars = 0; j < input_length; j++) { From 574842a12e6f09048183529ead1f462ad47908b4 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 14 May 2021 11:30:59 +0200 Subject: [PATCH 4/5] Fix signedness warning in glib/genviron.c glib/genviron.c: In function 'g_getenv': glib/genviron.c:490:52: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int' if (GetEnvironmentVariableW (wname, wvalue, len) != len - 1) ^~ glib/genviron.c:507:60: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int' if (ExpandEnvironmentStringsW (tem, wvalue, len) != len) ^~ --- glib/genviron.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/genviron.c b/glib/genviron.c index 04e9ab0a0..44e10d4bd 100644 --- a/glib/genviron.c +++ b/glib/genviron.c @@ -454,7 +454,7 @@ g_getenv (const gchar *variable) GQuark quark; gchar *value; wchar_t dummy[2], *wname, *wvalue; - int len; + DWORD len; g_return_val_if_fail (variable != NULL, NULL); g_return_val_if_fail (g_utf8_validate (variable, -1, NULL), NULL); From cd04e0b7a4605ed3b2e8a2672dd4e237254d5512 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 14 May 2021 11:40:02 +0200 Subject: [PATCH 5/5] Fix signedness warning in glib/gslice.c glib/gslice.c: In function 'slice_config_init': glib/gslice.c:394:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' else if (len >= G_N_ELEMENTS (wvalue)) ^~ --- glib/gslice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gslice.c b/glib/gslice.c index 690d21e07..190b20634 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -380,7 +380,7 @@ slice_config_init (SliceConfig *config) { wchar_t wvalue[128]; /* at least big enough for `always-malloc,debug-blocks` */ - int len; + gsize len; len = GetEnvironmentVariableW (L"G_SLICE", wvalue, G_N_ELEMENTS (wvalue));