aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-06-04 10:28:50 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-06-04 10:28:50 +0000
commitb436539f00a5a356514b1f995aa0205f41da6578 (patch)
tree5d67e1095c379d6c3c7546d25bde9a5398e3e603
parenta5a229f455c26772c8ee350033ce161d194c2119 (diff)
downloadChibiOS-b436539f00a5a356514b1f995aa0205f41da6578.tar.gz
ChibiOS-b436539f00a5a356514b1f995aa0205f41da6578.tar.bz2
ChibiOS-b436539f00a5a356514b1f995aa0205f41da6578.zip
MISRA-related fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10234 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/common/oslib/include/chmboxes.h8
-rw-r--r--os/rt/include/chvt.h28
2 files changed, 22 insertions, 14 deletions
diff --git a/os/common/oslib/include/chmboxes.h b/os/common/oslib/include/chmboxes.h
index c1f2d8bf6..8dc38a374 100644
--- a/os/common/oslib/include/chmboxes.h
+++ b/os/common/oslib/include/chmboxes.h
@@ -133,7 +133,7 @@ extern "C" {
*
* @iclass
*/
-static inline cnt_t chMBGetSizeI(mailbox_t *mbp) {
+static inline cnt_t chMBGetSizeI(const mailbox_t *mbp) {
/*lint -save -e9033 [10.8] Perfectly safe pointers
arithmetic.*/
@@ -150,7 +150,7 @@ static inline cnt_t chMBGetSizeI(mailbox_t *mbp) {
*
* @iclass
*/
-static inline cnt_t chMBGetUsedCountI(mailbox_t *mbp) {
+static inline cnt_t chMBGetUsedCountI(const mailbox_t *mbp) {
chDbgCheckClassI();
@@ -165,7 +165,7 @@ static inline cnt_t chMBGetUsedCountI(mailbox_t *mbp) {
*
* @iclass
*/
-static inline cnt_t chMBGetFreeCountI(mailbox_t *mbp) {
+static inline cnt_t chMBGetFreeCountI(const mailbox_t *mbp) {
chDbgCheckClassI();
@@ -184,7 +184,7 @@ static inline cnt_t chMBGetFreeCountI(mailbox_t *mbp) {
*
* @iclass
*/
-static inline msg_t chMBPeekI(mailbox_t *mbp) {
+static inline msg_t chMBPeekI(const mailbox_t *mbp) {
chDbgCheckClassI();
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index f1f175c37..dc08dbe07 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -25,8 +25,6 @@
* @{
*/
-#include <limits.h>
-
#ifndef CHVT_H
#define CHVT_H
@@ -53,8 +51,18 @@
* see the specific function documentation.
*/
#define TIME_INFINITE ((systime_t)-1)
+
+/**
+ * @brief Maximum time constant.
+ */
+#define TIME_MAXIMUM ((systime_t)-2)
/** @} */
+/**
+ * @brief Maximum unsigned integer.
+ */
+#define __UINT_MAX ((unsigned int)-1)
+
/*===========================================================================*/
/* Module pre-compile time settings. */
/*===========================================================================*/
@@ -236,7 +244,7 @@ extern "C" {
static inline systime_t LL_S2ST(unsigned int sec) {
uint64_t ticks = (uint64_t)sec * (uint64_t)CH_CFG_ST_FREQUENCY;
- chDbgAssert(ticks < (uint64_t)TIME_INFINITE, "conversion overflow");
+ chDbgAssert(ticks <= (uint64_t)TIME_MAXIMUM, "conversion overflow");
return (systime_t)ticks;
}
@@ -258,7 +266,7 @@ static inline systime_t LL_MS2ST(unsigned int msec) {
uint64_t ticks = (((uint64_t)msec * (uint64_t)CH_CFG_ST_FREQUENCY) + 999ULL)
/ 1000ULL;
- chDbgAssert(ticks < (uint64_t)TIME_INFINITE, "conversion overflow");
+ chDbgAssert(ticks <= (uint64_t)TIME_MAXIMUM, "conversion overflow");
return (systime_t)ticks;
}
@@ -280,7 +288,7 @@ static inline systime_t LL_US2ST(unsigned int usec) {
uint64_t ticks = (((uint64_t)usec * (uint64_t)CH_CFG_ST_FREQUENCY) + 999999ULL)
/ 1000000ULL;
- chDbgAssert(ticks < (uint64_t)TIME_INFINITE, "conversion overflow");
+ chDbgAssert(ticks <= (uint64_t)TIME_MAXIMUM, "conversion overflow");
return (systime_t)ticks;
}
@@ -302,7 +310,7 @@ static inline unsigned int LL_ST2S(systime_t n) {
uint64_t sec = ((uint64_t)n + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL)
/ (uint64_t)CH_CFG_ST_FREQUENCY;
- chDbgAssert(sec < (uint64_t)UINT_MAX, "conversion overflow");
+ chDbgAssert(sec < (uint64_t)__UINT_MAX, "conversion overflow");
return (unsigned int)sec;
}
@@ -321,10 +329,10 @@ static inline unsigned int LL_ST2S(systime_t n) {
* @api
*/
static inline unsigned int LL_ST2MS(systime_t n) {
- uint64_t msec = ((uint64_t)n * 1000ULL + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL)
+ uint64_t msec = (((uint64_t)n * 1000ULL) + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL)
/ (uint64_t)CH_CFG_ST_FREQUENCY;
- chDbgAssert(msec < (uint64_t)UINT_MAX, "conversion overflow");
+ chDbgAssert(msec < (uint64_t)__UINT_MAX, "conversion overflow");
return (unsigned int)msec;
}
@@ -343,10 +351,10 @@ static inline unsigned int LL_ST2MS(systime_t n) {
* @api
*/
static inline unsigned int LL_ST2US(systime_t n) {
- uint64_t usec = ((uint64_t)n * 1000000ULL + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL)
+ uint64_t usec = (((uint64_t)n * 1000000ULL) + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL)
/ (uint64_t)CH_CFG_ST_FREQUENCY;
- chDbgAssert(usec < (uint64_t)UINT_MAX, "conversion overflow");
+ chDbgAssert(usec < (uint64_t)__UINT_MAX, "conversion overflow");
return (unsigned int)usec;
}