summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_mutex_protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libthr/thread/thr_mutex_protocol.c')
-rw-r--r--lib/libthr/thread/thr_mutex_protocol.c30
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 56c8622..526cbe0 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);
}
+
OpenPOWER on IntegriCloud