]> git.notmuchmail.org Git - notmuch/commitdiff
cli: simplify mime node walk
authorJani Nikula <jani@nikula.org>
Fri, 6 Jan 2017 20:14:49 +0000 (22:14 +0200)
committerDavid Bremner <david@tethera.net>
Fri, 10 Mar 2017 11:55:15 +0000 (07:55 -0400)
The function is more straighforward to read when it's clear that the
only non-NULL return is at one place. No functional changes.

mime-node.c

index c9b82330f6e08908e85fcae2891bb003c5dfec98..f719422ec678bbe340cd670861bb5cf0b0ca347e 100644 (file)
@@ -322,20 +322,21 @@ mime_node_child (mime_node_t *parent, int child)
 static mime_node_t *
 _mime_node_seek_dfs_walk (mime_node_t *node, int *n)
 {
-    mime_node_t *ret = NULL;
     int i;
 
     if (*n == 0)
        return node;
 
     *n -= 1;
-    for (i = 0; i < node->nchildren && !ret; i++) {
+    for (i = 0; i < node->nchildren; i++) {
        mime_node_t *child = mime_node_child (node, i);
-       ret = _mime_node_seek_dfs_walk (child, n);
-       if (!ret)
-           talloc_free (child);
+       mime_node_t *ret = _mime_node_seek_dfs_walk (child, n);
+       if (ret)
+           return ret;
+
+       talloc_free (child);
     }
-    return ret;
+    return NULL;
 }
 
 mime_node_t *