aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-03-10 10:24:19 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-03-10 10:24:19 +0000
commit014976ee109e90dec11591118a4ab0d88c00118f (patch)
tree7d53cbc697223e7603430157cb1976f3573ac7e1
parente801a6adb4c12d337963398fa63867aae98f7630 (diff)
downloadChibiOS-014976ee109e90dec11591118a4ab0d88c00118f.tar.gz
ChibiOS-014976ee109e90dec11591118a4ab0d88c00118f.tar.bz2
ChibiOS-014976ee109e90dec11591118a4ab0d88c00118f.zip
Added strong type checks to the code rules.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7746 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/rt/include/chbsem.h4
-rw-r--r--os/rt/include/chevents.h6
-rw-r--r--os/rt/include/chqueues.h4
-rw-r--r--os/rt/include/chschd.h80
-rw-r--r--os/rt/include/chthreads.h2
-rw-r--r--os/rt/include/chvt.h2
-rw-r--r--os/rt/ports/SIMIA32/chcore.h2
-rw-r--r--os/rt/src/chdynamic.c10
-rw-r--r--os/rt/src/chevents.c29
-rw-r--r--os/rt/src/chmboxes.c12
-rw-r--r--os/rt/src/chregistry.c2
-rw-r--r--os/rt/src/chschd.c8
-rw-r--r--os/rt/src/chsem.c56
-rw-r--r--os/rt/src/chsys.c2
-rw-r--r--os/rt/src/chthreads.c12
-rw-r--r--os/rt/src/chvt.c4
-rw-r--r--test/rt/testbuild/pclint/waivers.lnt18
17 files changed, 138 insertions, 115 deletions
diff --git a/os/rt/include/chbsem.h b/os/rt/include/chbsem.h
index 96d1ca2fb..336e6925f 100644
--- a/os/rt/include/chbsem.h
+++ b/os/rt/include/chbsem.h
@@ -267,7 +267,7 @@ static inline void chBSemSignalI(binary_semaphore_t *bsp) {
chDbgCheckClassI();
- if (bsp->bs_sem.s_cnt < 1) {
+ if (bsp->bs_sem.s_cnt < (cnt_t)1) {
chSemSignalI(&bsp->bs_sem);
}
}
@@ -301,7 +301,7 @@ static inline bool chBSemGetStateI(binary_semaphore_t *bsp) {
chDbgCheckClassI();
- return (bsp->bs_sem.s_cnt > 0) ? false : true;
+ return (bsp->bs_sem.s_cnt > (cnt_t)0) ? false : true;
}
#endif /* CH_CFG_USE_SEMAPHORES == TRUE */
diff --git a/os/rt/include/chevents.h b/os/rt/include/chevents.h
index e58836f2e..8ac91d256 100644
--- a/os/rt/include/chevents.h
+++ b/os/rt/include/chevents.h
@@ -188,7 +188,7 @@ static inline void chEvtObjectInit(event_source_t *esp) {
*/
static inline void chEvtRegisterMask(event_source_t *esp,
event_listener_t *elp,
- eventflags_t events) {
+ eventmask_t events) {
chEvtRegisterMaskWithFlags(esp, elp, events, (eventflags_t)-1);
}
@@ -236,7 +236,7 @@ static inline bool chEvtIsListeningI(event_source_t *esp) {
*/
static inline void chEvtBroadcast(event_source_t *esp) {
- chEvtBroadcastFlags(esp, 0);
+ chEvtBroadcastFlags(esp, (eventflags_t)0);
}
/**
@@ -253,7 +253,7 @@ static inline void chEvtBroadcast(event_source_t *esp) {
*/
static inline void chEvtBroadcastI(event_source_t *esp) {
- chEvtBroadcastFlagsI(esp, 0);
+ chEvtBroadcastFlagsI(esp, (eventflags_t)0);
}
#endif /* CH_CFG_USE_EVENTS == TRUE */
diff --git a/os/rt/include/chqueues.h b/os/rt/include/chqueues.h
index 079b417d5..2b4c660f3 100644
--- a/os/rt/include/chqueues.h
+++ b/os/rt/include/chqueues.h
@@ -41,8 +41,8 @@
#define Q_OK MSG_OK /**< @brief Operation successful. */
#define Q_TIMEOUT MSG_TIMEOUT /**< @brief Timeout condition. */
#define Q_RESET MSG_RESET /**< @brief Queue has been reset. */
-#define Q_EMPTY -3 /**< @brief Queue empty. */
-#define Q_FULL -4 /**< @brief Queue full, */
+#define Q_EMPTY (msg_t)-3 /**< @brief Queue empty. */
+#define Q_FULL (msg_t)-4 /**< @brief Queue full, */
/** @} */
/*===========================================================================*/
diff --git a/os/rt/include/chschd.h b/os/rt/include/chschd.h
index 4d3319817..5d9829d57 100644
--- a/os/rt/include/chschd.h
+++ b/os/rt/include/chschd.h
@@ -36,48 +36,50 @@
* @name Wakeup status codes
* @{
*/
-#define MSG_OK 0 /**< @brief Normal wakeup message. */
-#define MSG_TIMEOUT -1 /**< @brief Wakeup caused by a timeout
- condition. */
-#define MSG_RESET -2 /**< @brief Wakeup caused by a reset
- condition. */
+#define MSG_OK (msg_t)0 /**< @brief Normal wakeup message. */
+#define MSG_TIMEOUT (msg_t)-1 /**< @brief Wakeup caused by a timeout
+ condition. */
+#define MSG_RESET (msg_t)-2 /**< @brief Wakeup caused by a reset
+ condition. */
/** @} */
/**
* @name Priority constants
* @{
*/
-#define NOPRIO 0U /**< @brief Ready list header priority. */
-#define IDLEPRIO 1U /**< @brief Idle thread priority. */
-#define LOWPRIO 2U /**< @brief Lowest user priority. */
-#define NORMALPRIO 64U /**< @brief Normal user priority. */
-#define HIGHPRIO 127U /**< @brief Highest user priority. */
-#define ABSPRIO 255U /**< @brief Greatest possible priority. */
+#define NOPRIO (tprio_t)0 /**< @brief Ready list header
+ priority. */
+#define IDLEPRIO (tprio_t)1 /**< @brief Idle priority. */
+#define LOWPRIO (tprio_t)2 /**< @brief Lowest priority. */
+#define NORMALPRIO (tprio_t)64 /**< @brief Normal priority. */
+#define HIGHPRIO (tprio_t)127 /**< @brief Highest priority. */
+#define ABSPRIO (tprio_t)255 /**< @brief Greatest priority. */
/** @} */
/**
* @name Thread states
* @{
*/
-#define CH_STATE_READY 0U /**< @brief Waiting on the ready list. */
-#define CH_STATE_CURRENT 1U /**< @brief Currently running. */
-#define CH_STATE_WTSTART 2U /**< @brief Created but not started. */
-#define CH_STATE_SUSPENDED 3U /**< @brief Suspended state. */
-#define CH_STATE_QUEUED 4U /**< @brief Waiting on an I/O queue. */
-#define CH_STATE_WTSEM 5U /**< @brief Waiting on a semaphore. */
-#define CH_STATE_WTMTX 6U /**< @brief Waiting on a mutex. */
-#define CH_STATE_WTCOND 7U /**< @brief Waiting on a condition
- variable. */
-#define CH_STATE_SLEEPING 8U /**< @brief Waiting in @p chThdSleep()
- or @p chThdSleepUntil(). */
-#define CH_STATE_WTEXIT 9U /**< @brief Waiting in @p chThdWait(). */
-#define CH_STATE_WTOREVT 10U /**< @brief Waiting for an event. */
-#define CH_STATE_WTANDEVT 11U /**< @brief Waiting for several events. */
-#define CH_STATE_SNDMSGQ 12U /**< @brief Sending a message, in queue.*/
-#define CH_STATE_SNDMSG 13U /**< @brief Sent a message, waiting
- answer. */
-#define CH_STATE_WTMSG 14U /**< @brief Waiting for a message. */
-#define CH_STATE_FINAL 15U /**< @brief Thread terminated. */
+#define CH_STATE_READY (tstate_t)0 /**< @brief Waiting on the
+ ready list. */
+#define CH_STATE_CURRENT (tstate_t)1 /**< @brief Currently running. */
+#define CH_STATE_WTSTART (tstate_t)2 /**< @brief Just created. */
+#define CH_STATE_SUSPENDED (tstate_t)3 /**< @brief Suspended state. */
+#define CH_STATE_QUEUED (tstate_t)4 /**< @brief On an I/O queue. */
+#define CH_STATE_WTSEM (tstate_t)5 /**< @brief On a semaphore. */
+#define CH_STATE_WTMTX (tstate_t)6 /**< @brief On a mutex. */
+#define CH_STATE_WTCOND (tstate_t)7 /**< @brief On a cond.variable.*/
+#define CH_STATE_SLEEPING (tstate_t)8 /**< @brief Sleeping. */
+#define CH_STATE_WTEXIT (tstate_t)9 /**< @brief Waiting a thread. */
+#define CH_STATE_WTOREVT (tstate_t)10 /**< @brief One event. */
+#define CH_STATE_WTANDEVT (tstate_t)11 /**< @brief Several events. */
+#define CH_STATE_SNDMSGQ (tstate_t)12 /**< @brief Sending a message,
+ in queue. */
+#define CH_STATE_SNDMSG (tstate_t)13 /**< @brief Sent a message,
+ waiting answer. */
+#define CH_STATE_WTMSG (tstate_t)14 /**< @brief Waiting for a
+ message. */
+#define CH_STATE_FINAL (tstate_t)15 /**< @brief Thread terminated. */
/**
* @brief Thread states as array of strings.
@@ -94,13 +96,15 @@
* @name Thread flags and attributes
* @{
*/
-#define CH_FLAG_MODE_MASK 3U /**< @brief Thread memory mode mask. */
-#define CH_FLAG_MODE_STATIC 0U /**< @brief Static thread. */
-#define CH_FLAG_MODE_HEAP 1U /**< @brief Thread allocated from a
- Memory Heap. */
-#define CH_FLAG_MODE_MEMPOOL 2U /**< @brief Thread allocated from a
- Memory Pool. */
-#define CH_FLAG_TERMINATE 4U /**< @brief Termination requested flag. */
+#define CH_FLAG_MODE_MASK (tmode_t)3U /**< @brief Thread memory mode
+ mask. */
+#define CH_FLAG_MODE_STATIC (tmode_t)0U /**< @brief Static thread. */
+#define CH_FLAG_MODE_HEAP (tmode_t)1U /**< @brief Thread allocated
+ from a Memory Heap. */
+#define CH_FLAG_MODE_MPOOL (tmode_t)2U /**< @brief Thread allocated
+ from a Memory Pool. */
+#define CH_FLAG_TERMINATE (tmode_t)4U /**< @brief Termination requested
+ flag. */
/** @} */
/**
@@ -755,7 +759,7 @@ static inline void chSchPreemption(void) {
tprio_t p2 = currp->p_prio;
#if CH_CFG_TIME_QUANTUM > 0
- if (currp->p_preempt > 0U) {
+ if (currp->p_preempt > (tslices_t)0) {
if (p1 > p2) {
chSchDoRescheduleAhead();
}
diff --git a/os/rt/include/chthreads.h b/os/rt/include/chthreads.h
index 966f5de08..aca3e1d78 100644
--- a/os/rt/include/chthreads.h
+++ b/os/rt/include/chthreads.h
@@ -230,7 +230,7 @@ static inline bool chThdTerminatedX(thread_t *tp) {
*/
static inline bool chThdShouldTerminateX(void) {
- return (bool)((chThdGetSelfX()->p_flags & CH_FLAG_TERMINATE) != 0U);
+ return (bool)((chThdGetSelfX()->p_flags & CH_FLAG_TERMINATE) != (tmode_t)0);
}
/**
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index 2d7d36f29..01cfbdeee 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -451,7 +451,7 @@ static inline void chVTDoTickI(void) {
virtual_timer_t *vtp;
--ch.vtlist.vt_next->vt_delta;
- while (ch.vtlist.vt_next->vt_delta == 0U) {
+ while (ch.vtlist.vt_next->vt_delta == (systime_t)0) {
vtfunc_t fn;
vtp = ch.vtlist.vt_next;
diff --git a/os/rt/ports/SIMIA32/chcore.h b/os/rt/ports/SIMIA32/chcore.h
index 943dbaf6e..b313cb9f9 100644
--- a/os/rt/ports/SIMIA32/chcore.h
+++ b/os/rt/ports/SIMIA32/chcore.h
@@ -276,7 +276,7 @@ static inline syssts_t port_get_irq_status(void) {
*/
static inline bool port_irq_enabled(syssts_t sts) {
- return (sts & 1U) == 0U;
+ return (sts & (syssts_t)1) == (syssts_t)0;
}
/**
diff --git a/os/rt/src/chdynamic.c b/os/rt/src/chdynamic.c
index 05cb3a265..ac4db6ba4 100644
--- a/os/rt/src/chdynamic.c
+++ b/os/rt/src/chdynamic.c
@@ -68,7 +68,7 @@
thread_t *chThdAddRef(thread_t *tp) {
chSysLock();
- chDbgAssert(tp->p_refs < 255U, "too many references");
+ chDbgAssert(tp->p_refs < (trefs_t)255, "too many references");
tp->p_refs++;
chSysUnlock();
@@ -92,7 +92,7 @@ void chThdRelease(thread_t *tp) {
trefs_t refs;
chSysLock();
- chDbgAssert(tp->p_refs > 0U, "not referenced");
+ chDbgAssert(tp->p_refs > (trefs_t)0, "not referenced");
tp->p_refs--;
refs = tp->p_refs;
chSysUnlock();
@@ -100,7 +100,7 @@ void chThdRelease(thread_t *tp) {
/* If the references counter reaches zero and the thread is in its
terminated state then the memory can be returned to the proper
allocator. Of course static threads are not affected.*/
- if ((refs == 0U) && (tp->p_state == CH_STATE_FINAL)) {
+ if ((refs == (trefs_t)0) && (tp->p_state == CH_STATE_FINAL)) {
switch (tp->p_flags & CH_FLAG_MODE_MASK) {
#if CH_CFG_USE_HEAP == TRUE
case CH_FLAG_MODE_HEAP:
@@ -111,7 +111,7 @@ void chThdRelease(thread_t *tp) {
break;
#endif
#if CH_CFG_USE_MEMPOOLS == TRUE
- case CH_FLAG_MODE_MEMPOOL:
+ case CH_FLAG_MODE_MPOOL:
#if CH_CFG_USE_REGISTRY == TRUE
REG_REMOVE(tp);
#endif
@@ -224,7 +224,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
chSysLock();
tp = chThdCreateI(wsp, mp->mp_object_size, prio, pf, arg);
- tp->p_flags = CH_FLAG_MODE_MEMPOOL;
+ tp->p_flags = CH_FLAG_MODE_MPOOL;
tp->p_mpool = mp;
chSchWakeupS(tp, MSG_OK);
chSysUnlock();
diff --git a/os/rt/src/chevents.c b/os/rt/src/chevents.c
index df5e4bfaa..96c1594d8 100644
--- a/os/rt/src/chevents.c
+++ b/os/rt/src/chevents.c
@@ -112,7 +112,7 @@ void chEvtRegisterMaskWithFlags(event_source_t *esp,
esp->es_next = elp;
elp->el_listener = currp;
elp->el_events = events;
- elp->el_flags = 0;
+ elp->el_flags = (eventflags_t)0;
elp->el_wflags = wflags;
chSysUnlock();
}
@@ -219,7 +219,8 @@ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {
elp->el_flags |= flags;
/* When flags == 0 the thread will always be signaled because the
source does not emit any flag.*/
- if ((flags == 0U) || ((elp->el_flags & elp->el_wflags) != 0U)) {
+ if ((flags == (eventflags_t)0) ||
+ ((elp->el_flags & elp->el_wflags) != (eventflags_t)0)) {
chEvtSignalI(elp->el_listener, elp->el_events);
}
elp = elp->el_next;
@@ -242,7 +243,7 @@ eventflags_t chEvtGetAndClearFlags(event_listener_t *elp) {
chSysLock();
flags = elp->el_flags;
- elp->el_flags = 0;
+ elp->el_flags = (eventflags_t)0;
chSysUnlock();
return flags;
@@ -286,7 +287,7 @@ void chEvtSignalI(thread_t *tp, eventmask_t events) {
tp->p_epending |= events;
/* Test on the AND/OR conditions wait states.*/
if (((tp->p_state == CH_STATE_WTOREVT) &&
- ((tp->p_epending & tp->p_u.ewmask) != 0U)) ||
+ ((tp->p_epending & tp->p_u.ewmask) != (eventmask_t)0)) ||
((tp->p_state == CH_STATE_WTANDEVT) &&
((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask))) {
tp->p_u.rdymsg = MSG_OK;
@@ -330,7 +331,7 @@ eventflags_t chEvtGetAndClearFlagsI(event_listener_t *elp) {
eventflags_t flags;
flags = elp->el_flags;
- elp->el_flags = 0;
+ elp->el_flags = (eventflags_t)0;
return flags;
}
@@ -349,9 +350,9 @@ void chEvtDispatch(const evhandler_t *handlers, eventmask_t events) {
chDbgCheck(handlers != NULL);
- eid = 0;
- while (events != 0U) {
- if ((events & EVENT_MASK(eid)) != 0U) {
+ eid = (eventid_t)0;
+ while (events != (eventmask_t)0) {
+ if ((events & EVENT_MASK(eid)) != (eventmask_t)0) {
chDbgAssert(handlers[eid] != NULL, "null handler");
events &= ~EVENT_MASK(eid);
handlers[eid](eid);
@@ -385,12 +386,12 @@ eventmask_t chEvtWaitOne(eventmask_t events) {
chSysLock();
m = ctp->p_epending & events;
- if (m == 0U) {
+ if (m == (eventmask_t)0) {
ctp->p_u.ewmask = events;
chSchGoSleepS(CH_STATE_WTOREVT);
m = ctp->p_epending & events;
}
- m ^= m & (m - 1U);
+ m ^= m & (m - (eventmask_t)1);
ctp->p_epending &= ~m;
chSysUnlock();
@@ -415,7 +416,7 @@ eventmask_t chEvtWaitAny(eventmask_t events) {
chSysLock();
m = ctp->p_epending & events;
- if (m == 0U) {
+ if (m == (eventmask_t)0) {
ctp->p_u.ewmask = events;
chSchGoSleepS(CH_STATE_WTOREVT);
m = ctp->p_epending & events;
@@ -481,7 +482,7 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t events, systime_t time) {
chSysLock();
m = ctp->p_epending & events;
- if (m == 0U) {
+ if (m == (eventmask_t)0) {
if (TIME_IMMEDIATE == time) {
chSysUnlock();
return (eventmask_t)0;
@@ -493,7 +494,7 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t events, systime_t time) {
}
m = ctp->p_epending & events;
}
- m ^= m & (m - 1U);
+ m ^= m & (m - (eventmask_t)1);
ctp->p_epending &= ~m;
chSysUnlock();
@@ -524,7 +525,7 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t events, systime_t time) {
chSysLock();
m = ctp->p_epending & events;
- if (m == 0U) {
+ if (m == (eventmask_t)0) {
if (TIME_IMMEDIATE == time) {
chSysUnlock();
return (eventmask_t)0;
diff --git a/os/rt/src/chmboxes.c b/os/rt/src/chmboxes.c
index 6c518676b..21f8ce55e 100644
--- a/os/rt/src/chmboxes.c
+++ b/os/rt/src/chmboxes.c
@@ -85,14 +85,14 @@
*/
void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n) {
- chDbgCheck((mbp != NULL) && (buf != NULL) && (n > 0));
+ chDbgCheck((mbp != NULL) && (buf != NULL) && (n > (cnt_t)0));
mbp->mb_buffer = buf;
mbp->mb_rdptr = buf;
mbp->mb_wrptr = buf;
mbp->mb_top = &buf[n];
chSemObjectInit(&mbp->mb_emptysem, n);
- chSemObjectInit(&mbp->mb_fullsem, 0);
+ chSemObjectInit(&mbp->mb_fullsem, (cnt_t)0);
}
/**
@@ -129,7 +129,7 @@ void chMBResetI(mailbox_t *mbp) {
mbp->mb_wrptr = mbp->mb_buffer;
mbp->mb_rdptr = mbp->mb_buffer;
chSemResetI(&mbp->mb_emptysem, (cnt_t)(mbp->mb_top - mbp->mb_buffer));
- chSemResetI(&mbp->mb_fullsem, 0);
+ chSemResetI(&mbp->mb_fullsem, (cnt_t)0);
}
/**
@@ -218,7 +218,7 @@ msg_t chMBPostI(mailbox_t *mbp, msg_t msg) {
chDbgCheckClassI();
chDbgCheck(mbp != NULL);
- if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) {
+ if (chSemGetCounterI(&mbp->mb_emptysem) <= (cnt_t)0) {
return MSG_TIMEOUT;
}
@@ -318,7 +318,7 @@ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) {
chDbgCheckClassI();
chDbgCheck(mbp != NULL);
- if (chSemGetCounterI(&mbp->mb_emptysem) <= 0) {
+ if (chSemGetCounterI(&mbp->mb_emptysem) <= (cnt_t)0) {
return MSG_TIMEOUT;
}
chSemFastWaitI(&mbp->mb_emptysem);
@@ -417,7 +417,7 @@ 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) <= (cnt_t)0) {
return MSG_TIMEOUT;
}
chSemFastWaitI(&mbp->mb_fullsem);
diff --git a/os/rt/src/chregistry.c b/os/rt/src/chregistry.c
index 162d69bf2..aacadf22c 100644
--- a/os/rt/src/chregistry.c
+++ b/os/rt/src/chregistry.c
@@ -164,7 +164,7 @@ thread_t *chRegNextThread(thread_t *tp) {
}
#if CH_CFG_USE_DYNAMIC == TRUE
else {
- chDbgAssert(ntp->p_refs < 255U, "too many references");
+ chDbgAssert(ntp->p_refs < (trefs_t)255, "too many references");
ntp->p_refs++;
}
#endif
diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c
index 91b982b0c..e53384b3d 100644
--- a/os/rt/src/chschd.c
+++ b/os/rt/src/chschd.c
@@ -257,7 +257,7 @@ void chSchGoSleepS(tstate_t newstate) {
#if CH_CFG_TIME_QUANTUM > 0
/* The thread is renouncing its remaining time slices so it will have a new
time quantum when it will wakeup.*/
- otp->p_preempt = CH_CFG_TIME_QUANTUM;
+ otp->p_preempt = (tslices_t)CH_CFG_TIME_QUANTUM;
#endif
setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
#if defined(CH_CFG_IDLE_ENTER_HOOK)
@@ -430,7 +430,7 @@ bool chSchIsPreemptionRequired(void) {
if the first thread on the ready queue has a higher priority.
Otherwise, if the running thread has used up its time quantum, reschedule
if the first thread on the ready queue has equal or higher priority.*/
- return (currp->p_preempt > 0U) ? (p1 > p2) : (p1 >= p2);
+ return (currp->p_preempt > (tslices_t)0) ? (p1 > p2) : (p1 >= p2);
#else
/* If the round robin preemption feature is not enabled then performs a
simpler comparison.*/
@@ -461,7 +461,7 @@ void chSchDoRescheduleBehind(void) {
#endif
currp->p_state = CH_STATE_CURRENT;
#if CH_CFG_TIME_QUANTUM > 0
- otp->p_preempt = CH_CFG_TIME_QUANTUM;
+ otp->p_preempt = (tslices_t)CH_CFG_TIME_QUANTUM;
#endif
(void) chSchReadyI(otp);
chSysSwitch(currp, otp);
@@ -518,7 +518,7 @@ void chSchDoReschedule(void) {
#if CH_CFG_TIME_QUANTUM > 0
/* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios
to handle on preemption: time quantum elapsed or not.*/
- if (currp->p_preempt == 0U) {
+ if (currp->p_preempt == (tslices_t)0) {
/* The thread consumed its time quantum so it is enqueued behind threads
with same priority level, however, it acquires a new time quantum.*/
chSchDoRescheduleBehind();
diff --git a/os/rt/src/chsem.c b/os/rt/src/chsem.c
index 30a68e035..4a891b521 100644
--- a/os/rt/src/chsem.c
+++ b/os/rt/src/chsem.c
@@ -96,7 +96,7 @@
*/
void chSemObjectInit(semaphore_t *sp, cnt_t n) {
- chDbgCheck((sp != NULL) && (n >= 0));
+ chDbgCheck((sp != NULL) && (n >= (cnt_t)0));
queue_init(&sp->s_queue);
sp->s_cnt = n;
@@ -148,14 +148,14 @@ void chSemResetI(semaphore_t *sp, cnt_t n) {
cnt_t cnt;
chDbgCheckClassI();
- chDbgCheck((sp != NULL) && (n >= 0));
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgCheck((sp != NULL) && (n >= (cnt_t)0));
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
cnt = sp->s_cnt;
sp->s_cnt = n;
- while (++cnt <= 0) {
+ while (++cnt <= (cnt_t)0) {
chSchReadyI(queue_lifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_RESET;
}
}
@@ -198,11 +198,11 @@ msg_t chSemWaitS(semaphore_t *sp) {
chDbgCheckClassS();
chDbgCheck(sp != NULL);
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
- if (--sp->s_cnt < 0) {
+ if (--sp->s_cnt < (cnt_t)0) {
currp->p_u.wtsemp = sp;
sem_insert(currp, &sp->s_queue);
chSchGoSleepS(CH_STATE_WTSEM);
@@ -265,11 +265,11 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) {
chDbgCheckClassS();
chDbgCheck(sp != NULL);
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
- if (--sp->s_cnt < 0) {
+ if (--sp->s_cnt < (cnt_t)0) {
if (TIME_IMMEDIATE == time) {
sp->s_cnt++;
@@ -294,12 +294,12 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) {
void chSemSignal(semaphore_t *sp) {
chDbgCheck(sp != NULL);
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
chSysLock();
- if (++sp->s_cnt <= 0) {
+ if (++sp->s_cnt <= (cnt_t)0) {
chSchWakeupS(queue_fifo_remove(&sp->s_queue), MSG_OK);
}
chSysUnlock();
@@ -320,11 +320,11 @@ void chSemSignalI(semaphore_t *sp) {
chDbgCheckClassI();
chDbgCheck(sp != NULL);
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
- if (++sp->s_cnt <= 0) {
+ if (++sp->s_cnt <= (cnt_t)0) {
/* Note, it is done this way in order to allow a tail call on
chSchReadyI().*/
thread_t *tp = queue_fifo_remove(&sp->s_queue);
@@ -349,13 +349,13 @@ void chSemSignalI(semaphore_t *sp) {
void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
chDbgCheckClassI();
- chDbgCheck((sp != NULL) && (n > 0));
- chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
- ((sp->s_cnt < 0) && queue_notempty(&sp->s_queue)),
+ chDbgCheck((sp != NULL) && (n > (cnt_t)0));
+ chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) ||
+ ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)),
"inconsistent semaphore");
- while (n > 0) {
- if (++sp->s_cnt <= 0) {
+ while (n > (cnt_t)0) {
+ if (++sp->s_cnt <= (cnt_t)0) {
chSchReadyI(queue_fifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_OK;
}
n--;
@@ -379,18 +379,18 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
msg_t msg;
chDbgCheck((sps != NULL) && (spw != NULL));
- chDbgAssert(((sps->s_cnt >= 0) && queue_isempty(&sps->s_queue)) ||
- ((sps->s_cnt < 0) && queue_notempty(&sps->s_queue)),
+ chDbgAssert(((sps->s_cnt >= (cnt_t)0) && queue_isempty(&sps->s_queue)) ||
+ ((sps->s_cnt < (cnt_t)0) && queue_notempty(&sps->s_queue)),
"inconsistent semaphore");
- chDbgAssert(((spw->s_cnt >= 0) && queue_isempty(&spw->s_queue)) ||
- ((spw->s_cnt < 0) && queue_notempty(&spw->s_queue)),
+ chDbgAssert(((spw->s_cnt >= (cnt_t)0) && queue_isempty(&spw->s_queue)) ||
+ ((spw->s_cnt < (cnt_t)0) && queue_notempty(&spw->s_queue)),
"inconsistent semaphore");
chSysLock();
- if (++sps->s_cnt <= 0) {
+ if (++sps->s_cnt <= (cnt_t)0) {
chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = MSG_OK;
}
- if (--spw->s_cnt < 0) {
+ if (--spw->s_cnt < (cnt_t)0) {
thread_t *ctp = currp;
sem_insert(ctp, &spw->s_queue);
ctp->p_u.wtsemp = spw;
diff --git a/os/rt/src/chsys.c b/os/rt/src/chsys.c
index 44c4fc567..a9fd3aa53 100644
--- a/os/rt/src/chsys.c
+++ b/os/rt/src/chsys.c
@@ -188,7 +188,7 @@ void chSysTimerHandlerI(void) {
#if CH_CFG_TIME_QUANTUM > 0
/* Running thread has not used up quantum yet? */
- if (currp->p_preempt > 0U) {
+ if (currp->p_preempt > (tslices_t)0) {
/* Decrement remaining quantum.*/
currp->p_preempt--;
}
diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
index 491f416d5..9c18788c0 100644
--- a/os/rt/src/chthreads.c
+++ b/os/rt/src/chthreads.c
@@ -94,20 +94,20 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) {
tp->p_state = CH_STATE_WTSTART;
tp->p_flags = CH_FLAG_MODE_STATIC;
#if CH_CFG_TIME_QUANTUM > 0
- tp->p_preempt = CH_CFG_TIME_QUANTUM;
+ tp->p_preempt = (tslices_t)CH_CFG_TIME_QUANTUM;
#endif
#if CH_CFG_USE_MUTEXES == TRUE
tp->p_realprio = prio;
tp->p_mtxlist = NULL;
#endif
#if CH_CFG_USE_EVENTS == TRUE
- tp->p_epending = 0;
+ tp->p_epending = (eventmask_t)0;
#endif
#if CH_DBG_THREADS_PROFILING == TRUE
- tp->p_time = 0;
+ tp->p_time = (systime_t)0;
#endif
#if CH_CFG_USE_DYNAMIC == TRUE
- tp->p_refs = 1;
+ tp->p_refs = (trefs_t)1;
#endif
#if CH_CFG_USE_REGISTRY == TRUE
tp->p_name = NULL;
@@ -333,7 +333,7 @@ void chThdSleepUntil(systime_t time) {
chSysLock();
time -= chVTGetSystemTimeX();
- if (time > 0U) {
+ if (time > (systime_t)0) {
chThdSleepS(time);
}
chSysUnlock();
@@ -480,7 +480,7 @@ msg_t chThdWait(thread_t *tp) {
chSysLock();
chDbgAssert(tp != currp, "waiting self");
#if CH_CFG_USE_DYNAMIC == TRUE
- chDbgAssert(tp->p_refs > 0U, "not referenced");
+ chDbgAssert(tp->p_refs > (trefs_t)0, "not referenced");
#endif
if (tp->p_state != CH_STATE_FINAL) {
list_insert(currp, &tp->p_waiting);
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c
index d802bc0c3..61fa7e056 100644
--- a/os/rt/src/chvt.c
+++ b/os/rt/src/chvt.c
@@ -64,9 +64,9 @@ void _vt_init(void) {
ch.vtlist.vt_prev = (virtual_timer_t *)&ch.vtlist;
ch.vtlist.vt_delta = (systime_t)-1;
#if CH_CFG_ST_TIMEDELTA == 0
- ch.vtlist.vt_systime = 0;
+ ch.vtlist.vt_systime = (systime_t)0;
#else /* CH_CFG_ST_TIMEDELTA > 0 */
- ch.vtlist.vt_lasttime = 0;
+ ch.vtlist.vt_lasttime = (systime_t)0;
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
}
diff --git a/test/rt/testbuild/pclint/waivers.lnt b/test/rt/testbuild/pclint/waivers.lnt
index 1acdaf818..03ccb7a09 100644
--- a/test/rt/testbuild/pclint/waivers.lnt
+++ b/test/rt/testbuild/pclint/waivers.lnt
@@ -7,6 +7,24 @@
+libh(stm32f4xx.h)
+libh(*_lld.h)
+/* Reinforcing type checking for some critical types even if not required by
+ MISRA.*/
+-strong(AJX, systime_t)
+-strong(AJX, rtcnt_t)
+-strong(AJX, rttime_t)
+-strong(AJX, syssts_t)
+-strong(AJX, msg_t)
+-strong(AJX, tmode_t)
+-strong(AJX, tstate_t)
+-strong(AJX, trefs_t)
+-strong(AJX, tslices_t)
+-strong(AJX, tprio_t)
+-strong(AJX, cnt_t)
+-strong(AJX, ucnt_t)
+-strong(AJX, eventid_t)
+-strong(AJX, eventmask_t)
+-strong(AJX, eventflags_t)
+
/* Permitting anonymous unions.*/
+fan