<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 7/21/2014 3:23 PM, Gedare Bloom
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAC82fA1dg4SEvGaqrNwqbCPjPmvV4HZzLwAdGKfBJUdBkXc+rA@mail.gmail.com"
      type="cite">
      <div dir="ltr">One issue with rbtree formatting is in some places
        if/while conditional expressions are put on the same line as the
        conditional statement. We should prefer to put them explicitly
        on separate lines, since that is the prevailing style of score
        and I have added such a convention to our style wiki page.<br>
        <div class="gmail_extra"><br>
        </div>
      </div>
    </blockquote>
    You are right. That also helps statement coverage imply decision
    coverage. <br>
    <br>
    if ( X )   return -1<br>
    <br>
    is counted as executing for true and false.<br>
    <br>
    if ( X )<br>
      return -1<br>
    <br>
    must execute true and false to get statement coverage.<br>
    <br>
    Good catch.  This style has a reason. :)<br>
    <blockquote
cite="mid:CAC82fA1dg4SEvGaqrNwqbCPjPmvV4HZzLwAdGKfBJUdBkXc+rA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Mon, Jul 21, 2014 at 12:57 PM,
            Joel Sherrill <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:joel.sherrill@oarcorp.com" target="_blank">joel.sherrill@oarcorp.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">There
              could be something wrong here but I don't see it on a
              quick review.<br>
              <div class="HOEnZb">
                <div class="h5">On 7/21/2014 11:31 AM, Sebastian Huber
                  wrote:<br>
                  > ---<br>
                  >  cpukit/score/src/rbtree.c        |   7 +-<br>
                  >  cpukit/score/src/rbtreeextract.c | 152
                  +++++++++++++++++++++------------------<br>
                  >  cpukit/score/src/rbtreefind.c    |   7 +-<br>
                  >  cpukit/score/src/rbtreeinsert.c  |  69
                  ++++++++++--------<br>
                  >  cpukit/score/src/rbtreeiterate.c |  12 ++--<br>
                  >  cpukit/score/src/rbtreenext.c    |  13 ++--<br>
                  >  6 files changed, 143 insertions(+), 117
                  deletions(-)<br>
                  ><br>
                  > diff --git a/cpukit/score/src/rbtree.c
                  b/cpukit/score/src/rbtree.c<br>
                  > index 5e8520d..2138a81 100644<br>
                  > --- a/cpukit/score/src/rbtree.c<br>
                  > +++ b/cpukit/score/src/rbtree.c<br>
                  > @@ -31,17 +31,18 @@ void _RBTree_Initialize(<br>
                  >    bool            is_unique<br>
                  >  )<br>
                  >  {<br>
                  > -  size_t      count;<br>
                  > +  size_t       count;<br>
                  >    RBTree_Node *next;<br>
                  ><br>
                  >    /* TODO: Error message? */<br>
                  > -  if (!the_rbtree) return;<br>
                  > +  if ( !the_rbtree ) return;<br>
                </div>
              </div>
            </blockquote>
            <div>Like here.<br>
            </div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5">
                  ><br>
                  >    /* could do sanity checks here */<br>
                  >    _RBTree_Initialize_empty( the_rbtree );<br>
                  ><br>
                  >    count = number_nodes;<br>
                  > -  next  = starting_address;<br>
                  > +  next = starting_address;<br>
                  > +<br>
                  >    while ( count-- ) {<br>
                  >      _RBTree_Insert( the_rbtree, next, compare,
                  is_unique );<br>
                  >      next = (RBTree_Node *)
                  _Addresses_Add_offset( next, node_size );<br>
                  > diff --git a/cpukit/score/src/rbtreeextract.c
                  b/cpukit/score/src/rbtreeextract.c<br>
                  > index 9e87868..2638f63 100644<br>
                  > --- a/cpukit/score/src/rbtreeextract.c<br>
                  > +++ b/cpukit/score/src/rbtreeextract.c<br>
                  > @@ -21,45 +21,45 @@<br>
                  >   *  @note It does NOT disable interrupts to
                  ensure the atomicity<br>
                  >   *        of the extract operation.<br>
                  >   */<br>
                  > -static void _RBTree_Extract_validate(<br>
                  > -    RBTree_Node *the_node<br>
                  > -    )<br>
                  > +static void _RBTree_Extract_validate(
                  RBTree_Node *the_node )<br>
                  >  {<br>
                  > -  RBTree_Node *parent, *sibling;<br>
                  > +  RBTree_Node     *parent, *sibling;<br>
                  >    RBTree_Direction dir;<br>
                  ><br>
                  >    parent = the_node->parent;<br>
                  > -  if(!parent->parent) return;<br>
                  ><br>
                  > -  sibling = _RBTree_Sibling(the_node);<br>
                  > +  if ( !parent->parent ) return;<br>
                  ><br>
                  > -  /* continue to correct tree as long as
                  the_node is black and not the root */<br>
                  > -  while (!_RBTree_Is_red(the_node) &&
                  parent->parent) {<br>
                  > +  sibling = _RBTree_Sibling( the_node );<br>
                  ><br>
                  > +  /* continue to correct tree as long as
                  the_node is black and not the root */<br>
                  > +  while ( !_RBTree_Is_red( the_node ) &&
                  parent->parent ) {<br>
                  >      /* if sibling is red, switch parent (black)
                  and sibling colors,<br>
                  >       * then rotate parent left, making the
                  sibling be the_node's grandparent.<br>
                  >       * Now the_node has a black sibling and red
                  parent. After rotation,<br>
                  >       * update sibling pointer.<br>
                  >       */<br>
                  > -    if (_RBTree_Is_red(sibling)) {<br>
                  > +    if ( _RBTree_Is_red( sibling ) ) {<br>
                  >        parent->color = RBT_RED;<br>
                  >        sibling->color = RBT_BLACK;<br>
                  > -      dir = the_node != parent->child[0];<br>
                  > -      _RBTree_Rotate(parent, dir);<br>
                  > -      sibling =
                  parent->child[_RBTree_Opposite_direction(dir)];<br>
                  > +      dir = the_node != parent->child[ 0 ];<br>
                  > +      _RBTree_Rotate( parent, dir );<br>
                  > +      sibling = parent->child[
                  _RBTree_Opposite_direction( dir ) ];<br>
                  >      }<br>
                  ><br>
                  >      /* sibling is black, see if both of its
                  children are also black. */<br>
                  > -    if
                  (!_RBTree_Is_red(sibling->child[RBT_RIGHT])
                  &&<br>
                  > -      
                   !_RBTree_Is_red(sibling->child[RBT_LEFT])) {<br>
                  > -        sibling->color = RBT_RED;<br>
                  > -        if (_RBTree_Is_red(parent)) {<br>
                  > -          parent->color = RBT_BLACK;<br>
                  > -          break;<br>
                  > -        }<br>
                  > -        the_node = parent; /* done if parent is
                  red */<br>
                  > -        parent = the_node->parent;<br>
                  > -        sibling = _RBTree_Sibling(the_node);<br>
                  > +    if ( !_RBTree_Is_red( sibling->child[
                  RBT_RIGHT ] ) &&<br>
                  > +         !_RBTree_Is_red( sibling->child[
                  RBT_LEFT ] ) ) {<br>
                  > +      sibling->color = RBT_RED;<br>
                  > +<br>
                  > +      if ( _RBTree_Is_red( parent ) ) {<br>
                  > +        parent->color = RBT_BLACK;<br>
                  > +        break;<br>
                  > +      }<br>
                  > +<br>
                  > +      the_node = parent;   /* done if parent is
                  red */<br>
                  > +      parent = the_node->parent;<br>
                  > +      sibling = _RBTree_Sibling( the_node );<br>
                  >      } else {<br>
                  >        /* at least one of sibling's children is
                  red. we now proceed in two<br>
                  >         * cases, either the_node is to the left
                  or the right of the parent.<br>
                  > @@ -67,21 +67,27 @@ static void
                  _RBTree_Extract_validate(<br>
                  >         * and if so rotate in the proper
                  direction and update sibling pointer.<br>
                  >         * Then switch the sibling and parent
                  colors, and rotate through parent.<br>
                  >         */<br>
                  > -      dir = the_node != parent->child[0];<br>
                  > -      if
                  (!_RBTree_Is_red(sibling->child[_RBTree_Opposite_direction(dir)]))
                  {<br>
                  > +      dir = the_node != parent->child[ 0 ];<br>
                  > +<br>
                  > +      if (<br>
                  > +        !_RBTree_Is_red( sibling->child[
                  _RBTree_Opposite_direction( dir ) ] )<br>
                  > +      ) {<br>
                  >          sibling->color = RBT_RED;<br>
                  > -        sibling->child[dir]->color =
                  RBT_BLACK;<br>
                  > -        _RBTree_Rotate(sibling,
                  _RBTree_Opposite_direction(dir));<br>
                  > -        sibling =
                  parent->child[_RBTree_Opposite_direction(dir)];<br>
                  > +        sibling->child[ dir ]->color =
                  RBT_BLACK;<br>
                  > +        _RBTree_Rotate( sibling,
                  _RBTree_Opposite_direction( dir ) );<br>
                  > +        sibling = parent->child[
                  _RBTree_Opposite_direction( dir ) ];<br>
                  >        }<br>
                  > +<br>
                  >        sibling->color = parent->color;<br>
                  >        parent->color = RBT_BLACK;<br>
                  > -    
                   sibling->child[_RBTree_Opposite_direction(dir)]->color
                  = RBT_BLACK;<br>
                  > -      _RBTree_Rotate(parent, dir);<br>
                  > +      sibling->child[
                  _RBTree_Opposite_direction( dir ) ]->color =
                  RBT_BLACK;<br>
                  > +      _RBTree_Rotate( parent, dir );<br>
                  >        break; /* done */<br>
                  >      }<br>
                  >    } /* while */<br>
                  > -  if(!the_node->parent->parent)
                  the_node->color = RBT_BLACK;<br>
                  > +<br>
                  > +  if ( !the_node->parent->parent )<br>
                  > +    the_node->color = RBT_BLACK;<br>
                  >  }<br>
                  ><br>
                  >  /** @brief Extract a Node (unprotected)<br>
                  > @@ -92,29 +98,29 @@ static void
                  _RBTree_Extract_validate(<br>
                  >   *        of the extract operation.<br>
                  >   */<br>
                  >  void _RBTree_Extract(<br>
                  > -    RBTree_Control *the_rbtree,<br>
                  > -    RBTree_Node *the_node<br>
                  > -    )<br>
                  > +  RBTree_Control *the_rbtree,<br>
                  > +  RBTree_Node    *the_node<br>
                  > +)<br>
                  >  {<br>
                  > -  RBTree_Node *leaf, *target;<br>
                  > -  RBTree_Color victim_color;<br>
                  > +  RBTree_Node     *leaf, *target;<br>
                  > +  RBTree_Color     victim_color;<br>
                  >    RBTree_Direction dir;<br>
                  ><br>
                  > -  if (!the_node) return;<br>
                  > +  if ( !the_node ) return;<br>
                  ><br>
                  >    /* check if min needs to be updated */<br>
                  > -  if (the_node ==
                  the_rbtree->first[RBT_LEFT]) {<br>
                  > +  if ( the_node == the_rbtree->first[
                  RBT_LEFT ] ) {<br>
                  >      RBTree_Node *next;<br>
                  > -    next = _RBTree_Successor(the_node);<br>
                  > -    the_rbtree->first[RBT_LEFT] = next;<br>
                  > +    next = _RBTree_Successor( the_node );<br>
                  > +    the_rbtree->first[ RBT_LEFT ] = next;<br>
                  >    }<br>
                  ><br>
                  >    /* Check if max needs to be updated. min=max
                  for 1 element trees so<br>
                  >     * do not use else if here. */<br>
                  > -  if (the_node ==
                  the_rbtree->first[RBT_RIGHT]) {<br>
                  > +  if ( the_node == the_rbtree->first[
                  RBT_RIGHT ] ) {<br>
                  >      RBTree_Node *previous;<br>
                  > -    previous = _RBTree_Predecessor(the_node);<br>
                  > -    the_rbtree->first[RBT_RIGHT] = previous;<br>
                  > +    previous = _RBTree_Predecessor( the_node );<br>
                  > +    the_rbtree->first[ RBT_RIGHT ] =
                  previous;<br>
                  >    }<br>
                  ><br>
                  >    /* if the_node has at most one non-null child
                  then it is safe to proceed<br>
                  > @@ -124,9 +130,11 @@ void _RBTree_Extract(<br>
                  >     * search tree property, but may violate the
                  red-black properties.<br>
                  >     */<br>
                  ><br>
                  > -  if (the_node->child[RBT_LEFT] &&
                  the_node->child[RBT_RIGHT]) {<br>
                  > -    target = the_node->child[RBT_LEFT]; /*
                  find max in node->child[RBT_LEFT] */<br>
                  > -    while (target->child[RBT_RIGHT]) target =
                  target->child[RBT_RIGHT];<br>
                  > +  if ( the_node->child[ RBT_LEFT ] &&
                  the_node->child[ RBT_RIGHT ] ) {<br>
                  > +    target = the_node->child[ RBT_LEFT ]; /*
                  find max in node->child[RBT_LEFT] */<br>
                  > +<br>
                  > +    while ( target->child[ RBT_RIGHT ] )<br>
                  > +      target = target->child[ RBT_RIGHT ];<br>
                  ><br>
                  >      /* if the target node has a child, need to
                  move it up the tree into<br>
                  >       * target's position (target is the right
                  child of target->parent)<br>
                  > @@ -134,28 +142,33 @@ void _RBTree_Extract(<br>
                  >       * should become NULL. This may cause the
                  coloring to be violated.<br>
                  >       * For now we store the color of the node
                  being deleted in victim_color.<br>
                  >       */<br>
                  > -    leaf = target->child[RBT_LEFT];<br>
                  > -    if(leaf) {<br>
                  > +    leaf = target->child[ RBT_LEFT ];<br>
                  > +<br>
                  > +    if ( leaf ) {<br>
                  >        leaf->parent = target->parent;<br>
                  >      } else {<br>
                  >        /* fix the tree here if the child is a
                  null leaf. */<br>
                  > -      _RBTree_Extract_validate(target);<br>
                  > +      _RBTree_Extract_validate( target );<br>
                  >      }<br>
                  > +<br>
                  >      victim_color = target->color;<br>
                  > -    dir = target !=
                  target->parent->child[0];<br>
                  > -    target->parent->child[dir] = leaf;<br>
                  > +    dir = target != target->parent->child[
                  0 ];<br>
                  > +    target->parent->child[ dir ] = leaf;<br>
                  ><br>
                  >      /* now replace the_node with target */<br>
                  > -    dir = the_node !=
                  the_node->parent->child[0];<br>
                  > -    the_node->parent->child[dir] = target;<br>
                  > +    dir = the_node !=
                  the_node->parent->child[ 0 ];<br>
                  > +    the_node->parent->child[ dir ] =
                  target;<br>
                  ><br>
                  >      /* set target's new children to the original
                  node's children */<br>
                  > -    target->child[RBT_RIGHT] =
                  the_node->child[RBT_RIGHT];<br>
                  > -    if (the_node->child[RBT_RIGHT])<br>
                  > -      the_node->child[RBT_RIGHT]->parent =
                  target;<br>
                  > -    target->child[RBT_LEFT] =
                  the_node->child[RBT_LEFT];<br>
                  > -    if (the_node->child[RBT_LEFT])<br>
                  > -      the_node->child[RBT_LEFT]->parent =
                  target;<br>
                  > +    target->child[ RBT_RIGHT ] =
                  the_node->child[ RBT_RIGHT ];<br>
                  > +<br>
                  > +    if ( the_node->child[ RBT_RIGHT ] )<br>
                  > +      the_node->child[ RBT_RIGHT ]->parent
                  = target;<br>
                  > +<br>
                  > +    target->child[ RBT_LEFT ] =
                  the_node->child[ RBT_LEFT ];<br>
                  > +<br>
                  > +    if ( the_node->child[ RBT_LEFT ] )<br>
                  > +      the_node->child[ RBT_LEFT ]->parent
                  = target;<br>
                  ><br>
                  >      /* finally, update the parent node and
                  recolor. target has completely<br>
                  >       * replaced the_node, and target's child has
                  moved up the tree if needed.<br>
                  > @@ -170,19 +183,21 @@ void _RBTree_Extract(<br>
                  >       * violated. We will fix it later.<br>
                  >       * For now we store the color of the node
                  being deleted in victim_color.<br>
                  >       */<br>
                  > -    leaf = the_node->child[RBT_LEFT] ?<br>
                  > -              the_node->child[RBT_LEFT] :
                  the_node->child[RBT_RIGHT];<br>
                  > -    if( leaf ) {<br>
                  > +    leaf = the_node->child[ RBT_LEFT ] ?<br>
                  > +           the_node->child[ RBT_LEFT ] :
                  the_node->child[ RBT_RIGHT ];<br>
                  > +<br>
                  > +    if ( leaf ) {<br>
                  >        leaf->parent = the_node->parent;<br>
                  >      } else {<br>
                  >        /* fix the tree here if the child is a
                  null leaf. */<br>
                  > -      _RBTree_Extract_validate(the_node);<br>
                  > +      _RBTree_Extract_validate( the_node );<br>
                  >      }<br>
                  > +<br>
                  >      victim_color = the_node->color;<br>
                  ><br>
                  >      /* remove the_node from the tree */<br>
                  > -    dir = the_node !=
                  the_node->parent->child[0];<br>
                  > -    the_node->parent->child[dir] = leaf;<br>
                  > +    dir = the_node !=
                  the_node->parent->child[ 0 ];<br>
                  > +    the_node->parent->child[ dir ] = leaf;<br>
                  >    }<br>
                  ><br>
                  >    /* fix coloring. leaf has moved up the tree.
                  The color of the deleted<br>
                  > @@ -190,15 +205,16 @@ void _RBTree_Extract(<br>
                  >     *   1. Deleted a red node, its child must be
                  black. Nothing must be done.<br>
                  >     *   2. Deleted a black node, its child must
                  be red. Paint child black.<br>
                  >     */<br>
                  > -  if (victim_color == RBT_BLACK) { /* eliminate
                  case 1 */<br>
                  > -    if (leaf) {<br>
                  > +  if ( victim_color == RBT_BLACK ) { /*
                  eliminate case 1 */<br>
                  > +    if ( leaf ) {<br>
                  >        leaf->color = RBT_BLACK; /* case 2 */<br>
                  >      }<br>
                  >    }<br>
                  ><br>
                  >    /* Wipe the_node */<br>
                  > -  _RBTree_Set_off_rbtree(the_node);<br>
                  > +  _RBTree_Set_off_rbtree( the_node );<br>
                  ><br>
                  >    /* set root to black, if it exists */<br>
                  > -  if (the_rbtree->root)
                  the_rbtree->root->color = RBT_BLACK;<br>
                  > +  if ( the_rbtree->root )<br>
                  > +    the_rbtree->root->color = RBT_BLACK;<br>
                  >  }<br>
                  > diff --git a/cpukit/score/src/rbtreefind.c
                  b/cpukit/score/src/rbtreefind.c<br>
                  > index ad0c9fd..f767626 100644<br>
                  > --- a/cpukit/score/src/rbtreefind.c<br>
                  > +++ b/cpukit/score/src/rbtreefind.c<br>
                  > @@ -26,15 +26,16 @@ RBTree_Node *_RBTree_Find(<br>
                  >    bool                  is_unique<br>
                  >  )<br>
                  >  {<br>
                  > -  RBTree_Node* iter_node = the_rbtree->root;<br>
                  > -  RBTree_Node* found = NULL;<br>
                  > +  RBTree_Node *iter_node = the_rbtree->root;<br>
                  > +  RBTree_Node *found = NULL;<br>
                  ><br>
                  >    while ( iter_node != NULL ) {<br>
                  > -    int compare_result = ( *compare )( the_node,
                  iter_node );<br>
                  > +    int              compare_result = ( *compare
                  )( the_node, iter_node );<br>
                  >      RBTree_Direction dir;<br>
                  ><br>
                  >      if ( _RBTree_Is_equal( compare_result ) ) {<br>
                  >        found = iter_node;<br>
                  > +<br>
                  >        if ( is_unique )<br>
                  >          break;<br>
                  >      }<br>
                  > diff --git a/cpukit/score/src/rbtreeinsert.c
                  b/cpukit/score/src/rbtreeinsert.c<br>
                  > index 7174529..369ef26 100644<br>
                  > --- a/cpukit/score/src/rbtreeinsert.c<br>
                  > +++ b/cpukit/score/src/rbtreeinsert.c<br>
                  > @@ -21,42 +21,43 @@<br>
                  >   *  @note It does NOT disable interrupts to
                  ensure the atomicity of the<br>
                  >   *        append operation.<br>
                  >   */<br>
                  > -static void _RBTree_Validate_insert(<br>
                  > -    RBTree_Node    *the_node<br>
                  > -    )<br>
                  > +static void _RBTree_Validate_insert( RBTree_Node
                  *the_node )<br>
                  >  {<br>
                  > -  RBTree_Node *u,*g;<br>
                  > +  RBTree_Node *u, *g;<br>
                  ><br>
                  >    /* note: the insert root case is handled
                  already */<br>
                  >    /* if the parent is black, nothing needs to be
                  done<br>
                  >     * otherwise may need to loop a few times */<br>
                  > -  while
                  (_RBTree_Is_red(_RBTree_Parent(the_node))) {<br>
                  > -    u = _RBTree_Parent_sibling(the_node);<br>
                  > +  while ( _RBTree_Is_red( _RBTree_Parent(
                  the_node ) ) ) {<br>
                  > +    u = _RBTree_Parent_sibling( the_node );<br>
                  >      g = the_node->parent->parent;<br>
                  ><br>
                  >      /* if uncle is red, repaint uncle/parent
                  black and grandparent red */<br>
                  > -    if(_RBTree_Is_red(u)) {<br>
                  > +    if ( _RBTree_Is_red( u ) ) {<br>
                  >        the_node->parent->color = RBT_BLACK;<br>
                  >        u->color = RBT_BLACK;<br>
                  >        g->color = RBT_RED;<br>
                  >        the_node = g;<br>
                  >      } else { /* if uncle is black */<br>
                  > -      RBTree_Direction dir = the_node !=
                  the_node->parent->child[0];<br>
                  > -      RBTree_Direction pdir =
                  the_node->parent != g->child[0];<br>
                  > +      RBTree_Direction dir = the_node !=
                  the_node->parent->child[ 0 ];<br>
                  > +      RBTree_Direction pdir =
                  the_node->parent != g->child[ 0 ];<br>
                  ><br>
                  >        /* ensure node is on the same branch
                  direction as parent */<br>
                  > -      if (dir != pdir) {<br>
                  > -        _RBTree_Rotate(the_node->parent,
                  pdir);<br>
                  > -        the_node = the_node->child[pdir];<br>
                  > +      if ( dir != pdir ) {<br>
                  > +        _RBTree_Rotate( the_node->parent,
                  pdir );<br>
                  > +        the_node = the_node->child[ pdir ];<br>
                  >        }<br>
                  > +<br>
                  >        the_node->parent->color = RBT_BLACK;<br>
                  >        g->color = RBT_RED;<br>
                  ><br>
                  >        /* now rotate grandparent in the other
                  branch direction (toward uncle) */<br>
                  > -      _RBTree_Rotate(g, (1-pdir));<br>
                  > +      _RBTree_Rotate( g, ( 1 - pdir ) );<br>
                  >      }<br>
                  >    }<br>
                  > -  if(!the_node->parent->parent)
                  the_node->color = RBT_BLACK;<br>
                  > +<br>
                  > +  if ( !the_node->parent->parent )<br>
                  > +    the_node->color = RBT_BLACK;<br>
                  >  }<br>
                  ><br>
                  >  RBTree_Node *_RBTree_Insert(<br>
                  > @@ -66,47 +67,53 @@ RBTree_Node *_RBTree_Insert(<br>
                  >    bool            is_unique<br>
                  >  )<br>
                  >  {<br>
                  > -  if(!the_node) return (RBTree_Node*)-1;<br>
                  > +  if ( !the_node ) return (RBTree_Node *) -1;<br>
                  ><br>
                  >    RBTree_Node *iter_node = the_rbtree->root;<br>
                  > -  int compare_result;<br>
                  ><br>
                  > -  if (!iter_node) { /* special case: first node
                  inserted */<br>
                  > +  if ( !iter_node ) { /* special case: first
                  node inserted */<br>
                  >      the_node->color = RBT_BLACK;<br>
                  >      the_rbtree->root = the_node;<br>
                  > -    the_rbtree->first[0] =
                  the_rbtree->first[1] = the_node;<br>
                  > +    the_rbtree->first[ 0 ] =
                  the_rbtree->first[ 1 ] = the_node;<br>
                  >      the_node->parent = (RBTree_Node *)
                  the_rbtree;<br>
                  > -    the_node->child[RBT_LEFT] =
                  the_node->child[RBT_RIGHT] = NULL;<br>
                  > +    the_node->child[ RBT_LEFT ] =
                  the_node->child[ RBT_RIGHT ] = NULL;<br>
                  >    } else {<br>
                  >      /* typical binary search tree insert,
                  descend tree to leaf and insert */<br>
                  > -    while (iter_node) {<br>
                  > -      compare_result = ( *compare )( the_node,
                  iter_node );<br>
                  > +    while ( iter_node ) {<br>
                  > +      int compare_result = ( *compare )(
                  the_node, iter_node );<br>
                  > +<br>
                  >        if ( is_unique &&
                  _RBTree_Is_equal( compare_result ) )<br>
                  >          return iter_node;<br>
                  > +<br>
                  >        RBTree_Direction dir = !_RBTree_Is_lesser(
                  compare_result );<br>
                  > -      if (!iter_node->child[dir]) {<br>
                  > -        the_node->child[RBT_LEFT] =
                  the_node->child[RBT_RIGHT] = NULL;<br>
                  > +<br>
                  > +      if ( !iter_node->child[ dir ] ) {<br>
                  > +        the_node->child[ RBT_LEFT ] =
                  the_node->child[ RBT_RIGHT ] = NULL;<br>
                  >          the_node->color = RBT_RED;<br>
                  > -        iter_node->child[dir] = the_node;<br>
                  > +        iter_node->child[ dir ] = the_node;<br>
                  >          the_node->parent = iter_node;<br>
                  >          /* update min/max */<br>
                  >          compare_result = ( *compare )(<br>
                  >            the_node,<br>
                  >            _RBTree_First( the_rbtree, dir )<br>
                  >          );<br>
                  > -        if ( (!dir &&
                  _RBTree_Is_lesser(compare_result)) ||<br>
                  > -              (dir &&
                  _RBTree_Is_greater(compare_result)) ) {<br>
                  > -          the_rbtree->first[dir] = the_node;<br>
                  > +<br>
                  > +        if (<br>
                  > +          ( !dir && _RBTree_Is_lesser(
                  compare_result ) )<br>
                  > +            || ( dir &&
                  _RBTree_Is_greater( compare_result ) )<br>
                  > +        ) {<br>
                  > +          the_rbtree->first[ dir ] =
                  the_node;<br>
                  >          }<br>
                  > +<br>
                  >          break;<br>
                  >        } else {<br>
                  > -        iter_node = iter_node->child[dir];<br>
                  > +        iter_node = iter_node->child[ dir ];<br>
                  >        }<br>
                  > -<br>
                  >      } /* while(iter_node) */<br>
                  ><br>
                  >      /* verify red-black properties */<br>
                  > -    _RBTree_Validate_insert(the_node);<br>
                  > +    _RBTree_Validate_insert( the_node );<br>
                  >    }<br>
                  > -  return (RBTree_Node*)0;<br>
                  > +<br>
                  > +  return (RBTree_Node *) 0;<br>
                  >  }<br>
                  > diff --git a/cpukit/score/src/rbtreeiterate.c
                  b/cpukit/score/src/rbtreeiterate.c<br>
                  > index f325567..8b5da1e 100644<br>
                  > --- a/cpukit/score/src/rbtreeiterate.c<br>
                  > +++ b/cpukit/score/src/rbtreeiterate.c<br>
                  > @@ -28,17 +28,17 @@<br>
                  ><br>
                  >  void _RBTree_Iterate(<br>
                  >    const RBTree_Control *rbtree,<br>
                  > -  RBTree_Direction dir,<br>
                  > -  RBTree_Visitor visitor,<br>
                  > -  void *visitor_arg<br>
                  > +  RBTree_Direction      dir,<br>
                  > +  RBTree_Visitor        visitor,<br>
                  > +  void                 *visitor_arg<br>
                  >  )<br>
                  >  {<br>
                  > -  RBTree_Direction opp_dir =
                  _RBTree_Opposite_direction( dir );<br>
                  > +  RBTree_Direction   opp_dir =
                  _RBTree_Opposite_direction( dir );<br>
                  >    const RBTree_Node *current = _RBTree_First(
                  rbtree, opp_dir );<br>
                  > -  bool stop = false;<br>
                  > +  bool               stop = false;<br>
                  ><br>
                  >    while ( !stop && current != NULL ) {<br>
                  > -    stop = (*visitor)( current, dir, visitor_arg
                  );<br>
                  > +    stop = ( *visitor )( current, dir,
                  visitor_arg );<br>
                  ><br>
                  >      current = _RBTree_Next( current, dir );<br>
                  >    }<br>
                  > diff --git a/cpukit/score/src/rbtreenext.c
                  b/cpukit/score/src/rbtreenext.c<br>
                  > index fde0bc6..2128ae5 100644<br>
                  > --- a/cpukit/score/src/rbtreenext.c<br>
                  > +++ b/cpukit/score/src/rbtreenext.c<br>
                  > @@ -29,25 +29,26 @@<br>
                  ><br>
                  >  RBTree_Node *_RBTree_Next(<br>
                  >    const RBTree_Node *node,<br>
                  > -  RBTree_Direction dir<br>
                  > +  RBTree_Direction   dir<br>
                  >  )<br>
                  >  {<br>
                  >    RBTree_Direction opp_dir =
                  _RBTree_Opposite_direction( dir );<br>
                  > -  RBTree_Node *current = node->child [dir];<br>
                  > -  RBTree_Node *next = NULL;<br>
                  > +  RBTree_Node     *current = node->child[ dir
                  ];<br>
                  > +  RBTree_Node     *next = NULL;<br>
                  ><br>
                  >    if ( current != NULL ) {<br>
                  >      next = current;<br>
                  > -    while ( (current = current->child
                  [opp_dir]) != NULL ) {<br>
                  > +<br>
                  > +    while ( ( current = current->child[
                  opp_dir ] ) != NULL ) {<br>
                  >        next = current;<br>
                  >      }<br>
                  >    } else {<br>
                  >      RBTree_Node *parent = node->parent;<br>
                  ><br>
                  > -    if ( parent->parent && node ==
                  parent->child [opp_dir] ) {<br>
                  > +    if ( parent->parent && node ==
                  parent->child[ opp_dir ] ) {<br>
                  >        next = parent;<br>
                  >      } else {<br>
                  > -      while ( parent->parent && node
                  == parent->child [dir] ) {<br>
                  > +      while ( parent->parent && node
                  == parent->child[ dir ] ) {<br>
                  >          node = parent;<br>
                  >          parent = parent->parent;<br>
                  >        }<br>
                  > --<br>
                  > 1.8.1.4<br>
                  ><br>
                  > _______________________________________________<br>
                  > devel mailing list<br>
                  > <a moz-do-not-send="true"
                    href="mailto:devel@rtems.org">devel@rtems.org</a><br>
                  > <a moz-do-not-send="true"
                    href="http://lists.rtems.org/mailman/listinfo/devel"
                    target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
                  <br>
                </div>
              </div>
              <span class="HOEnZb"><font color="#888888">--<br>
                  Joel Sherrill, Ph.D.             Director of Research
                  & Development<br>
                  <a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications
                  Research<br>
                  Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br>
                  Support Available                <a
                    moz-do-not-send="true"
                    href="tel:%28256%29%20722-9985" value="+12567229985">(256)
                    722-9985</a><br>
                </font></span>
              <div class="HOEnZb">
                <div class="h5"><br>
                  _______________________________________________<br>
                  devel mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:devel@rtems.org">devel@rtems.org</a><br>
                  <a moz-do-not-send="true"
                    href="http://lists.rtems.org/mailman/listinfo/devel"
                    target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Joel Sherrill, Ph.D.             Director of Research & Development
<a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985</pre>
  </body>
</html>