]> sourceware.org Git - newlib-cygwin.git/commitdiff
sys/tree.h: Simplify loop condition
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 5 Oct 2021 13:31:22 +0000 (15:31 +0200)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 5 Oct 2021 14:09:11 +0000 (16:09 +0200)
We have

  #define RB_ISRED(elm, field) \
    ((elm) != NULL && RB_COLOR(elm, field) == RB_RED)

So, the RB_ISRED() contains an implicit check for NULL.  In
RB_GENERATE_REMOVE_COLOR() the "elm" pointer cannot be NULL in the while
condition.  Use RB_COLOR(elm) == RB_BLACK instead.

newlib/libc/include/sys/tree.h

index 2af77a4992a45749c4576b0192d4590f5a5f417e..15831c7dd34dccbe544070bcb5a006d667b06c26 100644 (file)
@@ -540,7 +540,7 @@ name##_RB_REMOVE_COLOR(struct name *head, struct type *parent)              \
                        elm = RB_ROOT(head);                            \
                        break;                                          \
                }                                                       \
-       } while (!RB_ISRED(elm, field) && parent != NULL);              \
+       } while (RB_COLOR(elm, field) == RB_BLACK && parent != NULL);   \
        RB_COLOR(elm, field) = RB_BLACK;                                \
 }
 
This page took 0.031276 seconds and 5 git commands to generate.