From fbd65c1f6ae3c802467ab99f4b2fe9c7c084972e Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 3 Mar 2015 11:01:09 +0000 Subject: MISRA-related fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7711 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/src/chmboxes.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'os/rt/src/chmboxes.c') diff --git a/os/rt/src/chmboxes.c b/os/rt/src/chmboxes.c index ace84c625..32d0f35ea 100644 --- a/os/rt/src/chmboxes.c +++ b/os/rt/src/chmboxes.c @@ -154,6 +154,7 @@ msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t time) { chSysLock(); rdymsg = chMBPostS(mbp, msg, time); chSysUnlock(); + return rdymsg; } @@ -185,11 +186,13 @@ msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t time) { rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time); if (rdymsg == MSG_OK) { *mbp->mb_wrptr++ = msg; - if (mbp->mb_wrptr >= mbp->mb_top) + if (mbp->mb_wrptr >= mbp->mb_top) { mbp->mb_wrptr = mbp->mb_buffer; + } chSemSignalI(&mbp->mb_fullsem); chSchRescheduleS(); } + return rdymsg; } @@ -212,13 +215,17 @@ msg_t chMBPostI(mailbox_t *mbp, msg_t msg) { chDbgCheckClassI(); chDbgCheck(mbp != NULL); - if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) + if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) { return MSG_TIMEOUT; + } + chSemFastWaitI(&mbp->mb_emptysem); *mbp->mb_wrptr++ = msg; - if (mbp->mb_wrptr >= mbp->mb_top) + if (mbp->mb_wrptr >= mbp->mb_top) { mbp->mb_wrptr = mbp->mb_buffer; + } chSemSignalI(&mbp->mb_fullsem); + return MSG_OK; } @@ -247,6 +254,7 @@ msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t time) { chSysLock(); rdymsg = chMBPostAheadS(mbp, msg, time); chSysUnlock(); + return rdymsg; } @@ -277,12 +285,14 @@ msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t time) { rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time); if (rdymsg == MSG_OK) { - if (--mbp->mb_rdptr < mbp->mb_buffer) + if (--mbp->mb_rdptr < mbp->mb_buffer) { mbp->mb_rdptr = mbp->mb_top - 1; + } *mbp->mb_rdptr = msg; chSemSignalI(&mbp->mb_fullsem); chSchRescheduleS(); } + return rdymsg; } @@ -305,13 +315,16 @@ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) { chDbgCheckClassI(); chDbgCheck(mbp != NULL); - if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) + if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) { return MSG_TIMEOUT; + } chSemFastWaitI(&mbp->mb_emptysem); - if (--mbp->mb_rdptr < mbp->mb_buffer) + if (--mbp->mb_rdptr < mbp->mb_buffer) { mbp->mb_rdptr = mbp->mb_top - 1; + } *mbp->mb_rdptr = msg; chSemSignalI(&mbp->mb_fullsem); + return MSG_OK; } @@ -340,6 +353,7 @@ msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t time) { chSysLock(); rdymsg = chMBFetchS(mbp, msgp, time); chSysUnlock(); + return rdymsg; } @@ -371,11 +385,13 @@ msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t time) { rdymsg = chSemWaitTimeoutS(&mbp->mb_fullsem, time); if (rdymsg == MSG_OK) { *msgp = *mbp->mb_rdptr++; - if (mbp->mb_rdptr >= mbp->mb_top) + if (mbp->mb_rdptr >= mbp->mb_top) { mbp->mb_rdptr = mbp->mb_buffer; + } chSemSignalI(&mbp->mb_emptysem); chSchRescheduleS(); } + return rdymsg; } @@ -398,13 +414,16 @@ msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp) { chDbgCheckClassI(); chDbgCheck((mbp != NULL) && (msgp != NULL)); - if (chSemGetCounterI(&mbp->mb_fullsem) <= 0) + if (chSemGetCounterI(&mbp->mb_fullsem) <= 0) { return MSG_TIMEOUT; + } chSemFastWaitI(&mbp->mb_fullsem); *msgp = *mbp->mb_rdptr++; - if (mbp->mb_rdptr >= mbp->mb_top) + if (mbp->mb_rdptr >= mbp->mb_top) { mbp->mb_rdptr = mbp->mb_buffer; + } chSemSignalI(&mbp->mb_emptysem); + return MSG_OK; } #endif /* CH_CFG_USE_MAILBOXES */ -- cgit v1.2.3