[gnome-builder] rg: fix various -Wsign-compare warnings



commit e3bf39a318dae4f721c44f7bcc7c294800f1bf42
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 28 12:47:24 2017 -0800

    rg: fix various -Wsign-compare warnings

 contrib/rg/rg-cpu-table.c |    2 +-
 contrib/rg/rg-ring.c      |   12 ++++++------
 contrib/rg/rg-table.c     |    4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/contrib/rg/rg-cpu-table.c b/contrib/rg/rg-cpu-table.c
index 95eb7fa..8f9cf8e 100644
--- a/contrib/rg/rg-cpu-table.c
+++ b/contrib/rg/rg-cpu-table.c
@@ -110,7 +110,7 @@ rg_cpu_table_poll (RgCpuTable *self)
 
                     ret = sscanf(cpu, "cpu%d", &id);
 
-                    if (ret != 1 || id < 0 || id >= self->n_cpu)
+                    if (ret != 1 || id < 0 || id >= (gint)self->n_cpu)
                       goto next;
 
                     cpu_info = &g_array_index (self->cpu_info, CpuInfo, id);
diff --git a/contrib/rg/rg-ring.c b/contrib/rg/rg-ring.c
index 0e4662b..748a9e9 100644
--- a/contrib/rg/rg-ring.c
+++ b/contrib/rg/rg-ring.c
@@ -86,16 +86,16 @@ rg_ring_append_vals (RgRing        *ring,
   gpointer idx;
   gint ret = -1;
   gint x;
-  gint i;
 
   g_return_val_if_fail (ring_impl != NULL, 0);
   g_return_val_if_fail (len <= ring->len, 0);
   g_return_val_if_fail (len > 0, 0);
+  g_return_val_if_fail (len <= G_MAXINT, 0);
 
-  for (i = 0; i < len; i++)
+  for (gint i = 0; i < (gint)len; i++)
     {
       x = ring->pos - i;
-      x = (x >= 0) ? x : ring->len + x;
+      x = (x >= 0) ? x : (gint)ring->len + x;
       idx = ring->data + (ring_impl->elt_size * x);
       if (ring_impl->destroy && (ring_impl->looped == TRUE))
         ring_impl->destroy (idx);
@@ -134,15 +134,15 @@ rg_ring_foreach (RgRing *ring,
 
   if (!ring_impl->looped)
     {
-      for (i = 0; i < ring_impl->pos; i++)
+      for (i = 0; i < (gint)ring_impl->pos; i++)
         func (get_element (ring_impl, i), user_data);
       return;
     }
 
-  for (i = ring_impl->pos; i < ring_impl->len; i++)
+  for (i = ring_impl->pos; i < (gint)ring_impl->len; i++)
     func (get_element (ring_impl, i), user_data);
 
-  for (i = 0; i < ring_impl->pos; i++)
+  for (i = 0; i < (gint)ring_impl->pos; i++)
     func (get_element (ring_impl, i), user_data);
 }
 
diff --git a/contrib/rg/rg-table.c b/contrib/rg/rg-table.c
index d194030..9a11ff7 100644
--- a/contrib/rg/rg-table.c
+++ b/contrib/rg/rg-table.c
@@ -345,7 +345,7 @@ rg_table_iter_set (RgTableIter *iter,
     {
       RgColumn *column;
 
-      if (column_id >= priv->columns->len)
+      if (column_id >= (gint)priv->columns->len)
         {
           g_critical ("No such column %d", column_id);
           goto cleanup;
@@ -387,7 +387,7 @@ rg_table_iter_get (RgTableIter *iter,
     {
       RgColumn *column;
 
-      if (column_id >= priv->columns->len)
+      if (column_id >= (gint)priv->columns->len)
         {
           g_critical ("No such column %d", column_id);
           goto cleanup;


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