aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-03-05 21:28:51 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-03-05 21:28:51 +0000
commitb53489d0e4252aafe5ada7466e0b3b7c4ad5aaaf (patch)
tree2efd9ba0b52dfed9daefb6eb4d6b86b073776a21 /os/rt/include
parent880d6916b3fb25b3972ed78b380db630524623e7 (diff)
downloadChibiOS-b53489d0e4252aafe5ada7466e0b3b7c4ad5aaaf.tar.gz
ChibiOS-b53489d0e4252aafe5ada7466e0b3b7c4ad5aaaf.tar.bz2
ChibiOS-b53489d0e4252aafe5ada7466e0b3b7c4ad5aaaf.zip
Lots of MISRA-related changes in RT. Not finished yet.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7715 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/include')
-rw-r--r--os/rt/include/chbsem.h12
-rw-r--r--os/rt/include/chcond.h8
-rw-r--r--os/rt/include/chdebug.h28
-rw-r--r--os/rt/include/chdynamic.h12
-rw-r--r--os/rt/include/chevents.h22
-rw-r--r--os/rt/include/chheap.h10
-rw-r--r--os/rt/include/chmboxes.h9
-rw-r--r--os/rt/include/chmemcore.h8
-rw-r--r--os/rt/include/chmempools.h6
-rw-r--r--os/rt/include/chmsg.h6
-rw-r--r--os/rt/include/chmtx.h8
-rw-r--r--os/rt/include/chqueues.h26
-rw-r--r--os/rt/include/chregistry.h8
-rw-r--r--os/rt/include/chschd.h146
-rw-r--r--os/rt/include/chsem.h4
-rw-r--r--os/rt/include/chstats.h8
-rw-r--r--os/rt/include/chsys.h6
-rw-r--r--os/rt/include/chsystypes.h2
-rw-r--r--os/rt/include/chthreads.h14
-rw-r--r--os/rt/include/chtm.h6
-rw-r--r--os/rt/include/chvt.h17
21 files changed, 210 insertions, 156 deletions
diff --git a/os/rt/include/chbsem.h b/os/rt/include/chbsem.h
index ca79665ba..96d1ca2fb 100644
--- a/os/rt/include/chbsem.h
+++ b/os/rt/include/chbsem.h
@@ -49,7 +49,7 @@
#ifndef _CHBSEM_H_
#define _CHBSEM_H_
-#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -123,7 +123,7 @@ typedef struct {
*/
static inline void chBSemObjectInit(binary_semaphore_t *bsp, bool taken) {
- chSemObjectInit(&bsp->bs_sem, taken ? 0 : 1);
+ chSemObjectInit(&bsp->bs_sem, taken ? (cnt_t)0 : (cnt_t)1);
}
/**
@@ -233,7 +233,7 @@ static inline void chBSemResetI(binary_semaphore_t *bsp, bool taken) {
chDbgCheckClassI();
- chSemResetI(&bsp->bs_sem, taken ? 0 : 1);
+ chSemResetI(&bsp->bs_sem, taken ? (cnt_t)0 : (cnt_t)1);
}
/**
@@ -252,7 +252,7 @@ static inline void chBSemResetI(binary_semaphore_t *bsp, bool taken) {
*/
static inline void chBSemReset(binary_semaphore_t *bsp, bool taken) {
- chSemReset(&bsp->bs_sem, taken ? 0 : 1);
+ chSemReset(&bsp->bs_sem, taken ? (cnt_t)0 : (cnt_t)1);
}
/**
@@ -301,10 +301,10 @@ static inline bool chBSemGetStateI(binary_semaphore_t *bsp) {
chDbgCheckClassI();
- return bsp->bs_sem.s_cnt > 0 ? false : true;
+ return (bsp->bs_sem.s_cnt > 0) ? false : true;
}
-#endif /* CH_CFG_USE_SEMAPHORES */
+#endif /* CH_CFG_USE_SEMAPHORES == TRUE */
#endif /* _CHBSEM_H_ */
diff --git a/os/rt/include/chcond.h b/os/rt/include/chcond.h
index e8759b8f8..e8620e9c5 100644
--- a/os/rt/include/chcond.h
+++ b/os/rt/include/chcond.h
@@ -31,7 +31,7 @@
#ifndef _CHCOND_H_
#define _CHCOND_H_
-#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_CONDVARS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -45,7 +45,7 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !CH_CFG_USE_MUTEXES
+#if CH_CFG_USE_MUTEXES == FALSE
#error "CH_CFG_USE_CONDVARS requires CH_CFG_USE_MUTEXES"
#endif
@@ -97,7 +97,7 @@ extern "C" {
void chCondBroadcastI(condition_variable_t *cp);
msg_t chCondWait(condition_variable_t *cp);
msg_t chCondWaitS(condition_variable_t *cp);
-#if CH_CFG_USE_CONDVARS_TIMEOUT
+#if CH_CFG_USE_CONDVARS_TIMEOUT == TRUE
msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time);
msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time);
#endif
@@ -109,7 +109,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#endif /* CH_CFG_USE_CONDVARS */
+#endif /* CH_CFG_USE_CONDVARS == TRUE */
#endif /* _CHCOND_H_ */
diff --git a/os/rt/include/chdebug.h b/os/rt/include/chdebug.h
index 728d9bf35..2e4b846f3 100644
--- a/os/rt/include/chdebug.h
+++ b/os/rt/include/chdebug.h
@@ -74,7 +74,7 @@
/* Module data structures and types. */
/*===========================================================================*/
-#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
+#if (CH_DBG_ENABLE_TRACE == TRUE) || defined(__DOXYGEN__)
/**
* @brief Trace buffer record.
*/
@@ -120,14 +120,14 @@ typedef struct {
/* Module macros. */
/*===========================================================================*/
-#if CH_DBG_SYSTEM_STATE_CHECK
+#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
#define _dbg_enter_lock() (ch.dbg.lock_cnt = 1)
#define _dbg_leave_lock() (ch.dbg.lock_cnt = 0)
#endif
/* When the state checker feature is disabled then the following functions
are replaced by an empty macro.*/
-#if !CH_DBG_SYSTEM_STATE_CHECK
+#if CH_DBG_SYSTEM_STATE_CHECK == FALSE
#define _dbg_enter_lock()
#define _dbg_leave_lock()
#define _dbg_check_disable()
@@ -145,7 +145,7 @@ typedef struct {
/* When the trace feature is disabled this function is replaced by an empty
macro.*/
-#if !CH_DBG_ENABLE_TRACE
+#if CH_DBG_ENABLE_TRACE == FALSE
#define _dbg_trace(otp)
#endif
@@ -164,11 +164,15 @@ typedef struct {
* @api
*/
#if !defined(chDbgCheck)
+#if CH_DBG_ENABLE_CHECKS
#define chDbgCheck(c) do { \
- if (CH_DBG_ENABLE_CHECKS && !(c)) { \
+ if (!(c)) { \
chSysHalt(__func__); \
} \
-} while (0)
+} while (false)
+#else
+#define chDbgCheck(c)
+#endif
#endif /* !defined(chDbgCheck) */
/**
@@ -186,11 +190,15 @@ typedef struct {
* @api
*/
#if !defined(chDbgAssert)
+#if CH_DBG_ENABLE_ASSERTS == TRUE
#define chDbgAssert(c, r) do { \
- if (CH_DBG_ENABLE_ASSERTS && !(c)) { \
+ if (!(c)) { \
chSysHalt(__func__); \
} \
-} while (0)
+} while (false)
+#else
+#define chDbgAssert(c, r)
+#endif
#endif /* !defined(chDbgAssert) */
/** @} */
@@ -201,7 +209,7 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
-#if CH_DBG_SYSTEM_STATE_CHECK
+#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
void _dbg_check_disable(void);
void _dbg_check_suspend(void);
void _dbg_check_enable(void);
@@ -214,7 +222,7 @@ extern "C" {
void chDbgCheckClassI(void);
void chDbgCheckClassS(void);
#endif
-#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
+#if (CH_DBG_ENABLE_TRACE == TRUE) || defined(__DOXYGEN__)
void _dbg_trace_init(void);
void _dbg_trace(thread_t *otp);
#endif
diff --git a/os/rt/include/chdynamic.h b/os/rt/include/chdynamic.h
index 7a2e0c581..66f3232c0 100644
--- a/os/rt/include/chdynamic.h
+++ b/os/rt/include/chdynamic.h
@@ -28,7 +28,7 @@
#ifndef _CHDYNAMIC_H_
#define _CHDYNAMIC_H_
-#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
+#if (CH_CFG_USE_DYNAMIC == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -45,11 +45,11 @@
/*
* Module dependencies check.
*/
-#if CH_CFG_USE_DYNAMIC && !CH_CFG_USE_WAITEXIT
+#if CH_CFG_USE_WAITEXIT == FALSE
#error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_WAITEXIT"
#endif
-#if CH_CFG_USE_DYNAMIC && !CH_CFG_USE_HEAP && !CH_CFG_USE_MEMPOOLS
+#if (CH_CFG_USE_HEAP == FALSE) && (CH_CFG_USE_MEMPOOLS == FALSE)
#error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_HEAP and/or CH_CFG_USE_MEMPOOLS"
#endif
@@ -73,11 +73,11 @@ extern "C" {
#endif
thread_t *chThdAddRef(thread_t *tp);
void chThdRelease(thread_t *tp);
-#if CH_CFG_USE_HEAP
+#if CH_CFG_USE_HEAP == TRUE
thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg);
#endif
-#if CH_CFG_USE_MEMPOOLS
+#if CH_CFG_USE_MEMPOOLS == TRUE
thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
tfunc_t pf, void *arg);
#endif
@@ -89,7 +89,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#endif /* CH_CFG_USE_DYNAMIC */
+#endif /* CH_CFG_USE_DYNAMIC == TRUE */
#endif /* _CHDYNAMIC_H_ */
diff --git a/os/rt/include/chevents.h b/os/rt/include/chevents.h
index e7c91d669..9e06f897c 100644
--- a/os/rt/include/chevents.h
+++ b/os/rt/include/chevents.h
@@ -31,7 +31,7 @@
#ifndef _CHEVENTS_H_
#define _CHEVENTS_H_
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -80,7 +80,7 @@ typedef struct event_source {
/**
* @brief Event Handler callback function.
*/
-typedef void (*evhandler_t)(eventid_t);
+typedef void (*evhandler_t)(eventid_t id);
/*===========================================================================*/
/* Module macros. */
@@ -94,7 +94,7 @@ typedef void (*evhandler_t)(eventid_t);
/**
* @brief Returns an event mask from an event identifier.
*/
-#define EVENT_MASK(eid) ((eventmask_t)(1 << (eid)))
+#define EVENT_MASK(eid) ((eventmask_t)1 << (eventmask_t)(eid))
/**
* @brief Data part of a static event source initializer.
@@ -134,12 +134,12 @@ extern "C" {
void chEvtBroadcastFlags(event_source_t *esp, eventflags_t flags);
void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags);
void chEvtDispatch(const evhandler_t *handlers, eventmask_t events);
-#if CH_CFG_OPTIMIZE_SPEED || !CH_CFG_USE_EVENTS_TIMEOUT
+#if (CH_CFG_OPTIMIZE_SPEED == TRUE) || (CH_CFG_USE_EVENTS_TIMEOUT == FALSE)
eventmask_t chEvtWaitOne(eventmask_t events);
eventmask_t chEvtWaitAny(eventmask_t events);
eventmask_t chEvtWaitAll(eventmask_t events);
#endif
-#if CH_CFG_USE_EVENTS_TIMEOUT
+#if CH_CFG_USE_EVENTS_TIMEOUT == TRUE
eventmask_t chEvtWaitOneTimeout(eventmask_t events, systime_t time);
eventmask_t chEvtWaitAnyTimeout(eventmask_t events, systime_t time);
eventmask_t chEvtWaitAllTimeout(eventmask_t events, systime_t time);
@@ -148,7 +148,7 @@ extern "C" {
}
#endif
-#if !CH_CFG_OPTIMIZE_SPEED && CH_CFG_USE_EVENTS_TIMEOUT
+#if (CH_CFG_OPTIMIZE_SPEED == FALSE) && (CH_CFG_USE_EVENTS_TIMEOUT == TRUE)
#define chEvtWaitOne(mask) chEvtWaitOneTimeout(mask, TIME_INFINITE)
#define chEvtWaitAny(mask) chEvtWaitAnyTimeout(mask, TIME_INFINITE)
#define chEvtWaitAll(mask) chEvtWaitAllTimeout(mask, TIME_INFINITE)
@@ -169,7 +169,9 @@ extern "C" {
*/
static inline void chEvtObjectInit(event_source_t *esp) {
- esp->es_next = (event_listener_t *)(void *)esp;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ esp->es_next = (event_listener_t *)esp;
+ /*lint -restore*/
}
/**
@@ -223,7 +225,9 @@ static inline void chEvtRegister(event_source_t *esp,
*/
static inline bool chEvtIsListeningI(event_source_t *esp) {
- return (bool)((void *)esp != (void *)esp->es_next);
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ return (bool)(esp != (event_source_t *)esp->es_next);
+ /*lint -restore*/
}
/**
@@ -256,7 +260,7 @@ static inline void chEvtBroadcastI(event_source_t *esp) {
chEvtBroadcastFlagsI(esp, 0);
}
-#endif /* CH_CFG_USE_EVENTS */
+#endif /* CH_CFG_USE_EVENTS == TRUE */
#endif /* _CHEVENTS_H_ */
diff --git a/os/rt/include/chheap.h b/os/rt/include/chheap.h
index e8baae9a7..b041646b5 100644
--- a/os/rt/include/chheap.h
+++ b/os/rt/include/chheap.h
@@ -28,7 +28,7 @@
#ifndef _CHHEAP_H_
#define _CHHEAP_H_
-#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
+#if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -42,11 +42,11 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !CH_CFG_USE_MEMCORE
+#if CH_CFG_USE_MEMCORE == FALSE
#error "CH_CFG_USE_HEAP requires CH_CFG_USE_MEMCORE"
#endif
-#if !CH_CFG_USE_MUTEXES && !CH_CFG_USE_SEMAPHORES
+#if (CH_CFG_USE_MUTEXES == FALSE) && (CH_CFG_USE_SEMAPHORES == FALSE)
#error "CH_CFG_USE_HEAP requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES"
#endif
@@ -80,7 +80,7 @@ struct memory_heap {
memgetfunc_t h_provider; /**< @brief Memory blocks provider for
this heap. */
union heap_header h_free; /**< @brief Free blocks list header. */
-#if CH_CFG_USE_MUTEXES
+#if CH_CFG_USE_MUTEXES == TRUE
mutex_t h_mtx; /**< @brief Heap access mutex. */
#else
semaphore_t h_sem; /**< @brief Heap access semaphore. */
@@ -111,7 +111,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#endif /* CH_CFG_USE_HEAP */
+#endif /* CH_CFG_USE_HEAP == TRUE */
#endif /* _CHHEAP_H_ */
diff --git a/os/rt/include/chmboxes.h b/os/rt/include/chmboxes.h
index 5a2f964fa..6cf12abb5 100644
--- a/os/rt/include/chmboxes.h
+++ b/os/rt/include/chmboxes.h
@@ -28,7 +28,7 @@
#ifndef _CHMBOXES_H_
#define _CHMBOXES_H_
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MAILBOXES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -42,7 +42,7 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !CH_CFG_USE_SEMAPHORES
+#if CH_CFG_USE_SEMAPHORES == FALSE
#error "CH_CFG_USE_MAILBOXES requires CH_CFG_USE_SEMAPHORES"
#endif
@@ -137,7 +137,10 @@ extern "C" {
*/
static inline size_t chMBGetSizeI(mailbox_t *mbp) {
+ /*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe pointers
+ arithmetic.*/
return (size_t)(mbp->mb_top - mbp->mb_buffer);
+ /*lint -restore*/
}
/**
@@ -197,7 +200,7 @@ static inline msg_t chMBPeekI(mailbox_t *mbp) {
return *mbp->mb_rdptr;
}
-#endif /* CH_CFG_USE_MAILBOXES */
+#endif /* CH_CFG_USE_MAILBOXES == TRUE */
#endif /* _CHMBOXES_H_ */
diff --git a/os/rt/include/chmemcore.h b/os/rt/include/chmemcore.h
index fde35415d..33bafe072 100644
--- a/os/rt/include/chmemcore.h
+++ b/os/rt/include/chmemcore.h
@@ -28,7 +28,7 @@
#ifndef _CHMEMCORE_H_
#define _CHMEMCORE_H_
-#if CH_CFG_USE_MEMCORE || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MEMCORE == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -68,7 +68,7 @@ typedef void *(*memgetfunc_t)(size_t size);
/**
* @brief Alignment mask constant.
*/
-#define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1)
+#define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1U)
/**
* @brief Alignment helper macro.
@@ -84,7 +84,7 @@ typedef void *(*memgetfunc_t)(size_t size);
* @brief Returns whatever a pointer or memory size is aligned to
* the type @p align_t.
*/
-#define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0)
+#define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0U)
/** @} */
/*===========================================================================*/
@@ -106,7 +106,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#endif /* CH_CFG_USE_MEMCORE */
+#endif /* CH_CFG_USE_MEMCORE == TRUE */
#endif /* _CHMEMCORE_H_ */
diff --git a/os/rt/include/chmempools.h b/os/rt/include/chmempools.h
index e1ee0d1a5..3e363f86d 100644
--- a/os/rt/include/chmempools.h
+++ b/os/rt/include/chmempools.h
@@ -28,7 +28,7 @@
#ifndef _CHMEMPOOLS_H_
#define _CHMEMPOOLS_H_
-#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MEMPOOLS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -42,7 +42,7 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !CH_CFG_USE_MEMCORE
+#if CH_CFG_USE_MEMCORE == FALSE
#error "CH_CFG_USE_MEMPOOLS requires CH_CFG_USE_MEMCORE"
#endif
@@ -161,7 +161,7 @@ static inline void chPoolAddI(memory_pool_t *mp, void *objp) {
chPoolFreeI(mp, objp);
}
-#endif /* CH_CFG_USE_MEMPOOLS */
+#endif /* CH_CFG_USE_MEMPOOLS == TRUE */
#endif /* _CHMEMPOOLS_H_ */
diff --git a/os/rt/include/chmsg.h b/os/rt/include/chmsg.h
index f8b2db17d..0420562c3 100644
--- a/os/rt/include/chmsg.h
+++ b/os/rt/include/chmsg.h
@@ -28,7 +28,7 @@
#ifndef _CHMSG_H_
#define _CHMSG_H_
-#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -80,7 +80,9 @@ static inline bool chMsgIsPendingI(thread_t *tp) {
chDbgCheckClassI();
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
return (bool)(tp->p_msgqueue.p_next != (thread_t *)&tp->p_msgqueue);
+ /*lint -restore*/
}
/**
@@ -115,7 +117,7 @@ static inline void chMsgReleaseS(thread_t *tp, msg_t msg) {
chSchWakeupS(tp, msg);
}
-#endif /* CH_CFG_USE_MESSAGES */
+#endif /* CH_CFG_USE_MESSAGES == TRUE */
#endif /* _CHMSG_H_ */
diff --git a/os/rt/include/chmtx.h b/os/rt/include/chmtx.h
index 60e05e851..4a4b643ff 100644
--- a/os/rt/include/chmtx.h
+++ b/os/rt/include/chmtx.h
@@ -28,7 +28,7 @@
#ifndef _CHMTX_H_
#define _CHMTX_H_
-#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -61,7 +61,7 @@ struct mutex {
@p NULL. */
mutex_t *m_next; /**< @brief Next @p mutex_t into an
owner-list or @p NULL. */
-#if CH_CFG_USE_MUTEXES_RECURSIVE || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MUTEXES_RECURSIVE == TRUE) || defined(__DOXYGEN__)
cnt_t m_cnt; /**< @brief Mutex recursion counter. */
#endif
};
@@ -77,7 +77,7 @@ struct mutex {
*
* @param[in] name the name of the mutex variable
*/
-#if CH_CFG_USE_MUTEXES_RECURSIVE || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MUTEXES_RECURSIVE == TRUE) || defined(__DOXYGEN__)
#define _MUTEX_DATA(name) {_THREADS_QUEUE_DATA(name.m_queue), NULL, NULL, 0}
#else
#define _MUTEX_DATA(name) {_THREADS_QUEUE_DATA(name.m_queue), NULL, NULL}
@@ -146,7 +146,7 @@ static inline mutex_t *chMtxGetNextMutexS(void) {
return chThdGetSelfX()->p_mtxlist;
}
-#endif /* CH_CFG_USE_MUTEXES */
+#endif /* CH_CFG_USE_MUTEXES == TRUE */
#endif /* _CHMTX_H_ */
diff --git a/os/rt/include/chqueues.h b/os/rt/include/chqueues.h
index fbebc81e7..ea93708f4 100644
--- a/os/rt/include/chqueues.h
+++ b/os/rt/include/chqueues.h
@@ -28,7 +28,7 @@
#ifndef _CHQUEUES_H_
#define _CHQUEUES_H_
-#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_QUEUES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -198,9 +198,9 @@ typedef io_queue_t output_queue_t;
* @param[in] qp pointer to a @p io_queue_t structure.
* @return The buffer size.
*
- * @iclass
+ * @notapi
*/
-#define chQSizeI(qp) ((size_t)((qp)->q_top - (qp)->q_buffer))
+#define QSIZE(qp) ((size_t)((qp)->q_top - (qp)->q_buffer))
/**
* @brief Queue space.
@@ -284,7 +284,10 @@ static inline size_t chIQGetEmptyI(input_queue_t *iqp) {
chDbgCheckClassI();
- return (size_t)(chQSizeI(iqp) - chQSpaceI(iqp));
+ /*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe pointers
+ arithmetic in QSIZE().*/
+ return (size_t)(QSIZE(iqp) - chQSpaceI(iqp));
+ /*lint -restore*/
}
/**
@@ -301,7 +304,7 @@ static inline bool chIQIsEmptyI(input_queue_t *iqp) {
chDbgCheckClassI();
- return (bool)(chQSpaceI(iqp) <= 0);
+ return (bool)(chQSpaceI(iqp) <= 0U);
}
/**
@@ -318,7 +321,7 @@ static inline bool chIQIsFullI(input_queue_t *iqp) {
chDbgCheckClassI();
- return (bool)((iqp->q_wrptr == iqp->q_rdptr) && (iqp->q_counter != 0));
+ return (bool)((iqp->q_wrptr == iqp->q_rdptr) && (iqp->q_counter != 0U));
}
/**
@@ -351,7 +354,10 @@ static inline size_t chOQGetFullI(output_queue_t *oqp) {
chDbgCheckClassI();
- return (size_t)(chQSizeI(oqp) - chQSpaceI(oqp));
+ /*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe pointers
+ arithmetic in QSIZE().*/
+ return (size_t)(QSIZE(oqp) - chQSpaceI(oqp));
+ /*lint -restore*/
}
/**
@@ -384,7 +390,7 @@ static inline bool chOQIsEmptyI(output_queue_t *oqp) {
chDbgCheckClassI();
- return (bool)((oqp->q_wrptr == oqp->q_rdptr) && (oqp->q_counter != 0));
+ return (bool)((oqp->q_wrptr == oqp->q_rdptr) && (oqp->q_counter != 0U));
}
/**
@@ -401,7 +407,7 @@ static inline bool chOQIsFullI(output_queue_t *oqp) {
chDbgCheckClassI();
- return (bool)(chQSpaceI(oqp) <= 0);
+ return (bool)(chQSpaceI(oqp) <= 0U);
}
/**
@@ -423,7 +429,7 @@ static inline msg_t chOQPut(output_queue_t *oqp, uint8_t b) {
return chOQPutTimeout(oqp, b, TIME_INFINITE);
}
-#endif /* CH_CFG_USE_QUEUES */
+#endif /* CH_CFG_USE_QUEUES == TRUE */
#endif /* _CHQUEUES_H_ */
diff --git a/os/rt/include/chregistry.h b/os/rt/include/chregistry.h
index b1bcb15b7..002f67d8b 100644
--- a/os/rt/include/chregistry.h
+++ b/os/rt/include/chregistry.h
@@ -28,7 +28,7 @@
#ifndef _CHREGISTRY_H_
#define _CHREGISTRY_H_
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -95,7 +95,7 @@ typedef struct {
#define chRegSetThreadName(p)
#endif /* !CH_CFG_USE_REGISTRY */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
/**
* @brief Removes a thread from the registry list.
* @note This macro is not meant for use in application code.
@@ -153,7 +153,7 @@ static inline const char *chRegGetThreadNameI(thread_t *tp) {
chDbgCheckClassI();
-#if CH_CFG_USE_REGISTRY
+#if CH_CFG_USE_REGISTRY == TRUE
return tp->p_name;
#else
(void)tp;
@@ -161,7 +161,7 @@ static inline const char *chRegGetThreadNameI(thread_t *tp) {
#endif
}
-#endif /* CH_CFG_USE_REGISTRY */
+#endif /* CH_CFG_USE_REGISTRY == TRUE */
#endif /* _CHREGISTRY_H_ */
diff --git a/os/rt/include/chschd.h b/os/rt/include/chschd.h
index 12a6762fa..c166bc034 100644
--- a/os/rt/include/chschd.h
+++ b/os/rt/include/chschd.h
@@ -36,10 +36,10 @@
* @name Wakeup status codes
* @{
*/
-#define MSG_OK 0 /**< @brief Normal wakeup message. */
-#define MSG_TIMEOUT -1 /**< @brief Wakeup caused by a timeout
+#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
+#define MSG_RESET -2 /**< @brief Wakeup caused by a reset
condition. */
/** @} */
@@ -47,37 +47,37 @@
* @name Priority constants
* @{
*/
-#define NOPRIO 0 /**< @brief Ready list header priority. */
-#define IDLEPRIO 1 /**< @brief Idle thread priority. */
-#define LOWPRIO 2 /**< @brief Lowest user priority. */
-#define NORMALPRIO 64 /**< @brief Normal user priority. */
-#define HIGHPRIO 127 /**< @brief Highest user priority. */
-#define ABSPRIO 255 /**< @brief Greatest possible priority. */
+#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. */
/** @} */
/**
* @name Thread states
* @{
*/
-#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */
-#define CH_STATE_CURRENT 1 /**< @brief Currently running. */
-#define CH_STATE_WTSTART 2 /**< @brief Created but not started. */
-#define CH_STATE_SUSPENDED 3 /**< @brief Suspended state. */
-#define CH_STATE_QUEUED 4 /**< @brief Waiting on an I/O queue. */
-#define CH_STATE_WTSEM 5 /**< @brief Waiting on a semaphore. */
-#define CH_STATE_WTMTX 6 /**< @brief Waiting on a mutex. */
-#define CH_STATE_WTCOND 7 /**< @brief Waiting on a condition
+#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 8 /**< @brief Waiting in @p chThdSleep()
+#define CH_STATE_SLEEPING 8U /**< @brief Waiting in @p chThdSleep()
or @p chThdSleepUntil(). */
-#define CH_STATE_WTEXIT 9 /**< @brief Waiting in @p chThdWait(). */
-#define CH_STATE_WTOREVT 10 /**< @brief Waiting for an event. */
-#define CH_STATE_WTANDEVT 11 /**< @brief Waiting for several events. */
-#define CH_STATE_SNDMSGQ 12 /**< @brief Sending a message, in queue.*/
-#define CH_STATE_SNDMSG 13 /**< @brief Sent a message, waiting
+#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 14 /**< @brief Waiting for a message. */
-#define CH_STATE_FINAL 15 /**< @brief Thread terminated. */
+#define CH_STATE_WTMSG 14U /**< @brief Waiting for a message. */
+#define CH_STATE_FINAL 15U /**< @brief Thread terminated. */
/**
* @brief Thread states as array of strings.
@@ -94,13 +94,13 @@
* @name Thread flags and attributes
* @{
*/
-#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */
-#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */
-#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a
+#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 2 /**< @brief Thread allocated from a
+#define CH_FLAG_MODE_MEMPOOL 2U /**< @brief Thread allocated from a
Memory Pool. */
-#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */
+#define CH_FLAG_TERMINATE 4U /**< @brief Termination requested flag. */
/** @} */
/**
@@ -194,18 +194,18 @@ struct ch_thread {
/* End of the fields shared with the threads_queue_t structure.*/
tprio_t p_prio; /**< @brief Thread priority. */
struct context p_ctx; /**< @brief Processor context. */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
thread_t *p_newer; /**< @brief Newer registry element. */
thread_t *p_older; /**< @brief Older registry element. */
#endif
/* End of the fields shared with the ReadyList structure. */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
/**
* @brief Thread name or @p NULL.
*/
const char *p_name;
#endif
-#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
+#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
/**
* @brief Thread stack boundary.
*/
@@ -219,7 +219,7 @@ struct ch_thread {
* @brief Various thread flags.
*/
tmode_t p_flags;
-#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
+#if (CH_CFG_USE_DYNAMIC == TRUE) || defined(__DOXYGEN__)
/**
* @brief References to this thread.
*/
@@ -231,7 +231,7 @@ struct ch_thread {
#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
tslices_t p_preempt;
#endif
-#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
+#if (CH_DBG_THREADS_PROFILING == TRUE) || defined(__DOXYGEN__)
/**
* @brief Thread consumed time in ticks.
* @note This field can overflow.
@@ -265,7 +265,7 @@ struct ch_thread {
* states.
*/
void *wtobjp;
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Enabled events mask.
* @note This field is only valid while the thread is in the
@@ -274,13 +274,13 @@ struct ch_thread {
eventmask_t ewmask;
#endif
} p_u;
-#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
+#if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Termination waiting list.
*/
threads_list_t p_waiting;
#endif
-#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
/**
* @brief Messages queue.
*/
@@ -290,13 +290,13 @@ struct ch_thread {
*/
msg_t p_msg;
#endif
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Pending events mask.
*/
eventmask_t p_epending;
#endif
-#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
/**
* @brief List of the mutexes owned by this thread.
* @note The list is terminated by a @p NULL in this field.
@@ -307,13 +307,14 @@ struct ch_thread {
*/
tprio_t p_realprio;
#endif
-#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
+#if ((CH_CFG_USE_DYNAMIC == TRUE) && (CH_CFG_USE_MEMPOOLS == TRUE)) || \
+ defined(__DOXYGEN__)
/**
* @brief Memory Pool where the thread workspace is returned.
*/
void *p_mpool;
#endif
-#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Thread statistics.
*/
@@ -352,10 +353,10 @@ struct ch_virtual_timers_list {
virtual_timer_t *vt_prev; /**< @brief Last timer in the delta
list. */
systime_t vt_delta; /**< @brief Must be initialized to -1. */
-#if CH_CFG_ST_TIMEDELTA == 0 || defined(__DOXYGEN__)
+#if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
volatile systime_t vt_systime; /**< @brief System Time counter. */
#endif
-#if CH_CFG_ST_TIMEDELTA > 0 || defined(__DOXYGEN__)
+#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
/**
* @brief System time of the last tick event.
*/
@@ -373,7 +374,7 @@ struct ch_ready_list {
initialized to zero. */
struct context r_ctx; /**< @brief Not used, present because
offsets. */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
thread_t *r_newer; /**< @brief Newer registry element. */
thread_t *r_older; /**< @brief Older registry element. */
#endif
@@ -394,7 +395,7 @@ struct ch_system_debug {
* field itself is declared volatile.
*/
const char * volatile panic_msg;
-#if CH_DBG_SYSTEM_STATE_CHECK || defined(__DOXYGEN__)
+#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
/**
* @brief ISR nesting level.
*/
@@ -404,7 +405,7 @@ struct ch_system_debug {
*/
cnt_t lock_cnt;
#endif
-#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
+#if (CH_DBG_ENABLE_TRACE == TRUE) || defined(__DOXYGEN__)
/**
* @brief Public trace buffer.
*/
@@ -434,19 +435,19 @@ struct ch_system {
* @brief Main thread descriptor.
*/
thread_t mainthread;
-#if CH_CFG_USE_TM || defined(__DOXYGEN__)
+#if (CH_CFG_USE_TM == TRUE) || defined(__DOXYGEN__)
/**
* @brief Time measurement calibration data.
*/
tm_calibration_t tm;
#endif
-#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Global kernel statistics.
*/
kernel_stats_t kernel_stats;
#endif
-#if !CH_CFG_NO_IDLE_THREAD
+#if CH_CFG_NO_IDLE_THREAD == FALSE
/**
* @brief Idle thread working area.
*/
@@ -501,13 +502,13 @@ extern "C" {
thread_t *chSchReadyI(thread_t *tp);
void chSchGoSleepS(tstate_t newstate);
msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time);
- void chSchWakeupS(thread_t *tp, msg_t msg);
+ void chSchWakeupS(thread_t *ntp, msg_t msg);
void chSchRescheduleS(void);
bool chSchIsPreemptionRequired(void);
void chSchDoRescheduleBehind(void);
void chSchDoRescheduleAhead(void);
void chSchDoReschedule(void);
-#if !CH_CFG_OPTIMIZE_SPEED
+#if CH_CFG_OPTIMIZE_SPEED == FALSE
void queue_prio_insert(thread_t *tp, threads_queue_t *tqp);
void queue_insert(thread_t *tp, threads_queue_t *tqp);
thread_t *queue_fifo_remove(threads_queue_t *tqp);
@@ -515,7 +516,7 @@ extern "C" {
thread_t *queue_dequeue(thread_t *tp);
void list_insert(thread_t *tp, threads_list_t *tlp);
thread_t *list_remove(threads_list_t *tlp);
-#endif /* CH_CFG_OPTIMIZE_SPEED */
+#endif /* CH_CFG_OPTIMIZE_SPEED == FALSE */
#ifdef __cplusplus
}
#endif
@@ -533,7 +534,9 @@ extern "C" {
*/
static inline void list_init(threads_list_t *tlp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
tlp->p_next = (thread_t *)tlp;
+ /*lint -restore*/
}
/**
@@ -546,7 +549,9 @@ static inline void list_init(threads_list_t *tlp) {
*/
static inline bool list_isempty(threads_list_t *tlp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
return (bool)(tlp->p_next == (thread_t *)tlp);
+ /*lint -restore*/
}
/**
@@ -559,7 +564,9 @@ static inline bool list_isempty(threads_list_t *tlp) {
*/
static inline bool list_notempty(threads_list_t *tlp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
return (bool)(tlp->p_next != (thread_t *)tlp);
+ /*lint -restore*/
}
/**
@@ -571,7 +578,10 @@ static inline bool list_notempty(threads_list_t *tlp) {
*/
static inline void queue_init(threads_queue_t *tqp) {
- tqp->p_next = tqp->p_prev = (thread_t *)tqp;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ tqp->p_next = (thread_t *)tqp;
+ tqp->p_prev = (thread_t *)tqp;
+ /*lint -restore*/
}
/**
@@ -584,7 +594,9 @@ static inline void queue_init(threads_queue_t *tqp) {
*/
static inline bool queue_isempty(threads_queue_t *tqp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
return (bool)(tqp->p_next == (thread_t *)tqp);
+ /*lint -restore*/
}
/**
@@ -597,12 +609,14 @@ static inline bool queue_isempty(threads_queue_t *tqp) {
*/
static inline bool queue_notempty(threads_queue_t *tqp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
return (bool)(tqp->p_next != (thread_t *)tqp);
+ /*lint -restore*/
}
/* If the performance code path has been chosen then all the following
functions are inlined into the various kernel modules.*/
-#if CH_CFG_OPTIMIZE_SPEED
+#if CH_CFG_OPTIMIZE_SPEED == TRUE
static inline void list_insert(thread_t *tp, threads_list_t *tlp) {
tp->p_next = tlp->p_next;
@@ -619,26 +633,35 @@ static inline thread_t *list_remove(threads_list_t *tlp) {
static inline void queue_prio_insert(thread_t *tp, threads_queue_t *tqp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
thread_t *cp = (thread_t *)tqp;
do {
cp = cp->p_next;
} while ((cp != (thread_t *)tqp) && (cp->p_prio >= tp->p_prio));
+ /*lint -restore*/
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;
}
static inline void queue_insert(thread_t *tp, threads_queue_t *tqp) {
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
tp->p_next = (thread_t *)tqp;
+ /*lint -restore*/
tp->p_prev = tqp->p_prev;
- tp->p_prev->p_next = tqp->p_prev = tp;
+ tp->p_prev->p_next = tp;
+ tqp->p_prev = tp;
}
static inline thread_t *queue_fifo_remove(threads_queue_t *tqp) {
thread_t *tp = tqp->p_next;
- (tqp->p_next = tp->p_next)->p_prev = (thread_t *)tqp;
+ tqp->p_next = tp->p_next;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ tqp->p_next->p_prev = (thread_t *)tqp;
+ /*lint -restore*/
return tp;
}
@@ -646,7 +669,10 @@ static inline thread_t *queue_fifo_remove(threads_queue_t *tqp) {
static inline thread_t *queue_lifo_remove(threads_queue_t *tqp) {
thread_t *tp = tqp->p_prev;
- (tqp->p_prev = tp->p_prev)->p_next = (thread_t *)tqp;
+ tqp->p_prev = tp->p_prev;
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
+ tqp->p_prev->p_next = (thread_t *)tqp;
+ /*lint -restore*/
return tp;
}
@@ -658,7 +684,7 @@ static inline thread_t *queue_dequeue(thread_t *tp) {
return tp;
}
-#endif /* CH_CFG_OPTIMIZE_SPEED */
+#endif /* CH_CFG_OPTIMIZE_SPEED == TRUE */
/**
* @brief Determines if the current thread must reschedule.
diff --git a/os/rt/include/chsem.h b/os/rt/include/chsem.h
index 7d449f65f..51a29e0f2 100644
--- a/os/rt/include/chsem.h
+++ b/os/rt/include/chsem.h
@@ -28,7 +28,7 @@
#ifndef _CHSEM_H_
#define _CHSEM_H_
-#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -153,7 +153,7 @@ static inline cnt_t chSemGetCounterI(semaphore_t *sp) {
return sp->s_cnt;
}
-#endif /* CH_CFG_USE_SEMAPHORES */
+#endif /* CH_CFG_USE_SEMAPHORES == TRUE */
#endif /* _CHSEM_H_ */
diff --git a/os/rt/include/chstats.h b/os/rt/include/chstats.h
index 0c4155662..c2405e444 100644
--- a/os/rt/include/chstats.h
+++ b/os/rt/include/chstats.h
@@ -28,7 +28,7 @@
#ifndef _CHSTATS_H_
#define _CHSTATS_H_
-#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+#if (CH_DBG_STATISTICS == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -38,7 +38,7 @@
/* Module pre-compile time settings. */
/*===========================================================================*/
-#if !CH_CFG_USE_TM
+#if CH_CFG_USE_TM == FALSE
#error "CH_DBG_STATISTICS requires CH_CFG_USE_TM"
#endif
@@ -88,7 +88,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#else /* !CH_DBG_STATISTICS */
+#else /* CH_DBG_STATISTICS == FALSE */
/* Stub functions for when the statistics module is disabled. */
#define _stats_increase_irq()
@@ -98,7 +98,7 @@ extern "C" {
#define _stats_start_measure_crit_isr()
#define _stats_stop_measure_crit_isr()
-#endif /* !CH_DBG_STATISTICS */
+#endif /* CH_DBG_STATISTICS == FALSE */
#endif /* _CHSTATS_H_ */
diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h
index ce3ae530e..88814fa16 100644
--- a/os/rt/include/chsys.h
+++ b/os/rt/include/chsys.h
@@ -197,7 +197,7 @@
*
* @xclass
*/
-#if PORT_SUPPORTS_RT || defined(__DOXYGEN__)
+#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
#endif
@@ -388,7 +388,7 @@ static inline void chSysUnconditionalUnlock(void) {
}
}
-#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
+#if (CH_CFG_NO_IDLE_THREAD == FALSE) || defined(__DOXYGEN__)
/**
* @brief Returns a pointer to the idle thread.
* @pre In order to use this function the option @p CH_CFG_NO_IDLE_THREAD
@@ -405,7 +405,7 @@ static inline thread_t *chSysGetIdleThreadX(void) {
return ch.rlist.r_queue.p_prev;
}
-#endif /* !CH_CFG_NO_IDLE_THREAD */
+#endif /* CH_CFG_NO_IDLE_THREAD == FALSE */
#endif /* _CHSYS_H_ */
diff --git a/os/rt/include/chsystypes.h b/os/rt/include/chsystypes.h
index 9fe672267..cf101e0db 100644
--- a/os/rt/include/chsystypes.h
+++ b/os/rt/include/chsystypes.h
@@ -84,7 +84,7 @@ typedef struct ch_ready_list ready_list_t;
/**
* @brief Type of a Virtual Timer callback function.
*/
-typedef void (*vtfunc_t)(void *);
+typedef void (*vtfunc_t)(void *p);
/**
* @brief Type of a Virtual Timer structure.
diff --git a/os/rt/include/chthreads.h b/os/rt/include/chthreads.h
index 60d303f95..44b9e2032 100644
--- a/os/rt/include/chthreads.h
+++ b/os/rt/include/chthreads.h
@@ -52,7 +52,7 @@ typedef thread_t * thread_reference_t;
/**
* @brief Thread function.
*/
-typedef msg_t (*tfunc_t)(void *);
+typedef msg_t (*tfunc_t)(void *p);
/*===========================================================================*/
/* Module macros. */
@@ -132,7 +132,7 @@ typedef msg_t (*tfunc_t)(void *);
extern "C" {
#endif
thread_t *_thread_init(thread_t *tp, tprio_t prio);
-#if CH_DBG_FILL_THREADS
+#if CH_DBG_FILL_THREADS == TRUE
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
#endif
thread_t *chThdCreateI(void *wsp, size_t size,
@@ -156,7 +156,7 @@ extern "C" {
void chThdYield(void);
void chThdExit(msg_t msg);
void chThdExitS(msg_t msg);
-#if CH_CFG_USE_WAITEXIT
+#if CH_CFG_USE_WAITEXIT == TRUE
msg_t chThdWait(thread_t *tp);
#endif
#ifdef __cplusplus
@@ -202,7 +202,7 @@ static inline tprio_t chThdGetPriorityX(void) {
*
* @xclass
*/
-#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
+#if (CH_DBG_THREADS_PROFILING == TRUE) || defined(__DOXYGEN__)
static inline systime_t chThdGetTicksX(thread_t *tp) {
return tp->p_time;
@@ -233,7 +233,7 @@ static inline bool chThdTerminatedX(thread_t *tp) {
*/
static inline bool chThdShouldTerminateX(void) {
- return (bool)((chThdGetSelfX()->p_flags & CH_FLAG_TERMINATE) != 0);
+ return (bool)((chThdGetSelfX()->p_flags & CH_FLAG_TERMINATE) != 0U);
}
/**
@@ -268,7 +268,7 @@ static inline void chThdSleepS(systime_t time) {
chDbgCheck(time != TIME_IMMEDIATE);
- chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time);
+ (void) chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time);
}
/**
@@ -322,7 +322,7 @@ static inline void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg) {
chDbgAssert(tp->p_state == CH_STATE_QUEUED, "invalid state");
tp->p_u.rdymsg = msg;
- chSchReadyI(tp);
+ (void) chSchReadyI(tp);
}
#endif /* _CHTHREADS_H_ */
diff --git a/os/rt/include/chtm.h b/os/rt/include/chtm.h
index d6693869e..e072ff33e 100644
--- a/os/rt/include/chtm.h
+++ b/os/rt/include/chtm.h
@@ -28,7 +28,7 @@
#ifndef _CHTM_H_
#define _CHTM_H_
-#if CH_CFG_USE_TM || defined(__DOXYGEN__)
+#if (CH_CFG_USE_TM == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Module constants. */
@@ -42,7 +42,7 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !PORT_SUPPORTS_RT
+#if PORT_SUPPORTS_RT == FALSE
#error "CH_CFG_USE_TM requires PORT_SUPPORTS_RT"
#endif
@@ -102,7 +102,7 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
-#endif /* CH_CFG_USE_TM */
+#endif /* CH_CFG_USE_TM == TRUE */
#endif /* _CHTM_H_ */
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index f0a8f00d6..d461ccbfa 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -78,7 +78,7 @@
#error "CH_CFG_TIME_QUANTUM not supported in tickless mode"
#endif
-#if (CH_CFG_ST_TIMEDELTA > 0) && CH_DBG_THREADS_PROFILING
+#if (CH_CFG_ST_TIMEDELTA > 0) && (CH_DBG_THREADS_PROFILING == TRUE)
#error "CH_DBG_THREADS_PROFILING not supported in tickless mode"
#endif
@@ -283,7 +283,7 @@ static inline bool chVTIsTimeWithinX(systime_t time,
systime_t start,
systime_t end) {
- return (bool)(time - start < end - start);
+ return (bool)((time - start) < (end - start));
}
/**
@@ -476,7 +476,8 @@ static inline void chVTDoTickI(void) {
/* The next element is outside the current time window, the loop
is stopped here.*/
- if ((vtp = ch.vtlist.vt_next)->vt_delta > delta) {
+ vtp = ch.vtlist.vt_next;
+ if (vtp->vt_delta > delta) {
break;
}
@@ -485,17 +486,21 @@ static inline void chVTDoTickI(void) {
ch.vtlist.vt_lasttime += vtp->vt_delta;
/* The timer is removed from the list and marked as non-armed.*/
+ /*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
vtp->vt_next->vt_prev = (virtual_timer_t *)&ch.vtlist;
+ /*lint -restore*/
ch.vtlist.vt_next = vtp->vt_next;
fn = vtp->vt_func;
- vtp->vt_func = (vtfunc_t)NULL;
+ vtp->vt_func = NULL;
/* The callback is invoked outside the kernel critical zone.*/
chSysUnlockFromISR();
fn(vtp->vt_par);
chSysLockFromISR();
}
+ /*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*/
/* The list is empty, no tick event needed so the alarm timer
is stopped.*/
port_timer_stop_alarm();
@@ -503,11 +508,11 @@ static inline void chVTDoTickI(void) {
else {
/* Updating the alarm to the next deadline, deadline that must not be
closer in time than the minimum time delta.*/
- if (vtp->vt_delta >= CH_CFG_ST_TIMEDELTA) {
+ if (vtp->vt_delta >= (systime_t)CH_CFG_ST_TIMEDELTA) {
port_timer_set_alarm(now + vtp->vt_delta);
}
else {
- port_timer_set_alarm(now + CH_CFG_ST_TIMEDELTA);
+ port_timer_set_alarm(now + (systime_t)CH_CFG_ST_TIMEDELTA);
}
}
#endif /* CH_CFG_ST_TIMEDELTA > 0 */