[glib: 10/25] Fixing signedness problem in glib/gstrfuncs.c



commit 592d4369d4668b11649f94aa1d5335925934d5df
Author: Emmanuel Fleury <emmanuel fleury u-bordeaux fr>
Date:   Mon Feb 4 09:49:35 2019 +0100

    Fixing signedness problem in glib/gstrfuncs.c
    
    glib/gstrfuncs.c: In function ‘g_strstr_len’:
    glib/gstrfuncs.c:2709:24: error: comparison of integer expressions of different signedness: ‘gssize’ {aka 
‘long int’} and ‘gsize’ {aka ‘long unsigned int’} [-Werror=sign-compare]
           if (haystack_len < needle_len)
                            ^

 glib/gstrfuncs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 756dbc5bc..78eb71d3e 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -2700,13 +2700,14 @@ g_strstr_len (const gchar *haystack,
     {
       const gchar *p = haystack;
       gsize needle_len = strlen (needle);
+      gsize haystack_len_unsigned = haystack_len;
       const gchar *end;
       gsize i;
 
       if (needle_len == 0)
         return (gchar *)haystack;
 
-      if (haystack_len < needle_len)
+      if (haystack_len_unsigned < needle_len)
         return NULL;
 
       end = haystack + haystack_len - needle_len;


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