Libc/pthread: Fix return type of pthread_mutexattr_getprotocol
Upon successful completion, pthread_mutexattr_getprotocol() shall return 0;
otherwise, an error number shall be returned to indicate the error.
pthread_mutexattr_getprotocol was returning the protocol rather than 0.
#include <pthread.h>
#include <assert.h>
#include <debug.h>
+#include <errno.h>
/****************************************************************************
* Public Functions
*
****************************************************************************/
-int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr,
- FAR int *protocol)
+int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr, FAR int *protocol)
{
- DEBUGASSERT(attr != NULL && protocol != NULL);
-
+ if (attr != NULL && protocol != NULL) {
#ifdef CONFIG_PRIORITY_INHERITANCE
svdbg("Returning %d\n", attr->proto);
- return attr->proto;
+ *protocol = attr->proto;
#else
svdbg("Returning %d\n", PTHREAD_PRIO_NONE);
- return PTHREAD_PRIO_NONE;
+ *protocol = PTHREAD_PRIO_NONE;
#endif
+ return 0;
+ }
+
+ return EINVAL;
}
