diff --git a/sys/sys/tree.h b/sys/sys/tree.h index bc01e4de910a..0403288d1d68 100644 --- a/sys/sys/tree.h +++ b/sys/sys/tree.h @@ -719,15 +719,10 @@ name##_RB_NEXT(struct type *elm) \ while (RB_LEFT(elm, field)) \ elm = RB_LEFT(elm, field); \ } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ + elm = RB_PARENT(elm, field); \ } \ return (elm); \ } @@ -742,15 +737,10 @@ name##_RB_PREV(struct type *elm) \ while (RB_RIGHT(elm, field)) \ elm = RB_RIGHT(elm, field); \ } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ + while (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ + elm = RB_PARENT(elm, field); \ } \ return (elm); \ }