[glib: 4/7] Fix signedness warnings in glib/gutf8.c




commit 8c35109a2162d263c14c2270e2df1950e380978d
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Thu Nov 4 21:48:31 2021 +0100

    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++)
          |                     ^

 glib/gutf8.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/gutf8.c b/glib/gutf8.c
index 7d053540d..52e593d93 100644
--- a/glib/gutf8.c
+++ b/glib/gutf8.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]