diff options
Diffstat (limited to 'src/chmboxes.c')
-rw-r--r-- | src/chmboxes.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chmboxes.c b/src/chmboxes.c index 59ce0c93a..35f69bf73 100644 --- a/src/chmboxes.c +++ b/src/chmboxes.c @@ -27,7 +27,6 @@ #include <ch.h>
#if CH_USE_MAILBOXES
-
/**
* @brief Initializes a Mailbox object.
*
@@ -37,6 +36,8 @@ */
void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
+ chDbgCheck((mbp != NULL) && (buf != NULL) && (n > 0), "chMBInit");
+
mbp->mb_buffer = mbp->mb_wrptr = mbp->mb_rdptr = buf;
mbp->mb_top = &buf[n];
chSemInit(&mbp->mb_emptysem, n);
@@ -52,6 +53,8 @@ void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) { */
void chMBReset(Mailbox *mbp) {
+ chDbgCheck(mbp != NULL, "chMBReset");
+
chSysLock();
mbp->mb_wrptr = mbp->mb_rdptr = mbp->mb_buffer;
chSemResetI(&mbp->mb_emptysem, mbp->mb_top - mbp->mb_buffer);
@@ -77,6 +80,8 @@ void chMBReset(Mailbox *mbp) { msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t timeout) {
msg_t rdymsg;
+ chDbgCheck(mbp != NULL, "chMBPost");
+
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, timeout);
if (rdymsg == RDY_OK) {
@@ -106,6 +111,8 @@ msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t timeout) { msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t timeout) {
msg_t rdymsg;
+ chDbgCheck(mbp != NULL, "chMBPostAhead");
+
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, timeout);
if (rdymsg == RDY_OK) {
@@ -135,6 +142,8 @@ msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t timeout) { msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t timeout) {
msg_t rdymsg;
+ chDbgCheck((mbp != NULL) && (msgp != NULL), "chMBFetch");
+
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_fullsem, timeout);
if (rdymsg == RDY_OK) {
|