diff options
author | Mike Makonnen <mtm@FreeBSD.org> | 2004-09-22 16:53:23 +0000 |
---|---|---|
committer | Mike Makonnen <mtm@FreeBSD.org> | 2004-09-22 16:53:23 +0000 |
commit | ff9af45a01e0312f2d252d06cdfefa08a2abcb37 (patch) | |
tree | 3c659c63b5b5fb7aad8bae17ea60a1e89767c367 | |
parent | e0a9358679c83233e889c638e8d81abc03aa3fc3 (diff) |
Notes
-rw-r--r-- | lib/libthr/thread/thr_mutex.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 2771a65d04d5e..ae6e406164a39 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -105,9 +105,7 @@ _mutex_reinit(pthread_mutex_t * mutex) { int ret = 0; - if (mutex == NULL) - ret = EINVAL; - else if (*mutex == PTHREAD_MUTEX_INITIALIZER) + if (*mutex == PTHREAD_MUTEX_INITIALIZER) ret = _pthread_mutex_init(mutex, NULL); else { /* @@ -169,9 +167,6 @@ _pthread_mutex_init(pthread_mutex_t * mutex, int _pthread_mutex_destroy(pthread_mutex_t * mutex) { - if (mutex == NULL) - return (EINVAL); - /* * If this mutex was statically initialized, don't bother * initializing it in order to destroy it immediately. @@ -271,14 +266,11 @@ __pthread_mutex_trylock(pthread_mutex_t *mutex) { int ret = 0; - if (mutex == NULL) - ret = EINVAL; - /* * If the mutex is statically initialized, perform the dynamic * initialization: */ - else if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || + if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || (ret = mutex_init(mutex, 0)) == 0) ret = mutex_lock_common(mutex, 1, NULL); @@ -295,14 +287,11 @@ _pthread_mutex_trylock(pthread_mutex_t *mutex) _thread_sigblock(); - if (mutex == NULL) - ret = EINVAL; - /* * If the mutex is statically initialized, perform the dynamic * initialization marking the mutex private (delete safe): */ - else if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || + if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || (ret = mutex_init(mutex, 1)) == 0) ret = mutex_lock_common(mutex, 1, NULL); @@ -518,14 +507,11 @@ __pthread_mutex_lock(pthread_mutex_t *mutex) if (_thread_initial == NULL) _thread_init(); - if (mutex == NULL) - ret = EINVAL; - /* * If the mutex is statically initialized, perform the dynamic * initialization: */ - else if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || + if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || ((ret = mutex_init(mutex, 0)) == 0)) ret = mutex_lock_common(mutex, 0, NULL); @@ -545,14 +531,11 @@ _pthread_mutex_lock(pthread_mutex_t *mutex) _thread_sigblock(); - if (mutex == NULL) - ret = EINVAL; - /* * If the mutex is statically initialized, perform the dynamic * initialization marking it private (delete safe): */ - else if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || + if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || ((ret = mutex_init(mutex, 1)) == 0)) ret = mutex_lock_common(mutex, 0, NULL); @@ -574,9 +557,7 @@ _pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime) /* * Initialize it if it's a valid statically inited mutex. */ - if (mutex == NULL) - error = EINVAL; - else if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || + if ((*mutex != PTHREAD_MUTEX_INITIALIZER) || ((error = mutex_init(mutex, 0)) == 0)) error = mutex_lock_common(mutex, 0, abstime); @@ -660,8 +641,6 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) /* * Error checking. */ - if (*mutex == NULL) - return (EINVAL); if ((*mutex)->m_owner != curthread) return (EPERM); PTHREAD_ASSERT(((*mutex)->m_protocol >= PTHREAD_PRIO_NONE && |