[gvdb/mcatanzaro/sign-compare] Fix -Wsign-compare warning



commit 18a0d95aa21f5007a330c00d7d25412695525bf1
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Jun 22 13:34:21 2019 -0500

    Fix -Wsign-compare warning
    
    [23/236] Compiling C object 'lib/76b5a...isc@sha/contrib_gvdb_gvdb-reader.c.o'.
    ../../../../Projects/epiphany/lib/contrib/gvdb/gvdb-reader.c: In function ‘gvdb_table_get_names’:
    ../../../../Projects/epiphany/lib/contrib/gvdb/gvdb-reader.c:428:27: warning: comparison of integer 
expressions of different signedness: ‘guint32’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} [-Wsign-compare]
      428 |           else if (parent < n_names && names[parent] != NULL)
          |                           ^
    
    To fix this, we have to change n_names to guint, and then also change
    the types of everything it's compared against. This seems to be safe
    since none of these should ever be negative.

 gvdb-reader.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gvdb-reader.c b/gvdb-reader.c
index ccae40e..2dbb5b4 100644
--- a/gvdb-reader.c
+++ b/gvdb-reader.c
@@ -351,10 +351,10 @@ gvdb_table_get_names (GvdbTable *table,
                       gsize     *length)
 {
   gchar **names;
-  gint n_names;
-  gint filled;
-  gint total;
-  gint i;
+  guint n_names;
+  guint filled;
+  guint total;
+  guint i;
 
   /* We generally proceed by iterating over the list of items in the
    * hash table (in order of appearance) recording them into an array.


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