-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/rbtree: Remove dead case in rb_remove() #33239
Labels
Comments
explora26
changed the title
Reb/black tree: maybe we can remove some bed code
Reb/black tree: maybe we can remove some bad code
Mar 11, 2021
Zhaoningx
changed the title
Reb/black tree: maybe we can remove some bad code
lib/rbtree: Remove dead case in rb_remove()
Mar 12, 2021
Zhaoningx
added a commit
to Zhaoningx/zephyr
that referenced
this issue
Mar 12, 2021
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 zephyrproject-rtos#33239. Signed-off-by: Ningx Zhao <[email protected]>
nashif
pushed a commit
that referenced
this issue
Mar 13, 2021
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 <[email protected]>
It has fixed, so closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
I find some code that never been reached here in rb.c(lines 486~489) , the code screenshot as below:
let's do something firstly, Naming node that ready to be removed as A, and naming the biggest node of side 0 about A as B, so let me show you my point.
After my analysis, I think if the code can be reached here, It must meet the following conditions:
The first condition, the node A has two child, demo it such as(A is 30, B is 25, C is 23):
I think when B is red or C is black can reach the
else{...}
code (lines 486~489), but as you see, it is not satisfied the Red/black tree's principle.The second condition, the node A just has one left child, demo it such as(A is 50, B is 45):
I think when A and B are both same color can reach the
else{...}
code (lines 486~489), but it's also not satisfied the rbtree's principle.In my opinion, whatever we do, it can't be covered for the
else{ ... }
code except two conditions(with corrupt rbtree) above. So I think we should deleteelse{}
code(lines 486~489).Impact
It will makes a impact for tree's code coverage.
The text was updated successfully, but these errors were encountered: