Changeset 2d2dcab2 in rtems


Ignore:
Timestamp:
Jan 19, 2010, 7:33:08 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 5, master
Children:
b2ac8a9
Parents:
cb4e992
Message:

2010-01-19 Joel Sherrill <joel.sherrill@…>

Coverity Id 5

  • score/src/objectinitializeinformation.c: Do not modify maximum parameter. Clean up and simplify code. This should help the Coverity path analysis to avoid reporting issues.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rcb4e992 r2d2dcab2  
     12010-01-19      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        Coverity Id 5
     4        * score/src/objectinitializeinformation.c: Do not modify maximum
     5        parameter. Clean up and simplify code. This should help the Coverity
     6        path analysis to avoid reporting issues.
     7
    182010-01-19      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • cpukit/score/src/objectinitializeinformation.c

    rcb4e992 r2d2dcab2  
    11/*
    2  *  Object Handler
     2 *  Object Handler Initialization per Object Class
    33 *
    4  *
    5  *  COPYRIGHT (c) 1989-1999.
     4 *  COPYRIGHT (c) 1989-2010.
    65 *  On-Line Applications Research Corporation (OAR).
    76 *
     
    6665  uint32_t                minimum_index;
    6766  uint32_t                name_length;
    68 #if defined(RTEMS_MULTIPROCESSING)
    69   uint32_t                index;
    70 #endif
     67  uint32_t                maximum_per_allocation;
     68  #if defined(RTEMS_MULTIPROCESSING)
     69    uint32_t              index;
     70  #endif
    7171
    7272  information->the_api            = the_api;
    7373  information->the_class          = the_class;
    74 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    75   information->is_string          = is_string;
    76 #endif
    77 
     74  information->size               = size;
    7875  information->local_table        = 0;
    7976  information->inactive_per_block = 0;
    8077  information->object_blocks      = 0;
    81 
    8278  information->inactive           = 0;
     79  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
     80    information->is_string        = is_string;
     81  #endif
    8382
    8483  /*
    85    *  Set the entry in the object information table.
     84   *  Set the maximum value to 0. It will be updated when objects are
     85   *  added to the inactive set from _Objects_Extend_information()
    8686   */
     87  information->maximum = 0;
    8788
     89  /*
     90   *  Register this Object Class in the Object Information Table.
     91   */
    8892  _Objects_Information_table[ the_api ][ the_class ] = information;
    8993
    9094  /*
    91    *  Set the size of the object
     95   *  Are we operating in limited or unlimited (e.g. auto-extend) mode.
    9296   */
    93 
    94   information->size = size;
    95 
    96   /*
    97    *  Are we operating in unlimited, or auto-extend mode
    98    */
    99 
    10097  information->auto_extend =
    10198        (maximum & OBJECTS_UNLIMITED_OBJECTS) ? true : false;
    102   maximum                 &= ~OBJECTS_UNLIMITED_OBJECTS;
     99  maximum_per_allocation = maximum & ~OBJECTS_UNLIMITED_OBJECTS;
    103100
    104101  /*
    105102   *  The allocation unit is the maximum value
    106103   */
    107 
    108   information->allocation_size = maximum;
     104  information->allocation_size = maximum_per_allocation;
    109105
    110106  /*
    111107   *  Provide a null local table entry for the case of any empty table.
    112108   */
    113 
    114109  information->local_table = &null_local_table;
    115110
     
    117112   *  Calculate minimum and maximum Id's
    118113   */
    119 
    120   if ( maximum == 0 ) minimum_index = 0;
    121   else                minimum_index = 1;
    122 
     114  minimum_index = (maximum_per_allocation == 0) ? 0 : 1;
    123115  information->minimum_id =
    124116    _Objects_Build_id( the_api, the_class, _Objects_Local_node, minimum_index );
     
    127119   *  Calculate the maximum name length
    128120   */
    129 
    130121  name_length = maximum_name_length;
    131122
     
    141132   *  Initialize objects .. if there are any
    142133   */
    143 
    144   if ( maximum ) {
    145 
    146     /*
    147      *  Reset the maximum value. It will be updated when the information is
    148      *  extended.
    149      */
    150 
    151     information->maximum = 0;
    152 
     134  if ( maximum_per_allocation ) {
    153135    /*
    154136     *  Always have the maximum size available so the current performance
     
    156138     *  number then a performance hit is taken.
    157139     */
    158 
    159140    _Objects_Extend_information( information );
    160 
    161141  }
    162142
     
    164144   *  Take care of multiprocessing
    165145   */
     146  #if defined(RTEMS_MULTIPROCESSING)
     147    information->extract = extract;
    166148
    167 #if defined(RTEMS_MULTIPROCESSING)
    168   information->extract = extract;
     149    if ( (supports_global == true) && _System_state_Is_multiprocessing ) {
    169150
    170   if ( (supports_global == true) && _System_state_Is_multiprocessing ) {
     151      information->global_table =
     152        (Chain_Control *) _Workspace_Allocate_or_fatal_error(
     153          (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control)
     154        );
    171155
    172     information->global_table =
    173       (Chain_Control *) _Workspace_Allocate_or_fatal_error(
    174         (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control)
    175       );
    176 
    177     for ( index=1; index <= _Objects_Maximum_nodes ; index++ )
    178       _Chain_Initialize_empty( &information->global_table[ index ] );
    179    }
    180    else
    181      information->global_table = NULL;
    182 #endif
     156      for ( index=1; index <= _Objects_Maximum_nodes ; index++ )
     157        _Chain_Initialize_empty( &information->global_table[ index ] );
     158     }
     159     else
     160       information->global_table = NULL;
     161  #endif
    183162}
Note: See TracChangeset for help on using the changeset viewer.