mtd/fs/jffs2 nodelist.c,1.54,1.55

David Woodhouse dwmw2 at infradead.org
Tue Sep 3 18:12:12 EDT 2002


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv30563

Modified Files:
	nodelist.c 
Log Message:
Take the debugging out of rb_next. Fix rb_replace_node some more.


Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- nodelist.c	3 Sep 2002 21:57:41 -0000	1.54
+++ nodelist.c	3 Sep 2002 22:12:10 -0000	1.55
@@ -516,14 +516,9 @@
 	/* If we have a right-hand child, go down and then left as far
 	   as we can. */
 	if (node->rb_right) {
-		D1(printk("Following right pointer frmo %p to %p\n",
-		       node, node->rb_right));
 		node = node->rb_right; 
-		while (node->rb_left) {
-			D1(printk("Following left pointer from %p to %p\n",
-				  node, node->rb_left));
+		while (node->rb_left)
 			node=node->rb_left;
-		}
 		return node;
 	}
 
@@ -533,12 +528,9 @@
 	   ancestor is a right-hand child of its parent, keep going
 	   up. First time it's a left-hand child of its parent, said
 	   parent is our 'next' node. */
-	while (node->rb_parent && node == node->rb_parent->rb_right) {
-		D1(printk("Following parent pointer frmo %p to %p\n",
-			  node, node->rb_parent));
+	while (node->rb_parent && node == node->rb_parent->rb_right)
 		node = node->rb_parent;
-	}
-	D1(printk("Returning parent %p\n", node->rb_parent));
+
 	return node->rb_parent;
 }
 
@@ -546,15 +538,18 @@
 {
 	rb_node_t *parent = victim->rb_parent;
 
-	if (victim == parent->rb_left)
-		parent->rb_left = new;
-	else
-		parent->rb_right = new;
-
-	*new = *victim;
-
+	/* Set the surrounding nodes to point to the replacement */
+	if (parent) {
+		if (victim == parent->rb_left)
+			parent->rb_left = new;
+		else
+			parent->rb_right = new;
+	}
 	if (victim->rb_left)
 		victim->rb_left->rb_parent = new;
 	if (victim->rb_right)
 		victim->rb_right->rb_parent = new;
+
+	/* Copy the pointers/colour from the victim to the replacement */
+	*new = *victim;
 }





More information about the linux-mtd-cvs mailing list