summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/corerwlockrelease.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-22 15:02:02 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-22 15:02:02 +0000
commite5200d5afe4415f3c3f41b0b5c18c733c23d277f (patch)
tree29d730c0fef2865abdb1ddd89f0326994dfc7a97 /cpukit/score/src/corerwlockrelease.c
parentBump version to 0.7 (diff)
downloadrtems-e5200d5afe4415f3c3f41b0b5c18c733c23d277f.tar.bz2
2007-05-22 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/corerwlockrelease.c: Do not dereference NULL.
Diffstat (limited to 'cpukit/score/src/corerwlockrelease.c')
-rw-r--r--cpukit/score/src/corerwlockrelease.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c
index 30daaeaba9..b9d0e2f9e1 100644
--- a/cpukit/score/src/corerwlockrelease.c
+++ b/cpukit/score/src/corerwlockrelease.c
@@ -79,32 +79,33 @@ CORE_RWLock_Status _CORE_RWLock_Release(
next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
- rwmode = next->Wait.option;
- if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
- the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
- return CORE_RWLOCK_SUCCESSFUL;
- }
-
- /*
- * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more
- * readers can be let go.
- */
-
- while ( 1 ) {
- next = _Thread_queue_First( &the_rwlock->Wait_queue );
- if ( !next )
- return CORE_RWLOCK_SUCCESSFUL;
- if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ )
- return CORE_RWLOCK_SUCCESSFUL;
-
- /* it is definitely wanting to read */
- the_rwlock->number_of_readers += 1;
- _Thread_queue_Extract( &the_rwlock->Wait_queue, next );
- }
-
-
+ if ( next ) {
+ rwmode = next->Wait.option;
+ if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
+ the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
+ return CORE_RWLOCK_SUCCESSFUL;
+ }
+
+ /*
+ * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more
+ * readers can be let go.
+ */
+
+ while ( 1 ) {
+ next = _Thread_queue_First( &the_rwlock->Wait_queue );
+ if ( !next )
+ return CORE_RWLOCK_SUCCESSFUL;
+ if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ )
+ return CORE_RWLOCK_SUCCESSFUL;
+
+ /* it is definitely wanting to read */
+ the_rwlock->number_of_readers += 1;
+ _Thread_queue_Extract( &the_rwlock->Wait_queue, next );
+ }
/* XXX need to put read/write lock request indicator in Wait info */
+ }
+
return CORE_RWLOCK_SUCCESSFUL;
}