]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Fix rbtree-interval balancing
authorSasha Levin <levinsasha928@gmail.com>
Sat, 21 May 2011 08:51:50 +0000 (11:51 +0300)
committerPekka Enberg <penberg@kernel.org>
Sat, 21 May 2011 09:02:54 +0000 (12:02 +0300)
Augmentation is started on the pre-rotation node found in the search,
augment the rotated node instead.

Max high is the max of max highs below it, not the max of highs below it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/util/rbtree-interval.c

index 735e912cf4c00e49996562d2cff9aeebae58d682..d02fbf0c469c08d2cff4fdcc521b566d436b1498 100644 (file)
@@ -51,9 +51,9 @@ static void update_node_max_high(struct rb_node *node, void *arg)
        i_node->max_high = i_node->high;
 
        if (node->rb_left)
-               i_node->max_high = max(i_node->max_high, rb_int(node->rb_left)->high);
+               i_node->max_high = max(i_node->max_high, rb_int(node->rb_left)->max_high);
        if (node->rb_right)
-               i_node->max_high = max(i_node->max_high, rb_int(node->rb_right)->high);
+               i_node->max_high = max(i_node->max_high, rb_int(node->rb_right)->max_high);
 }
 
 int rb_int_insert(struct rb_root *root, struct rb_int_node *i_node)
@@ -75,7 +75,7 @@ int rb_int_insert(struct rb_root *root, struct rb_int_node *i_node)
        rb_link_node(&i_node->node, parent, node);
        rb_insert_color(&i_node->node, root);
 
-       rb_augment_insert(*node, update_node_max_high, NULL);
+       rb_augment_insert(&i_node->node, update_node_max_high, NULL);
        return 1;
 }