Skip to content

Commit

Permalink
lib/rbtree: Remove dead case in rb_remove()
Browse files Browse the repository at this point in the history
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 <ningx.zhao@intel.com>
  • Loading branch information
Zhaoningx authored and nashif committed Mar 13, 2021
1 parent 15b9565 commit 7874052
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/os/rb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 7874052

Please sign in to comment.