From 19b76fe9d1aa9621a227bc979be639f6f60b0f3f Mon Sep 17 00:00:00 2001 From: Vidisha Thapa Date: Fri, 21 Jul 2017 15:00:09 +0530 Subject: [PATCH] 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. Signed-off-by: Vidisha Thapa --- lib/libc/pthread/pthread_mutexattr_getprotocol.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/libc/pthread/pthread_mutexattr_getprotocol.c b/lib/libc/pthread/pthread_mutexattr_getprotocol.c index a923fb5..6218ea7 100644 --- a/lib/libc/pthread/pthread_mutexattr_getprotocol.c +++ b/lib/libc/pthread/pthread_mutexattr_getprotocol.c @@ -59,6 +59,7 @@ #include #include #include +#include /**************************************************************************** * Public Functions @@ -80,16 +81,18 @@ * ****************************************************************************/ -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; + svdbg("Returning %d\n", attr->proto); + *protocol = attr->proto; #else - svdbg("Returning %d\n", PTHREAD_PRIO_NONE); - return PTHREAD_PRIO_NONE; + svdbg("Returning %d\n", PTHREAD_PRIO_NONE); + *protocol = PTHREAD_PRIO_NONE; #endif + return 0; + } + + return EINVAL; } -- 2.7.4