diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-03 11:01:09 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-03 11:01:09 +0000 |
commit | fbd65c1f6ae3c802467ab99f4b2fe9c7c084972e (patch) | |
tree | cafc124edd19ce4f3b676a9de703f7a0aefed409 /os/rt/src/chsem.c | |
parent | 3d1a86e9fb0b9495a726dab534e97c063b5f368b (diff) | |
download | ChibiOS-fbd65c1f6ae3c802467ab99f4b2fe9c7c084972e.tar.gz ChibiOS-fbd65c1f6ae3c802467ab99f4b2fe9c7c084972e.tar.bz2 ChibiOS-fbd65c1f6ae3c802467ab99f4b2fe9c7c084972e.zip |
MISRA-related fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7711 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/src/chsem.c')
-rw-r--r-- | os/rt/src/chsem.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/os/rt/src/chsem.c b/os/rt/src/chsem.c index 4f9a278c6..36fa8a445 100644 --- a/os/rt/src/chsem.c +++ b/os/rt/src/chsem.c @@ -155,8 +155,9 @@ void chSemResetI(semaphore_t *sp, cnt_t n) { cnt = sp->s_cnt;
sp->s_cnt = n;
- while (++cnt <= 0)
+ while (++cnt <= 0) {
chSchReadyI(queue_lifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_RESET;
+ }
}
/**
@@ -177,6 +178,7 @@ msg_t chSemWait(semaphore_t *sp) { chSysLock();
msg = chSemWaitS(sp);
chSysUnlock();
+
return msg;
}
@@ -204,8 +206,10 @@ msg_t chSemWaitS(semaphore_t *sp) { currp->p_u.wtobjp = sp;
sem_insert(currp, &sp->s_queue);
chSchGoSleepS(CH_STATE_WTSEM);
+
return currp->p_u.rdymsg;
}
+
return MSG_OK;
}
@@ -234,6 +238,7 @@ msg_t chSemWaitTimeout(semaphore_t *sp, systime_t time) { chSysLock();
msg = chSemWaitTimeoutS(sp, time);
chSysUnlock();
+
return msg;
}
@@ -267,12 +272,15 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) { if (--sp->s_cnt < 0) {
if (TIME_IMMEDIATE == time) {
sp->s_cnt++;
+
return MSG_TIMEOUT;
}
currp->p_u.wtobjp = sp;
sem_insert(currp, &sp->s_queue);
+
return chSchGoSleepTimeoutS(CH_STATE_WTSEM, time);
}
+
return MSG_OK;
}
@@ -291,8 +299,9 @@ void chSemSignal(semaphore_t *sp) { "inconsistent semaphore");
chSysLock();
- if (++sp->s_cnt <= 0)
+ if (++sp->s_cnt <= 0) {
chSchWakeupS(queue_fifo_remove(&sp->s_queue), MSG_OK);
+ }
chSysUnlock();
}
@@ -346,8 +355,9 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) { "inconsistent semaphore");
while (n > 0) {
- if (++sp->s_cnt <= 0)
+ if (++sp->s_cnt <= 0) {
chSchReadyI(queue_fifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_OK;
+ }
n--;
}
}
@@ -377,8 +387,9 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) { "inconsistent semaphore");
chSysLock();
- if (++sps->s_cnt <= 0)
+ if (++sps->s_cnt <= 0) {
chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = MSG_OK;
+ }
if (--spw->s_cnt < 0) {
thread_t *ctp = currp;
sem_insert(ctp, &spw->s_queue);
@@ -391,6 +402,7 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) { msg = MSG_OK;
}
chSysUnlock();
+
return msg;
}
|