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 :(
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;