Changeset d7a94693 in rtems


Ignore:
Timestamp:
07/21/14 16:16:47 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
8abbbdde
Parents:
6b0a7efc
git-author:
Sebastian Huber <sebastian.huber@…> (07/21/14 16:16:47)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/22/14 10:31:39)
Message:

rbtree: Remove superfluous NULL pointer checks

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/rbtree.h

    r6b0a7efc rd7a94693  
    230230 *   otherwise.
    231231 *
    232  *  @retval 0 Successfully inserted.
    233  *  @retval -1 NULL @a the_node.
    234  *  @retval RBTree_Node* if one with equal value to @a the_node 's key exists
    235  *          in an unique @a the_rbtree.
     232 * @retval NULL Successfully inserted.
     233 * @retval existing_node This is a unique insert and there exists a node with
     234 *   an equal key in the tree already.
    236235 */
    237236RBTree_Node *_RBTree_Insert(
     
    482481
    483482/**
    484  * @brief Get the first node.
    485  *
    486  * This function removes the minimum or maximum node from the_rbtree and
    487  * returns a pointer to that node.
    488  *
    489  * @param[in] the_rbtree is the rbtree to attempt to get the min node from.
    490  * @param[in] dir specifies whether to get minimum (0) or maximum (1)
    491  *
    492  * @return This method returns the min or max node on the rbtree, or NULL.
    493  *
    494  * @note This routine may return NULL if the RBTree is empty.
     483 * @brief Gets a node with an extremal key value.
     484 *
     485 * This function extracts a node with the minimum or maximum key value from
     486 * tree and returns a pointer to that node if it exists.  In case multiple
     487 * nodes with an extremal key value exist, then they are extracted in FIFO
     488 * order.
     489 *
     490 * @param[in] the_rbtree The red-black tree control.
     491 * @param[in] dir Specifies whether to get a node with the minimum (RBT_LEFT)
     492 *   or maximum (RBT_RIGHT) key value.
     493 *
     494 * @retval NULL The tree is empty.
     495 * @retval extremal_node A node with the minimal or maximal key value on the
     496 *   tree.
    495497 */
    496498RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Get(
    497     RBTree_Control *the_rbtree,
    498     RBTree_Direction dir
    499     )
    500 {
    501   RBTree_Node *the_node = the_rbtree->first[dir];
    502   _RBTree_Extract(the_rbtree, the_node);
     499  RBTree_Control *the_rbtree,
     500  RBTree_Direction dir
     501)
     502{
     503  RBTree_Node *the_node = the_rbtree->first[ dir ];
     504
     505  if ( the_node != NULL ) {
     506    _RBTree_Extract( the_rbtree, the_node );
     507  }
     508
    503509  return the_node;
    504510}
  • cpukit/score/src/rbtree.c

    r6b0a7efc rd7a94693  
    3535  RBTree_Node *next;
    3636
    37   /* TODO: Error message? */
    38   if ( !the_rbtree )
    39     return;
    40 
    4137  /* could do sanity checks here */
    4238  _RBTree_Initialize_empty( the_rbtree );
  • cpukit/score/src/rbtreeextract.c

    r6b0a7efc rd7a94693  
    1212
    1313#include <rtems/score/rbtreeimpl.h>
    14 #include <rtems/score/isr.h>
    1514
    1615/** @brief  Validate and fix-up tree properties after deleting a node
     
    9291}
    9392
    94 /** @brief Extract a Node (unprotected)
    95  *
    96  *  This routine extracts (removes) @a the_node from @a the_rbtree.
    97  *
    98  *  @note It does NOT disable interrupts to ensure the atomicity
    99  *        of the extract operation.
    100  */
    10193void _RBTree_Extract(
    10294  RBTree_Control *the_rbtree,
     
    108100  RBTree_Direction dir;
    109101
    110   if ( !the_node )
    111     return;
    112 
    113102  /* check if min needs to be updated */
    114103  if ( the_node == the_rbtree->first[ RBT_LEFT ] ) {
  • cpukit/score/src/rbtreeinsert.c

    r6b0a7efc rd7a94693  
    1212
    1313#include <rtems/score/rbtreeimpl.h>
    14 #include <rtems/score/isr.h>
    1514
    1615/** @brief Validate and fix-up tree properties for a new insert/colored node
     
    6867)
    6968{
    70   if ( !the_node )
    71     return (RBTree_Node *) -1;
    72 
    7369  RBTree_Node *iter_node = the_rbtree->root;
    7470
  • testsuites/sptests/sprbtree01/init.c

    r6b0a7efc rd7a94693  
    150150  rb_insert_unique( &rbtree1, &node2.Node );
    151151
    152   p = rb_insert_unique( &rbtree1, NULL );
    153   if (p != (void *)(-1))
    154     puts( "INIT - FAILED NULL NODE INSERT" );
    155152
    156153  _RBTree_Rotate(NULL, RBT_LEFT);
Note: See TracChangeset for help on using the changeset viewer.