public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rbtree: Add some necessary condition checks
@ 2013-08-23 15:03 zwu.kernel
  2013-08-26 21:52 ` Andrew Morton
  0 siblings, 1 reply; 16+ messages in thread
From: zwu.kernel @ 2013-08-23 15:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: walken, akpm, Zhi Yong Wu

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 include/linux/rbtree_augmented.h | 3 ++-
 lib/rbtree.c                     | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index fea49b5..7d19770 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -199,7 +199,8 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root,
 		}
 
 		successor->rb_left = tmp = node->rb_left;
-		rb_set_parent(tmp, successor);
+		if (tmp)
+			rb_set_parent(tmp, successor);
 
 		pc = node->__rb_parent_color;
 		tmp = __rb_parent(pc);
diff --git a/lib/rbtree.c b/lib/rbtree.c
index c0e31fe..329f2bc 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -226,7 +226,8 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 				 */
 				parent->rb_right = tmp1 = sibling->rb_left;
 				sibling->rb_left = parent;
-				rb_set_parent_color(tmp1, parent, RB_BLACK);
+				if (tmp1)
+					rb_set_parent_color(tmp1, parent, RB_BLACK);
 				__rb_rotate_set_parents(parent, sibling, root,
 							RB_RED);
 				augment_rotate(parent, sibling);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH] rbtree: Add some necessary condition checks
@ 2013-08-23 15:01 zwu.kernel
  0 siblings, 0 replies; 16+ messages in thread
From: zwu.kernel @ 2013-08-23 15:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: walken, akpm, Zhi Yong Wu

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 include/linux/rbtree_augmented.h | 3 ++-
 lib/rbtree.c                     | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index fea49b5..7d19770 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -199,7 +199,8 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root,
 		}
 
 		successor->rb_left = tmp = node->rb_left;
-		rb_set_parent(tmp, successor);
+		if (tmp)
+			rb_set_parent(tmp, successor);
 
 		pc = node->__rb_parent_color;
 		tmp = __rb_parent(pc);
diff --git a/lib/rbtree.c b/lib/rbtree.c
index c0e31fe..329f2bc 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -226,7 +226,8 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 				 */
 				parent->rb_right = tmp1 = sibling->rb_left;
 				sibling->rb_left = parent;
-				rb_set_parent_color(tmp1, parent, RB_BLACK);
+				if (tmp1)
+					rb_set_parent_color(tmp1, parent, RB_BLACK);
 				__rb_rotate_set_parents(parent, sibling, root,
 							RB_RED);
 				augment_rotate(parent, sibling);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH] rbtree: Add some necessary condition checks
@ 2013-08-23 14:45 zwu.kernel
  2013-08-26 22:01 ` Michel Lespinasse
  0 siblings, 1 reply; 16+ messages in thread
From: zwu.kernel @ 2013-08-23 14:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: walken, akpm, Zhi Yong Wu

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 include/linux/rbtree_augmented.h | 3 ++-
 lib/rbtree.c                     | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index fea49b5..7d19770 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -199,7 +199,8 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root,
 		}
 
 		successor->rb_left = tmp = node->rb_left;
-		rb_set_parent(tmp, successor);
+		if (tmp)
+			rb_set_parent(tmp, successor);
 
 		pc = node->__rb_parent_color;
 		tmp = __rb_parent(pc);
diff --git a/lib/rbtree.c b/lib/rbtree.c
index c0e31fe..2cb01ba 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -214,7 +214,7 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 		 */
 		sibling = parent->rb_right;
 		if (node != sibling) {	/* node == parent->rb_left */
-			if (rb_is_red(sibling)) {
+			if (sibling && rb_is_red(sibling)) {
 				/*
 				 * Case 1 - left rotate at parent
 				 *
@@ -226,7 +226,8 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root,
 				 */
 				parent->rb_right = tmp1 = sibling->rb_left;
 				sibling->rb_left = parent;
-				rb_set_parent_color(tmp1, parent, RB_BLACK);
+				if (tmp1)
+					rb_set_parent_color(tmp1, parent, RB_BLACK);
 				__rb_rotate_set_parents(parent, sibling, root,
 							RB_RED);
 				augment_rotate(parent, sibling);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-09-05  1:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23 15:03 [PATCH] rbtree: Add some necessary condition checks zwu.kernel
2013-08-26 21:52 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2013-08-23 15:01 zwu.kernel
2013-08-23 14:45 zwu.kernel
2013-08-26 22:01 ` Michel Lespinasse
2013-09-02  6:30   ` Zhi Yong Wu
2013-09-02  8:57     ` Michel Lespinasse
2013-09-03  4:45       ` Zhi Yong Wu
2013-09-03  5:48         ` Michel Lespinasse
2013-09-03  6:22           ` Zhi Yong Wu
2013-09-03  6:58           ` Zhi Yong Wu
2013-09-04 17:22       ` Zhi Yong Wu
2013-09-04 23:59         ` Davidlohr Bueso
2013-09-05  0:37           ` Zhi Yong Wu
2013-09-05  1:12             ` Davidlohr Bueso
2013-09-05  1:25               ` Zhi Yong Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox