diff options
Diffstat (limited to 'os/rt/src')
-rw-r--r-- | os/rt/src/chdebug.c | 6 | ||||
-rw-r--r-- | os/rt/src/chdynamic.c | 5 | ||||
-rw-r--r-- | os/rt/src/chqueues.c | 2 | ||||
-rw-r--r-- | os/rt/src/chregistry.c | 4 | ||||
-rw-r--r-- | os/rt/src/chschd.c | 43 | ||||
-rw-r--r-- | os/rt/src/chstats.c | 4 | ||||
-rw-r--r-- | os/rt/src/chsys.c | 42 | ||||
-rw-r--r-- | os/rt/src/chthreads.c | 2 | ||||
-rw-r--r-- | os/rt/src/chtm.c | 8 | ||||
-rw-r--r-- | os/rt/src/chvt.c | 29 |
10 files changed, 90 insertions, 55 deletions
diff --git a/os/rt/src/chdebug.c b/os/rt/src/chdebug.c index eef4128d0..a09f327b4 100644 --- a/os/rt/src/chdebug.c +++ b/os/rt/src/chdebug.c @@ -105,7 +105,7 @@ /* Module exported functions. */
/*===========================================================================*/
-#if CH_DBG_SYSTEM_STATE_CHECK || defined(__DOXYGEN__)
+#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
/**
* @brief Guard code for @p chSysDisable().
*
@@ -254,9 +254,9 @@ void chDbgCheckClassS(void) { }
}
-#endif /* CH_DBG_SYSTEM_STATE_CHECK */
+#endif /* CH_DBG_SYSTEM_STATE_CHECK == TRUE */
-#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
+#if (CH_DBG_ENABLE_TRACE == TRUE) || defined(__DOXYGEN__)
/**
* @brief Trace circular buffer subsystem initialization.
* @note Internal use only.
diff --git a/os/rt/src/chdynamic.c b/os/rt/src/chdynamic.c index 78a667966..9a0c33303 100644 --- a/os/rt/src/chdynamic.c +++ b/os/rt/src/chdynamic.c @@ -68,9 +68,10 @@ thread_t *chThdAddRef(thread_t *tp) {
chSysLock();
- chDbgAssert(tp->p_refs < 255, "too many references");
+ chDbgAssert(tp->p_refs < 255U, "too many references");
tp->p_refs++;
chSysUnlock();
+
return tp;
}
@@ -98,7 +99,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 == 0) && (tp->p_state == CH_STATE_FINAL)) {
+ if ((refs == 0U) && (tp->p_state == CH_STATE_FINAL)) {
switch (tp->p_flags & CH_FLAG_MODE_MASK) {
#if CH_CFG_USE_HEAP
case CH_FLAG_MODE_HEAP:
diff --git a/os/rt/src/chqueues.c b/os/rt/src/chqueues.c index 07f1ca230..f85cac9bc 100644 --- a/os/rt/src/chqueues.c +++ b/os/rt/src/chqueues.c @@ -295,7 +295,7 @@ void chOQResetI(output_queue_t *oqp) { chDbgCheckClassI();
oqp->q_rdptr = oqp->q_wrptr = oqp->q_buffer;
- oqp->q_counter = chQSizeI(oqp);
+ oqp->q_counter = QSIZE(oqp);
chThdDequeueAllI(&oqp->q_waiting, Q_RESET);
}
diff --git a/os/rt/src/chregistry.c b/os/rt/src/chregistry.c index 043fb1516..157d90d11 100644 --- a/os/rt/src/chregistry.c +++ b/os/rt/src/chregistry.c @@ -75,12 +75,12 @@ * OS signature in ROM plus debug-related information.
*/
ROMCONST chdebug_t ch_debug = {
- "main",
+ {'m', 'a', 'i', 'n'},
(uint8_t)0,
(uint8_t)sizeof (chdebug_t),
(uint16_t)((CH_KERNEL_MAJOR << 11) |
(CH_KERNEL_MINOR << 6) |
- (CH_KERNEL_PATCH) << 0),
+ (CH_KERNEL_PATCH << 0)),
(uint8_t)sizeof (void *),
(uint8_t)sizeof (systime_t),
(uint8_t)sizeof (thread_t),
diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index 2640f25e9..03d5259ed 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -66,12 +66,15 @@ void _scheduler_init(void) { queue_init(&ch.rlist.r_queue);
ch.rlist.r_prio = NOPRIO;
-#if CH_CFG_USE_REGISTRY
- ch.rlist.r_newer = ch.rlist.r_older = (thread_t *)&ch.rlist;
+#if CH_CFG_USE_REGISTRY == TRUE
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ ch.rlist.r_newer = (thread_t *)&ch.rlist;
+ ch.rlist.r_older = (thread_t *)&ch.rlist;
+ /*lint -restore*/
#endif
}
-#if !CH_CFG_OPTIMIZE_SPEED || defined(__DOXYGEN__)
+#if (CH_CFG_OPTIMIZE_SPEED == FALSE) || defined(__DOXYGEN__)
/**
* @brief Inserts a thread into a priority ordered queue.
* @note The insertion is done by scanning the list from the highest
@@ -224,14 +227,17 @@ thread_t *chSchReadyI(thread_t *tp) { "invalid state");
tp->p_state = CH_STATE_READY;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
cp = (thread_t *)&ch.rlist.r_queue;
+ /*lint -restore*/
do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);
/* Insertion on p_prev.*/
tp->p_next = cp;
tp->p_prev = cp->p_prev;
- tp->p_prev->p_next = cp->p_prev = tp;
+ tp->p_prev->p_next = tp;
+ cp->p_prev = tp;
return tp;
}
@@ -250,7 +256,8 @@ void chSchGoSleepS(tstate_t newstate) { chDbgCheckClassS();
- (otp = currp)->p_state = newstate;
+ otp = currp;
+ otp->p_state = 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.*/
@@ -270,7 +277,9 @@ void chSchGoSleepS(tstate_t newstate) { * Timeout wakeup callback.
*/
static void wakeup(void *p) {
+ /*lint -save -e9087 [11.3] The real type is hidden but correct.*/
thread_t *tp = (thread_t *)p;
+ /*lint -restore*/
chSysLockFromISR();
switch (tp->p_state) {
@@ -282,20 +291,24 @@ static void wakeup(void *p) { case CH_STATE_SUSPENDED:
*(thread_reference_t *)tp->p_u.wtobjp = NULL;
break;
-#if CH_CFG_USE_SEMAPHORES
+#if CH_CFG_USE_SEMAPHORES == TRUE
case CH_STATE_WTSEM:
chSemFastSignalI((semaphore_t *)tp->p_u.wtobjp);
/* Falls into, intentional. */
#endif
-#if CH_CFG_USE_CONDVARS && CH_CFG_USE_CONDVARS_TIMEOUT
+#if (CH_CFG_USE_CONDVARS == TRUE) && (CH_CFG_USE_CONDVARS_TIMEOUT == TRUE)
case CH_STATE_WTCOND:
#endif
case CH_STATE_QUEUED:
/* States requiring dequeuing.*/
- queue_dequeue(tp);
+ (void) queue_dequeue(tp);
+ break;
+ default:
+ chDbgAssert(false, "unexpected state");
+ break;
}
tp->p_u.rdymsg = MSG_TIMEOUT;
- chSchReadyI(tp);
+ (void) chSchReadyI(tp);
chSysUnlockFromISR();
}
@@ -329,8 +342,9 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { chVTDoSetI(&vt, time, wakeup, currp);
chSchGoSleepS(newstate);
- if (chVTIsArmedI(&vt))
+ if (chVTIsArmedI(&vt)) {
chVTDoResetI(&vt);
+ }
}
else {
chSchGoSleepS(newstate);
@@ -369,7 +383,7 @@ void chSchWakeupS(thread_t *ntp, msg_t msg) { running immediately and the invoking thread goes in the ready
list instead.*/
if (ntp->p_prio <= currp->p_prio) {
- chSchReadyI(ntp);
+ (void) chSchReadyI(ntp);
}
else {
thread_t *otp = chSchReadyI(currp);
@@ -455,7 +469,7 @@ void chSchDoRescheduleBehind(void) { #if CH_CFG_TIME_QUANTUM > 0
otp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
- chSchReadyI(otp);
+ (void) chSchReadyI(otp);
chSysSwitch(currp, otp);
}
@@ -482,14 +496,17 @@ void chSchDoRescheduleAhead(void) { currp->p_state = CH_STATE_CURRENT;
otp->p_state = CH_STATE_READY;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
cp = (thread_t *)&ch.rlist.r_queue;
+ /*lint -restore*/
do {
cp = cp->p_next;
} while (cp->p_prio > otp->p_prio);
/* Insertion on p_prev.*/
otp->p_next = cp;
otp->p_prev = cp->p_prev;
- otp->p_prev->p_next = cp->p_prev = otp;
+ otp->p_prev->p_next = otp;
+ cp->p_prev = otp;
chSysSwitch(currp, otp);
}
diff --git a/os/rt/src/chstats.c b/os/rt/src/chstats.c index fc695d0fe..fbd28f44a 100644 --- a/os/rt/src/chstats.c +++ b/os/rt/src/chstats.c @@ -28,7 +28,7 @@ #include "ch.h"
-#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -119,6 +119,6 @@ void _stats_stop_measure_crit_isr(void) { chTMStopMeasurementX(&ch.kernel_stats.m_crit_isr);
}
-#endif /* CH_DBG_STATISTICS */
+#endif /* CH_DBG_STATISTICS == TRUE */
/** @} */
diff --git a/os/rt/src/chsys.c b/os/rt/src/chsys.c index 7823409f3..4e2102b89 100644 --- a/os/rt/src/chsys.c +++ b/os/rt/src/chsys.c @@ -51,7 +51,7 @@ /* Module local functions. */
/*===========================================================================*/
-#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
+#if (CH_CFG_NO_IDLE_THREAD == FALSE) || defined(__DOXYGEN__)
/**
* @brief This function implements the idle thread infinite loop.
* @details The function puts the processor in the lowest power mode capable
@@ -67,11 +67,14 @@ static void _idle_thread(void *p) { (void)p;
chRegSetThreadName("idle");
while (true) {
+ /*lint -save -e522 [2.2] Apparently no side effects because it contains
+ an asm instruction.*/
port_wait_for_interrupt();
+ /*lint -restore*/
CH_CFG_IDLE_LOOP_HOOK();
}
}
-#endif /* CH_CFG_NO_IDLE_THREAD */
+#endif /* CH_CFG_NO_IDLE_THREAD == FALSE */
/*===========================================================================*/
/* Module exported functions. */
@@ -88,30 +91,30 @@ static void _idle_thread(void *p) { * @special
*/
void chSysInit(void) {
-#if CH_DBG_ENABLE_STACK_CHECK
+#if CH_DBG_ENABLE_STACK_CHECK == TRUE
extern stkalign_t __main_thread_stack_base__;
#endif
port_init();
_scheduler_init();
_vt_init();
-#if CH_CFG_USE_TM
+#if CH_CFG_USE_TM == TRUE
_tm_init();
#endif
-#if CH_CFG_USE_MEMCORE
+#if CH_CFG_USE_MEMCORE == TRUE
_core_init();
#endif
-#if CH_CFG_USE_HEAP
+#if CH_CFG_USE_HEAP == TRUE
_heap_init();
#endif
-#if CH_DBG_STATISTICS
+#if CH_DBG_STATISTICS == TRUE
_stats_init();
#endif
-#if CH_DBG_ENABLE_TRACE
+#if CH_DBG_ENABLE_TRACE == TRUE
_dbg_trace_init();
#endif
-#if !CH_CFG_NO_IDLE_THREAD
+#if CH_CFG_NO_IDLE_THREAD == FALSE
/* Now this instructions flow becomes the main thread.*/
setcurrp(_thread_init(&ch.mainthread, NORMALPRIO));
#else
@@ -120,7 +123,7 @@ void chSysInit(void) { #endif
currp->p_state = CH_STATE_CURRENT;
-#if CH_DBG_ENABLE_STACK_CHECK
+#if CH_DBG_ENABLE_STACK_CHECK == TRUE
/* This is a special case because the main thread thread_t structure is not
adjacent to its stack area.*/
currp->p_stklimit = &__main_thread_stack_base__;
@@ -131,12 +134,15 @@ void chSysInit(void) { active, else the parameter is ignored.*/
chRegSetThreadName((const char *)&ch_debug);
-#if !CH_CFG_NO_IDLE_THREAD
+#if CH_CFG_NO_IDLE_THREAD == FALSE
/* This thread has the lowest priority in the system, its role is just to
serve interrupts in its context while keeping the lowest energy saving
mode compatible with the system status.*/
- chThdCreateStatic(ch.idle_thread_wa, sizeof(ch.idle_thread_wa), IDLEPRIO,
- (tfunc_t)_idle_thread, NULL);
+ /*lint -save -e9074 -e9087 [11.3, 11.1] The idle thread returns void because
+ an optimization.*/
+ (void) chThdCreateStatic(ch.idle_thread_wa, sizeof(ch.idle_thread_wa),
+ IDLEPRIO, (tfunc_t)_idle_thread, NULL);
+ /*lint -restore*/
#endif
}
@@ -189,7 +195,7 @@ void chSysTimerHandlerI(void) { /* Decrement remaining quantum.*/
currp->p_preempt--;
#endif
-#if CH_DBG_THREADS_PROFILING
+#if CH_DBG_THREADS_PROFILING == TRUE
currp->p_time++;
#endif
chVTDoTickI();
@@ -247,7 +253,7 @@ void chSysRestoreStatusX(syssts_t sts) { }
}
-#if PORT_SUPPORTS_RT || defined(__DOXYGEN__)
+#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Realtime window test.
* @details This function verifies if the current realtime counter value
@@ -268,8 +274,8 @@ void chSysRestoreStatusX(syssts_t sts) { */
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end) {
- return end > start ? (cnt >= start) && (cnt < end) :
- (cnt >= start) || (cnt < end);
+ return (end > start) ? ((cnt >= start) && (cnt < end)) :
+ ((cnt >= start) || (cnt < end));
}
/**
@@ -290,6 +296,6 @@ void chSysPolledDelayX(rtcnt_t cycles) { while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
}
}
-#endif /* PORT_SUPPORTS_RT */
+#endif /* PORT_SUPPORTS_RT == TRUE */
/** @} */
diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c index 12d045a84..16a80aaab 100644 --- a/os/rt/src/chthreads.c +++ b/os/rt/src/chthreads.c @@ -571,7 +571,7 @@ void chThdResumeI(thread_reference_t *trp, msg_t msg) { *trp = NULL;
tp->p_u.rdymsg = msg;
- chSchReadyI(tp);
+ (void) chSchReadyI(tp);
}
}
diff --git a/os/rt/src/chtm.c b/os/rt/src/chtm.c index 9d95bd987..07f365114 100644 --- a/os/rt/src/chtm.c +++ b/os/rt/src/chtm.c @@ -28,7 +28,7 @@ #include "ch.h"
-#if CH_CFG_USE_TM || defined(__DOXYGEN__)
+#if (CH_CFG_USE_TM == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module local definitions. */
@@ -55,14 +55,16 @@ static inline void tm_stop(time_measurement_t *tmp, rtcnt_t offset) {
tmp->n++;
- tmp->last = now - tmp->last - offset;
+ tmp->last = (now - tmp->last) - offset;
tmp->cumulative += (rttime_t)tmp->last;
+ /*lint -save -e9013 [15.7] There is no else because it is not needed.*/
if (tmp->last > tmp->worst) {
tmp->worst = tmp->last;
}
else if (tmp->last < tmp->best) {
tmp->best = tmp->last;
}
+ /*lint -restore*/
}
/*===========================================================================*/
@@ -151,6 +153,6 @@ NOINLINE void chTMChainMeasurementToX(time_measurement_t *tmp1, tm_stop(tmp1, tmp2->last, 0);
}
-#endif /* CH_CFG_USE_TM */
+#endif /* CH_CFG_USE_TM == TRUE */
/** @} */
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c index 68ef9b861..de50a4ae5 100644 --- a/os/rt/src/chvt.c +++ b/os/rt/src/chvt.c @@ -60,7 +60,10 @@ */
void _vt_init(void) {
- ch.vtlist.vt_next = ch.vtlist.vt_prev = (void *)&ch.vtlist;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ ch.vtlist.vt_next = (virtual_timer_t *)&ch.vtlist;
+ ch.vtlist.vt_prev = (virtual_timer_t *)&ch.vtlist;
+ /*lint -restore*/
ch.vtlist.vt_delta = (systime_t)-1;
#if CH_CFG_ST_TIMEDELTA == 0
ch.vtlist.vt_systime = 0;
@@ -102,17 +105,19 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay, vtp->vt_func = vtfunc;
p = ch.vtlist.vt_next;
-#if CH_CFG_ST_TIMEDELTA > 0 || defined(__DOXYGEN__)
+#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
{
systime_t now = port_timer_get_time();
/* If the requested delay is lower than the minimum safe delta then it
is raised to the minimum safe value.*/
- if (delay < CH_CFG_ST_TIMEDELTA) {
- delay = CH_CFG_ST_TIMEDELTA;
+ if (delay < (systime_t)CH_CFG_ST_TIMEDELTA) {
+ delay = (systime_t)CH_CFG_ST_TIMEDELTA;
}
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
if (&ch.vtlist == (virtual_timers_list_t *)p) {
+ /*lint -restore*/
/* The delta list is empty, the current time becomes the new
delta list base time.*/
ch.vtlist.vt_lasttime = now;
@@ -140,8 +145,10 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay, }
/* The timer is inserted in the delta list.*/
- vtp->vt_prev = (vtp->vt_next = p)->vt_prev;
- vtp->vt_prev->vt_next = p->vt_prev = vtp;
+ vtp->vt_next = p;
+ vtp->vt_prev = vtp->vt_next->vt_prev;
+ vtp->vt_prev->vt_next = vtp;
+ p->vt_prev = vtp;
vtp->vt_delta = delay
/* Special case when the timer is in last position in the list, the
@@ -168,28 +175,30 @@ void chVTDoResetI(virtual_timer_t *vtp) { vtp->vt_next->vt_delta += vtp->vt_delta;
vtp->vt_prev->vt_next = vtp->vt_next;
vtp->vt_next->vt_prev = vtp->vt_prev;
- vtp->vt_func = (vtfunc_t)NULL;
+ vtp->vt_func = NULL;
/* The above code changes the value in the header when the removed element
is the last of the list, restoring it.*/
ch.vtlist.vt_delta = (systime_t)-1;
-#if CH_CFG_ST_TIMEDELTA > 0 || defined(__DOXYGEN__)
+#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
{
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
if (&ch.vtlist == (virtual_timers_list_t *)ch.vtlist.vt_next) {
+ /*lint -restore*/
/* Just removed the last element in the list, alarm timer stopped.*/
port_timer_stop_alarm();
}
else {
/* Updating the alarm to the next deadline, deadline that must not be
closer in time than the minimum time delta.*/
- if (ch.vtlist.vt_next->vt_delta >= CH_CFG_ST_TIMEDELTA) {
+ if (ch.vtlist.vt_next->vt_delta >= (systime_t)CH_CFG_ST_TIMEDELTA) {
port_timer_set_alarm(ch.vtlist.vt_lasttime +
ch.vtlist.vt_next->vt_delta);
}
else {
port_timer_set_alarm(ch.vtlist.vt_lasttime +
- CH_CFG_ST_TIMEDELTA);
+ (systime_t)CH_CFG_ST_TIMEDELTA);
}
}
}
|