From 86ef26818f3a1af5afb4842e9c97c34ffe98bafa Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 17 Jun 2015 08:55:42 +0200 Subject: [PATCH] src/utils_avltree.c: Rewrite checks in c_avl_pick(). The previous code made the (correct) assumption that "height" is always greater than zero. This tripped up clang's "scan-build". This confuses the static analysis in two more places in this file, which are not as easy to fix :( --- src/utils_avltree.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils_avltree.c b/src/utils_avltree.c index f71b1fd6..6a25fb57 100644 --- a/src/utils_avltree.c +++ b/src/utils_avltree.c @@ -613,10 +613,18 @@ int c_avl_pick (c_avl_tree_t *t, void **key, void **value) n = t->root; while ((n->left != NULL) || (n->right != NULL)) { - int height_left = (n->left == NULL) ? 0 : n->left->height; - int height_right = (n->right == NULL) ? 0 : n->right->height; + if (n->left == NULL) + { + n = n->right; + continue; + } + else if (n->right == NULL) + { + n = n->left; + continue; + } - if (height_left > height_right) + if (n->left->height > n->right->height) n = n->left; else n = n->right; -- 2.11.0