[glib] gnode: Eliminate implicit signed-to-unsigned integer conversion



commit ae7895002b993022694c2435a12e4449dbac1d87
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Jun 21 11:27:48 2014 +0100

    gnode: Eliminate implicit signed-to-unsigned integer conversion
    
    When doing a level traverse of a GNode with depth of -1, the depth was
    implicitly being converted to an unsigned integer. This worked (making
    the depth limit G_MAXUINT), but was a bit mystical.
    
    Change g_node_depth_traverse_level() to explicitly take a signed depth
    and handle it appropriately.
    
    Coverity issue: #1159465
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732003

 glib/gnode.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gnode.c b/glib/gnode.c
index 9d5ff57..de98fd5 100644
--- a/glib/gnode.c
+++ b/glib/gnode.c
@@ -779,7 +779,7 @@ g_node_traverse_level (GNode                 *node,
 static gboolean
 g_node_depth_traverse_level (GNode             *node,
                             GTraverseFlags     flags,
-                            guint              depth,
+                            gint               depth,
                             GNodeTraverseFunc  func,
                             gpointer           data)
 {
@@ -787,7 +787,7 @@ g_node_depth_traverse_level (GNode             *node,
   gboolean more_levels;
 
   level = 0;  
-  while (level != depth) 
+  while (depth < 0 || level != (guint) depth)
     {
       more_levels = FALSE;
       if (g_node_traverse_level (node, flags, level, func, data, &more_levels))


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