Module: xenomai-3
Branch: master
Commit: 67ae83b2f26ff7550e3390781bf9fe10b3aef41b
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=67ae83b2f26ff7550e3390781bf9fe10b3aef41b

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