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/posix/src/mutexsetprioceiling.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'cpukit/posix/src/mutexsetprioceiling.c') diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c index de35bbae23..8d7b40adf3 100644 --- a/cpukit/posix/src/mutexsetprioceiling.c +++ b/cpukit/posix/src/mutexsetprioceiling.c @@ -48,13 +48,19 @@ int pthread_mutex_setprioceiling( the_priority = _POSIX_Priority_To_core( prioceiling ); /* - * Must acquire the mutex before we can change it's ceiling + * Must acquire the mutex before we can change it's ceiling. + * POSIX says block until we acquire it. */ + (void) pthread_mutex_lock( mutex ); - status = pthread_mutex_lock( mutex ); - if ( status ) - return status; - + /* + * Do not worry about the return code from this. The Get operation + * will also fail if it is a bad id or was deleted between the two + * operations. + * + * NOTE: This makes it easier to get 100% binary coverage since the + * bad Id case is handled by the switch. + */ the_mutex = _POSIX_Mutex_Get( mutex, &location ); switch ( location ) { @@ -63,12 +69,16 @@ int pthread_mutex_setprioceiling( the_mutex->Mutex.Attributes.priority_ceiling ); the_mutex->Mutex.Attributes.priority_ceiling = the_priority; + /* + * We are required to unlock the mutex before we return. + */ _CORE_mutex_Surrender( &the_mutex->Mutex, the_mutex->Object.id, NULL ); _Thread_Enable_dispatch(); + return 0; #if defined(RTEMS_MULTIPROCESSING) -- cgit v1.2.3