From: Florian Forster Date: Wed, 17 Jun 2015 20:08:19 +0000 (+0200) Subject: src/utils_avltree.c: Add assertions to rotate_{left,right}(). X-Git-Tag: collectd-5.5.1~101^2~18 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3d2e974839fb6590b84e58e000fa92ed6282f4c4;p=collectd.git src/utils_avltree.c: Add assertions to rotate_{left,right}(). clang's static code analysis thought that x->right / x->left could be NULL, reporting false positives. Let's see if this fixes it. --- diff --git a/src/utils_avltree.c b/src/utils_avltree.c index 6a25fb57..ecaf3c91 100644 --- a/src/utils_avltree.c +++ b/src/utils_avltree.c @@ -142,6 +142,9 @@ static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x) c_avl_node_t *y; c_avl_node_t *b; + assert (x != NULL); + assert (x->left != NULL); + p = x->parent; y = x->left; b = y->right; @@ -166,7 +169,7 @@ static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x) y->height = calc_height (y); return (y); -} /* void rotate_left */ +} /* void rotate_right */ /* * (x) (y) @@ -183,6 +186,9 @@ static c_avl_node_t *rotate_left (c_avl_tree_t *t, c_avl_node_t *x) c_avl_node_t *y; c_avl_node_t *b; + assert (x != NULL); + assert (x->right != NULL); + p = x->parent; y = x->right; b = y->left;