2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>

Coverity Id 5
	* score/src/objectextendinformation.c: Check object_blocks for NULL to
	determine when to allocate object block table.
This commit is contained in:
Joel Sherrill
2010-01-20 17:08:19 +00:00
parent 59f7e9177a
commit f659921bd2
2 changed files with 10 additions and 15 deletions

View File

@@ -1,3 +1,9 @@
2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 5
* score/src/objectextendinformation.c: Check object_blocks for NULL to
determine when to allocate object block table.
2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com> 2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 27 Coverity Id 27

View File

@@ -61,12 +61,12 @@ void _Objects_Extend_information(
* Search for a free block of indexes. The block variable ends up set * Search for a free block of indexes. The block variable ends up set
* to block_count + 1 if the table needs to be extended. * to block_count + 1 if the table needs to be extended.
*/ */
minimum_index = _Objects_Get_index( information->minimum_id ); minimum_index = _Objects_Get_index( information->minimum_id );
index_base = minimum_index; index_base = minimum_index;
block = 0; block = 0;
if ( information->maximum < minimum_index ) /* if ( information->maximum < minimum_index ) */
if ( information->object_blocks == NULL )
block_count = 0; block_count = 0;
else { else {
block_count = information->maximum / information->allocation_size; block_count = information->maximum / information->allocation_size;
@@ -94,7 +94,6 @@ void _Objects_Extend_information(
* Allocate the name table, and the objects and if it fails either return or * Allocate the name table, and the objects and if it fails either return or
* generate a fatal error depending on auto-extending being active. * generate a fatal error depending on auto-extending being active.
*/ */
block_size = information->allocation_size * information->size; block_size = information->allocation_size * information->size;
if ( information->auto_extend ) { if ( information->auto_extend ) {
new_object_block = _Workspace_Allocate( block_size ); new_object_block = _Workspace_Allocate( block_size );
@@ -107,7 +106,6 @@ void _Objects_Extend_information(
/* /*
* If the index_base is the maximum we need to grow the tables. * If the index_base is the maximum we need to grow the tables.
*/ */
if (index_base >= information->maximum ) { if (index_base >= information->maximum ) {
ISR_Level level; ISR_Level level;
void **object_blocks; void **object_blocks;
@@ -136,13 +134,11 @@ void _Objects_Extend_information(
/* /*
* Up the block count and maximum * Up the block count and maximum
*/ */
block_count++; block_count++;
/* /*
* Allocate the tables and break it up. * Allocate the tables and break it up.
*/ */
block_size = block_count * block_size = block_count *
(sizeof(void *) + sizeof(uint32_t) + sizeof(Objects_Name *)) + (sizeof(void *) + sizeof(uint32_t) + sizeof(Objects_Name *)) +
((maximum + minimum_index) * sizeof(Objects_Control *)); ((maximum + minimum_index) * sizeof(Objects_Control *));
@@ -156,7 +152,6 @@ void _Objects_Extend_information(
/* /*
* Break the block into the various sections. * Break the block into the various sections.
*/ */
inactive_per_block = (uint32_t *) _Addresses_Add_offset( inactive_per_block = (uint32_t *) _Addresses_Add_offset(
object_blocks, block_count * sizeof(void*) ); object_blocks, block_count * sizeof(void*) );
local_table = (Objects_Control **) _Addresses_Add_offset( local_table = (Objects_Control **) _Addresses_Add_offset(
@@ -166,7 +161,6 @@ void _Objects_Extend_information(
* Take the block count down. Saves all the (block_count - 1) * Take the block count down. Saves all the (block_count - 1)
* in the copies. * in the copies.
*/ */
block_count--; block_count--;
if ( information->maximum > minimum_index ) { if ( information->maximum > minimum_index ) {
@@ -185,8 +179,7 @@ void _Objects_Extend_information(
memcpy( local_table, memcpy( local_table,
information->local_table, information->local_table,
(information->maximum + minimum_index) * sizeof(Objects_Control *) ); (information->maximum + minimum_index) * sizeof(Objects_Control *) );
} } else {
else {
/* /*
* Deal with the special case of the 0 to minimum_index * Deal with the special case of the 0 to minimum_index
@@ -199,7 +192,6 @@ void _Objects_Extend_information(
/* /*
* Initialise the new entries in the table. * Initialise the new entries in the table.
*/ */
object_blocks[block_count] = NULL; object_blocks[block_count] = NULL;
inactive_per_block[block_count] = 0; inactive_per_block[block_count] = 0;
@@ -235,13 +227,11 @@ void _Objects_Extend_information(
/* /*
* Assign the new object block to the object block table. * Assign the new object block to the object block table.
*/ */
information->object_blocks[ block ] = new_object_block; information->object_blocks[ block ] = new_object_block;
/* /*
* Initialize objects .. add to a local chain first. * Initialize objects .. add to a local chain first.
*/ */
_Chain_Initialize( _Chain_Initialize(
&Inactive, &Inactive,
information->object_blocks[ block ], information->object_blocks[ block ],
@@ -252,7 +242,6 @@ void _Objects_Extend_information(
/* /*
* Move from the local chain, initialise, then append to the inactive chain * Move from the local chain, initialise, then append to the inactive chain
*/ */
index = index_base; index = index_base;
while ((the_object = (Objects_Control *) _Chain_Get( &Inactive )) != NULL ) { while ((the_object = (Objects_Control *) _Chain_Get( &Inactive )) != NULL ) {