Merge branch 'fix_more_warnings' into 'main'

Fix more (Windows) warnings

See merge request GNOME/glib!2273
This commit is contained in:
Philip Withnall 2021-10-13 08:49:06 +00:00
commit 02a94a4e7e
5 changed files with 11 additions and 7 deletions

View File

@ -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';

View File

@ -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 +

View File

@ -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);

View File

@ -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++)
{

View File

@ -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));