summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/regiondelete.c
diff options
context:
space:
mode:
authorGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-27 17:38:11 +0000
committerGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-27 17:38:11 +0000
commit5700b804e2443135a07c6ff5f65a024e7be412fd (patch)
tree8177dd1b95bd7698eac495c8403c6bf7828e2cf3 /cpukit/rtems/src/regiondelete.c
parent2007-11-27 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-5700b804e2443135a07c6ff5f65a024e7be412fd.tar.bz2
2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* rtems/src/regioncreate.c, rtems/src/regiondelete.c, rtems/src/regionextend.c, rtems/src/regiongetfreeinfo.c, rtems/src/regiongetinfo.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, rtems/src/regionreturnsegment.c: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement, have a single exit with one call to _RTEMS_Unlock_allocator and eliminate the fall-through return of RTEMS_INTERNAL_ERROR. These changes produced simplier assembly code and allowed for complete test coverage.
Diffstat (limited to 'cpukit/rtems/src/regiondelete.c')
-rw-r--r--cpukit/rtems/src/regiondelete.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/cpukit/rtems/src/regiondelete.c b/cpukit/rtems/src/regiondelete.c
index 6788282750..2b96aa9720 100644
--- a/cpukit/rtems/src/regiondelete.c
+++ b/cpukit/rtems/src/regiondelete.c
@@ -46,33 +46,36 @@ rtems_status_code rtems_region_delete(
Objects_Id id
)
{
- register Region_Control *the_region;
Objects_Locations location;
+ rtems_status_code return_status = RTEMS_INTERNAL_ERROR;
+ register Region_Control *the_region;
_RTEMS_Lock_allocator();
- the_region = _Region_Get( id, &location );
- switch ( location ) {
+
+ the_region = _Region_Get( id, &location );
+ switch ( location ) {
+
+ case OBJECTS_LOCAL:
+ _Region_Debug_Walk( the_region, 5 );
+ if ( the_region->number_of_used_blocks != 0 )
+ return_status = RTEMS_RESOURCE_IN_USE;
+ else {
+ _Objects_Close( &_Region_Information, &the_region->Object );
+ _Region_Free( the_region );
+ return_status = RTEMS_SUCCESSFUL;
+ }
+ break;
+
#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* this error cannot be returned */
- _RTEMS_Unlock_allocator();
- return RTEMS_INTERNAL_ERROR;
+ case OBJECTS_REMOTE: /* this error cannot be returned */
+ break;
#endif
- case OBJECTS_ERROR:
- _RTEMS_Unlock_allocator();
- return RTEMS_INVALID_ID;
-
- case OBJECTS_LOCAL:
- _Region_Debug_Walk( the_region, 5 );
- if ( the_region->number_of_used_blocks == 0 ) {
- _Objects_Close( &_Region_Information, &the_region->Object );
- _Region_Free( the_region );
- _RTEMS_Unlock_allocator();
- return RTEMS_SUCCESSFUL;
- }
- _RTEMS_Unlock_allocator();
- return RTEMS_RESOURCE_IN_USE;
- }
+ case OBJECTS_ERROR:
+ return_status = RTEMS_INVALID_ID;
+ break;
+ }
- return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
+ _RTEMS_Unlock_allocator();
+ return return_status;
}