Module: xenomai-gch
Branch: for-forge
Commit: 7e07d9f70171175cef5be1740f040fe5779d10e5
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=7e07d9f70171175cef5be1740f040fe5779d10e5

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Oct 11 19:14:55 2015 +0200

cobalt/mutex: propagate autoinit error

instead of using assert.

---

 lib/cobalt/mutex.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index daf0e3a..0b62f4d 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -212,12 +212,19 @@ static int __attribute__((cold)) 
cobalt_mutex_autoinit(pthread_mutex_t *mutex)
        pthread_mutexattr_init(&mattr);
        pthread_mutexattr_settype(&mattr, type);
        err = __COBALT(pthread_mutex_lock(&cobalt_autoinit_mutex));
-       assert(err = 0);
+       if (err) {
+               ret = err;
+               goto out;
+       }
        if (_mutex->magic != COBALT_MUTEX_MAGIC)
                ret = __COBALT(pthread_mutex_init(mutex, &mattr));
        err = __COBALT(pthread_mutex_unlock(&cobalt_autoinit_mutex));
-       assert(err == 0);
+       if (err) {
+               if (ret == 0)
+                       ret = err;
+       }
 
+  out:
        pthread_mutexattr_destroy(&mattr);
 
        return ret;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to