Module: xenomai-forge
Branch: next
Commit: 145e286a0cd351e25e3960617a3190ecbd36d054
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=145e286a0cd351e25e3960617a3190ecbd36d054

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Fri Oct 25 21:34:27 2013 +0200

cobalt: avoid calling prefault in case of syscall failure

---

 lib/cobalt/cond.c  |    9 ++++++---
 lib/cobalt/mutex.c |    2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index a65aef7..4df2ff0 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -87,8 +87,11 @@ COBALT_IMPL(int, pthread_cond_init, (pthread_cond_t *cond,
        unsigned long *pending_signalsp;
        int err;
 
-       err = XENOMAI_SKINCALL2(__cobalt_muxid, sc_cobalt_cond_init, _cnd, 
attr);
-       if (!err && !_cnd->attr.pshared) {
+       err = -XENOMAI_SKINCALL2(__cobalt_muxid, sc_cobalt_cond_init, _cnd, 
attr);
+       if (err)
+               return err;
+
+       if (!_cnd->attr.pshared) {
                pending_signalsp = (unsigned long *)
                        (cobalt_sem_heap[0] + _cnd->pending_signals_offset);
                _cnd->pending_signals = pending_signalsp;
@@ -97,7 +100,7 @@ COBALT_IMPL(int, pthread_cond_init, (pthread_cond_t *cond,
 
        __cobalt_prefault(pending_signalsp);
 
-       return -err;
+       return 0;
 }
 
 COBALT_IMPL(int, pthread_cond_destroy, (pthread_cond_t *cond))
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 0d0c4b2..9655eca 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -90,6 +90,8 @@ COBALT_IMPL(int, pthread_mutex_init, (pthread_mutex_t *mutex,
        }
 
        err = 
-XENOMAI_SKINCALL2(__cobalt_muxid,sc_cobalt_mutex_init,_mutex,attr);
+       if (err)
+               return err;
 
        if (!_mutex->attr.pshared) {
                datp = (struct mutex_dat *)


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

Reply via email to