Fix warnings from the Clang Static Analyzer.
[tinc] / src / avl_tree.c
index 4b23756..f1645d5 100644 (file)
@@ -2,7 +2,7 @@
     avl_tree.c -- avl_ tree and linked list convenience
     Copyright (C) 1998 Michael H. Buselli
                   2000-2005 Ivo Timmermans,
-                  2000-2006 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2014 Guus Sliepen <guus@tinc-vpn.org>
                   2000-2005 Wessel Dankers <wsl@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
@@ -123,8 +123,6 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
        avl_node_t *parent;
        avl_node_t **superparent;
 
-       parent = node;
-
        while(node) {
                parent = node->parent;
 
@@ -168,14 +166,12 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
                                                child->right->parent = child;
                                        gchild->right = node;
 
-                                       if(gchild->right)
-                                               gchild->right->parent = gchild;
+                                       gchild->right->parent = gchild;
                                        gchild->left = child;
 
-                                       if(gchild->left)
-                                               gchild->left->parent = gchild;
-                                       *superparent = gchild;
+                                       gchild->left->parent = gchild;
 
+                                       *superparent = gchild;
                                        gchild->parent = parent;
 #ifdef AVL_COUNT
                                        node->count = AVL_CALC_COUNT(node);
@@ -224,8 +220,7 @@ static void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
                                                child->left->parent = child;
                                        gchild->left = node;
 
-                                       if(gchild->left)
-                                               gchild->left->parent = gchild;
+                                       gchild->left->parent = gchild;
                                        gchild->right = child;
 
                                        gchild->right->parent = gchild;