From 06f5ec9ce0fc6e876f40a4f07975049751fee669 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 7 Jul 2009 17:29:47 +0000 Subject: 2009-07-07 Joel Sherrill * posix/src/mutexsetprioceiling.c: Restructure to eliminate code paths which are unreachable. Also add more comments. * score/src/coremutexsurrender.c: Mark some code as RTEMS_DEBUG only since it cannot be hit unless coremutexseize.c is broken. --- cpukit/score/src/coremutexsurrender.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'cpukit/score/src/coremutexsurrender.c') diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index 16268934af..28d4b5d876 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -84,17 +84,27 @@ CORE_mutex_Status _CORE_mutex_Surrender( the_mutex->nest_count--; - if ( the_mutex->nest_count != 0 ) { - switch ( the_mutex->Attributes.lock_nesting_behavior ) { - case CORE_MUTEX_NESTING_ACQUIRES: - return CORE_MUTEX_STATUS_SUCCESSFUL; - case CORE_MUTEX_NESTING_IS_ERROR: - /* should never occur */ - return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; - case CORE_MUTEX_NESTING_BLOCKS: - /* Currently no API exercises this behavior. */ - break; - } + if ( the_mutex->nest_count != 0 ) { + /* + * All error checking is on the locking side, so if the lock was + * allowed to acquired multiple times, then we should just deal with + * that. The RTEMS_DEBUG is just a validation. + */ + #if defined(RTEMS_DEBUG) + switch ( the_mutex->Attributes.lock_nesting_behavior ) { + case CORE_MUTEX_NESTING_ACQUIRES: + return CORE_MUTEX_STATUS_SUCCESSFUL; + case CORE_MUTEX_NESTING_IS_ERROR: + /* should never occur */ + return CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; + case CORE_MUTEX_NESTING_BLOCKS: + /* Currently no API exercises this behavior. */ + break; + } + #else + /* must be CORE_MUTEX_NESTING_ACQUIRES or we wouldn't be here */ + return CORE_MUTEX_STATUS_SUCCESSFUL; + #endif } /* -- cgit v1.2.3