diff options
| author | David Xu <davidxu@FreeBSD.org> | 2005-04-02 01:20:00 +0000 | 
|---|---|---|
| committer | David Xu <davidxu@FreeBSD.org> | 2005-04-02 01:20:00 +0000 | 
| commit | a091d823ad89a36935ba6e5568c4720a35f9a99b (patch) | |
| tree | 6aaef5f553a6539306bd6f5679d039ed3c2abcce /lib/libthr/thread/thr_mutex_protocol.c | |
| parent | 824a5e96dc28e3a2b48c4eb714bfb98efff1c8c4 (diff) | |
Notes
Diffstat (limited to 'lib/libthr/thread/thr_mutex_protocol.c')
| -rw-r--r-- | lib/libthr/thread/thr_mutex_protocol.c | 30 | 
1 files changed, 20 insertions, 10 deletions
| diff --git a/lib/libthr/thread/thr_mutex_protocol.c b/lib/libthr/thread/thr_mutex_protocol.c index 56c8622555a3..526cbe08a050 100644 --- a/lib/libthr/thread/thr_mutex_protocol.c +++ b/lib/libthr/thread/thr_mutex_protocol.c @@ -31,6 +31,7 @@   *   * $FreeBSD$   */ +  #include <string.h>  #include <stdlib.h>  #include <errno.h> @@ -43,19 +44,28 @@ __weak_reference(_pthread_mutexattr_setprotocol, pthread_mutexattr_setprotocol);  int  _pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol)  { -	if (*mattr == NULL) -		return (EINVAL); -	*protocol = (*mattr)->m_protocol; -	return(0); +	int ret = 0; + +	if ((mattr == NULL) || (*mattr == NULL)) +		ret = EINVAL; +	else +		*protocol = (*mattr)->m_protocol; + +	return(ret);  }  int  _pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol)  { -	if (*mattr == NULL || protocol < PTHREAD_PRIO_NONE || -	    protocol > PTHREAD_PRIO_PROTECT) -		return (EINVAL); -	(*mattr)->m_protocol = protocol; -	(*mattr)->m_ceiling = PTHREAD_MAX_PRIORITY; -	return(0); +	int ret = 0; + +	if ((mattr == NULL) || (*mattr == NULL) || +	    (protocol < PTHREAD_PRIO_NONE) || (protocol > PTHREAD_PRIO_PROTECT)) +		ret = EINVAL; +	else { +		(*mattr)->m_protocol = protocol; +		(*mattr)->m_ceiling = THR_MAX_PRIORITY; +	} +	return(ret);  } + | 
