Fix signedness warnings in glib/gutf8.c

glib/gutf8.c: In function 'g_utf8_get_char_extended':
glib/gutf8.c:626:39: error: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'gssize' {aka 'int'}
  626 |   if (G_UNLIKELY (max_len >= 0 && len > max_len))
      |                                       ^
glib/gmacros.h:1091:27: note: in definition of macro 'G_UNLIKELY'
 1091 | #define G_UNLIKELY(expr) (expr)
      |                           ^~~~
glib/gutf8.c:628:21: error: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'gssize' {aka 'int'}
  628 |       for (i = 1; i < max_len; i++)
      |                     ^
This commit is contained in:
Emmanuel Fleury
2021-11-04 21:48:31 +01:00
parent 264055f3c0
commit 8c35109a21

View File

@@ -574,7 +574,7 @@ static inline gunichar
g_utf8_get_char_extended (const gchar *p,
gssize max_len)
{
guint i, len;
gsize i, len;
gunichar min_code;
gunichar wc = (guchar) *p;
const gunichar partial_sequence = (gunichar) -2;
@@ -623,9 +623,9 @@ g_utf8_get_char_extended (const gchar *p,
return malformed_sequence;
}
if (G_UNLIKELY (max_len >= 0 && len > max_len))
if (G_UNLIKELY (max_len >= 0 && len > (gsize) max_len))
{
for (i = 1; i < max_len; i++)
for (i = 1; i < (gsize) max_len; i++)
{
if ((((guchar *)p)[i] & 0xc0) != 0x80)
return malformed_sequence;