From 7874052df220caf53e9bb6b949f7e6a4c1903311 Mon Sep 17 00:00:00 2001 From: Ningx Zhao Date: Thu, 11 Mar 2021 21:05:40 +0800 Subject: [PATCH] lib/rbtree: Remove dead case in rb_remove() This "else" clause was dead code, in a valid tree it's not possible to have a node and its child both be red. Fix issue #33239. Signed-off-by: Ningx Zhao --- lib/os/rb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/os/rb.c b/lib/os/rb.c index ee6308ffd7a..341fcec37ac 100644 --- a/lib/os/rb.c +++ b/lib/os/rb.c @@ -478,14 +478,11 @@ void rb_remove(struct rbtree *tree, struct rbnode *node) set_child(parent, get_side(parent, node), child); /* Check colors, if one was red (at least one must have been - * black in a valid tree), then we're done. Otherwise we have - * a missing black we need to fix + * black in a valid tree), then we're done. */ + __ASSERT(is_black(node) || is_black(child), "both nodes red?!"); if (is_red(node) || is_red(child)) { set_color(child, BLACK); - } else { - stack[stacksz - 1] = child; - fix_missing_black(stack, stacksz, NULL); } }