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'; 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 + 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); 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++) { 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));