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
This commit is contained in:
Philip Withnall 2014-06-21 11:27:48 +01:00 committed by Philip Withnall
parent b16d7fc1a7
commit ae7895002b

View File

@ -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))