From ce7f7103df5f634f7b57d90e115c5824adcb68a0 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 8 Mar 2015 21:19:58 +0000 Subject: MISRA fixes for high level HAL. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7738 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal_queues.h | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'os/hal/include/hal_queues.h') diff --git a/os/hal/include/hal_queues.h b/os/hal/include/hal_queues.h index 08515fd45..62c08d11c 100644 --- a/os/hal/include/hal_queues.h +++ b/os/hal/include/hal_queues.h @@ -30,7 +30,8 @@ /* The ChibiOS/RT kernel provides the following definitions by itself, this check is performed in order to avoid conflicts. */ -#if !defined(_CHIBIOS_RT_) || !CH_CFG_USE_QUEUES || defined(__DOXYGEN__) +#if !defined(_CHIBIOS_RT_) || (CH_CFG_USE_QUEUES == FALSE) || \ + defined(__DOXYGEN__) /** * @name Queue functions returned status value @@ -85,9 +86,12 @@ struct io_queue { * @param[in] qp pointer to a @p io_queue_t structure. * @return The buffer size. * - * @iclass + * @xclass */ -#define qSizeI(qp) ((size_t)((qp)->q_top - (qp)->q_buffer)) +#define qSizeX(qp) \ + /*lint -save -e9033 [10.8] The cast is safe.*/ \ + ((size_t)((qp)->q_top - (qp)->q_buffer)) \ + /*lint -restore*/ /** * @brief Queue space. @@ -149,7 +153,7 @@ typedef io_queue_t input_queue_t; * * @iclass */ -#define iqGetEmptyI(iqp) (qSizeI(iqp) - qSpaceI(iqp)) +#define iqGetEmptyI(iqp) (qSizeX(iqp) - qSpaceI(iqp)) /** * @brief Evaluates to @p TRUE if the specified input queue is empty. @@ -161,7 +165,7 @@ typedef io_queue_t input_queue_t; * * @iclass */ -#define iqIsEmptyI(iqp) ((bool)(qSpaceI(iqp) <= 0)) +#define iqIsEmptyI(iqp) ((bool)(qSpaceI(iqp) == 0U)) /** * @brief Evaluates to @p TRUE if the specified input queue is full. @@ -174,7 +178,7 @@ typedef io_queue_t input_queue_t; * @iclass */ #define iqIsFullI(iqp) ((bool)(((iqp)->q_wrptr == (iqp)->q_rdptr) && \ - ((iqp)->q_counter != 0))) + ((iqp)->q_counter != 0U))) /** * @brief Input queue read. @@ -204,7 +208,7 @@ typedef io_queue_t input_queue_t; */ #define _INPUTQUEUE_DATA(name, buffer, size, inotify, link) { \ NULL, \ - 0, \ + 0U, \ (uint8_t *)(buffer), \ (uint8_t *)(buffer) + (size), \ (uint8_t *)(buffer), \ @@ -252,7 +256,7 @@ typedef io_queue_t output_queue_t; * * @iclass */ -#define oqGetFullI(oqp) (qSizeI(oqp) - qSpaceI(oqp)) +#define oqGetFullI(oqp) (qSizeX(oqp) - qSpaceI(oqp)) /** * @brief Returns the empty space into an output queue. @@ -276,7 +280,7 @@ typedef io_queue_t output_queue_t; * @iclass */ #define oqIsEmptyI(oqp) ((bool)(((oqp)->q_wrptr == (oqp)->q_rdptr) && \ - ((oqp)->q_counter != 0))) + ((oqp)->q_counter != 0U))) /** * @brief Evaluates to @p TRUE if the specified output queue is full. @@ -288,7 +292,7 @@ typedef io_queue_t output_queue_t; * * @iclass */ -#define oqIsFullI(oqp) ((bool)(qSpaceI(oqp) <= 0)) +#define oqIsFullI(oqp) ((bool)(qSpaceI(oqp) == 0U)) /** * @brief Output queue write. @@ -350,17 +354,17 @@ extern "C" { qnotify_t infy, void *link); void iqResetI(input_queue_t *iqp); msg_t iqPutI(input_queue_t *iqp, uint8_t b); - msg_t iqGetTimeout(input_queue_t *iqp, systime_t time); + msg_t iqGetTimeout(input_queue_t *iqp, systime_t timeout); size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, - size_t n, systime_t time); + size_t n, systime_t timeout); void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link); void oqResetI(output_queue_t *oqp); - msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time); + msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t timeout); msg_t oqGetI(output_queue_t *oqp); size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, - size_t n, systime_t time); + size_t n, systime_t timeout); #ifdef __cplusplus } #endif @@ -369,7 +373,7 @@ extern "C" { /* If ChibiOS is being used and its own queues subsystem is activated then this module will use the ChibiOS queues code.*/ -#define qSizeI(qp) chQSizeI(qp) +#define qSizeX(qp) chQSizeX(qp) #define qSpaceI(qp) chQSpaceI(qp) #define qGetLink(qp) chQGetLinkX(qp) #define iqGetFullI(iqp) chIQGetFullI(iqp) @@ -395,7 +399,7 @@ extern "C" { #define oqGetI(oqp) chOQGetI(oqp) #define oqWriteTimeout(oqp, bp, n, time) chOQWriteTimeout(oqp, bp, n, time) -#endif /* defined(_CHIBIOS_RT_) && CH_CFG_USE_QUEUES */ +#endif /* defined(_CHIBIOS_RT_) || (CH_CFG_USE_QUEUES == FALSE) */ #endif /* _HAL_QUEUES_H_ */ -- cgit v1.2.3