diff options
author | Jani Nikula <jani@nikula.org> | 2017-01-06 22:14:49 +0200 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2017-03-10 07:55:15 -0400 |
commit | 069362ee10d0af108c7d0a275bda1a78c4a49f27 (patch) | |
tree | d9fa99e41eb2a468dff4528d9cb109cdf31843bc /mime-node.c | |
parent | 84813729566e37fb2ccdff58cdba635b7a90ba0d (diff) |
cli: simplify mime node walk
The function is more straighforward to read when it's clear that the
only non-NULL return is at one place. No functional changes.
Diffstat (limited to 'mime-node.c')
-rw-r--r-- | mime-node.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mime-node.c b/mime-node.c index c9b82330..f719422e 100644 --- a/mime-node.c +++ b/mime-node.c @@ -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 * |