Code

src/utils_avltree.c: Add assertions to rotate_{left,right}().
authorFlorian Forster <octo@collectd.org>
Wed, 17 Jun 2015 20:08:19 +0000 (22:08 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 17 Jun 2015 20:09:14 +0000 (22:09 +0200)
clang's static code analysis thought that x->right / x->left could be NULL,
reporting false positives. Let's see if this fixes it.

src/utils_avltree.c

index 6a25fb57657104470a1f18fdf7d008f94e830fd6..ecaf3c915967b2daee20489b9d8aa02aa41e6de6 100644 (file)
@@ -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;