summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6efc94f)
raw | patch | inline | side by side (parent: 6efc94f)
author | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:55:42 +0000 (08:55 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 17 Jun 2015 06:55:44 +0000 (08:55 +0200) |
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 :(
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 | patch | blob | history |
diff --git a/src/utils_avltree.c b/src/utils_avltree.c
index f71b1fd6913bbc9676bb0e494d26bba1f829e7c2..6a25fb57657104470a1f18fdf7d008f94e830fd6 100644 (file)
--- a/src/utils_avltree.c
+++ b/src/utils_avltree.c
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;