summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tree.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/tree.c b/src/tree.c
index 9b2c22b..90a7af7 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -151,32 +151,28 @@ static gboolean
foreach(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
gpointer user_data)
{
- gboolean ret;
-
- ret = MQ_TREE_CONTINUE;
for (; node; node = node->next) {
/* XXX: Warning: Does not skip root node */
- ret = cb(node, user_data);
- if (ret == MQ_TREE_STOP) {
- break;
+ if (cb(node, user_data) == MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
}
if (node->first_child) {
- ret = foreach(node->first_child, cb, user_data);
- if (ret == MQ_TREE_STOP) {
- break;
+ if (foreach(node->first_child, cb, user_data) ==
+ MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
}
}
if (node->parent && node->parent->next) {
- ret = foreach(node->parent->next, cb, user_data);
- if (ret == MQ_TREE_STOP) {
- break;
+ if (foreach(node->parent->next, cb, user_data) ==
+ MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
}
}
}
- return ret;
+ return MQ_TREE_CONTINUE;
}
void
@@ -190,17 +186,13 @@ static gboolean
foreach_child(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
gpointer user_data)
{
- gboolean ret;
-
- ret = MQ_TREE_CONTINUE;
for (node = node->first_child; node; node = node->next) {
- ret = cb(node, user_data);
- if (ret == MQ_TREE_STOP) {
- break;
+ if (cb(node, user_data) == MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
}
}
- return ret;
+ return MQ_TREE_CONTINUE;
}
void