MISRA-related changes.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11473 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2018-02-10 11:25:29 +00:00
parent 87bae60d9d
commit ff109ac9e6
20 changed files with 72 additions and 59 deletions

View File

@ -162,7 +162,7 @@ typedef uint32_t systime_t;
#if 0
/**
* @brief Type of system time counter.
* @brief Type of system time interval.
*/
typedef uint32_t sysinterval_t;
#endif

View File

@ -162,7 +162,7 @@ systime_t osalOsGetSystemTimeX(void) {
*
* @sclass
*/
void osalThreadSleepS(systime_t time) {
void osalThreadSleepS(sysinterval_t time) {
virtual_timer_t vt;
thread_reference_t tr;
@ -183,7 +183,7 @@ void osalThreadSleepS(systime_t time) {
*
* @api
*/
void osalThreadSleep(systime_t time) {
void osalThreadSleep(sysinterval_t time) {
osalSysLock();
osalThreadSleepS(time);
@ -236,7 +236,7 @@ msg_t osalThreadSuspendS(thread_reference_t *trp) {
*
* @sclass
*/
msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, systime_t timeout) {
msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout) {
msg_t msg;
virtual_timer_t vt;
@ -316,7 +316,7 @@ void osalThreadResumeS(thread_reference_t *trp, msg_t msg) {
*
* @sclass
*/
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, systime_t timeout) {
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout) {
msg_t msg;
virtual_timer_t vt;

View File

@ -177,7 +177,7 @@ typedef int32_t msg_t;
typedef uint32_t systime_t;
/**
* @brief Type of system time counter.
* @brief Type of system time interval.
*/
typedef uint32_t sysinterval_t;
@ -366,7 +366,7 @@ typedef struct {
* @api
*/
#define OSAL_S2I(secs) \
((systime_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY))
((sysinterval_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY))
/**
* @brief Milliseconds to system ticks.
@ -379,7 +379,7 @@ typedef struct {
* @api
*/
#define OSAL_MS2I(msecs) \
((systime_t)((((((uint32_t)(msecs)) * \
((sysinterval_t)((((((uint32_t)(msecs)) * \
((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000UL) + 1UL))
/**
@ -393,7 +393,7 @@ typedef struct {
* @api
*/
#define OSAL_US2I(usecs) \
((systime_t)((((((uint32_t)(usecs)) * \
((sysinterval_t)((((((uint32_t)(usecs)) * \
((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
/** @} */

View File

@ -150,7 +150,7 @@ typedef uint32_t systime_t;
#if 0
/**
* @brief Type of system time counter.
* @brief Type of system time interval.
*/
typedef uint32_t sysinterval_t;
#endif

View File

@ -713,7 +713,7 @@ void i2c_lld_stop(I2CDriver *i2cp) {
*/
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;
@ -793,7 +793,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;

View File

@ -498,10 +498,10 @@ extern "C" {
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
#ifdef __cplusplus
}
#endif

View File

@ -961,7 +961,7 @@ void i2c_lld_stop(I2CDriver *i2cp) {
*/
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
msg_t msg;
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;
@ -1064,7 +1064,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
msg_t msg;
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;

View File

@ -487,10 +487,10 @@ extern "C" {
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
#ifdef __cplusplus
}
#endif

View File

@ -1037,7 +1037,7 @@ void i2c_lld_stop(I2CDriver *i2cp) {
*/
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
msg_t msg;
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;
@ -1160,7 +1160,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
msg_t msg;
I2C_TypeDef *dp = i2cp->i2c;
systime_t start, end;

View File

@ -553,10 +553,10 @@ extern "C" {
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
#ifdef __cplusplus
}
#endif

View File

@ -358,14 +358,14 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, sysinterval_t timeout) {
size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
size_t n, sysinterval_t timeout) {
size_t r = 0;
sysinterval_t deadline;
systime_t deadline;
osalDbgCheck(n > 0U);
osalSysLock();
/* Time window for the whole operation.*/
deadline = osalOsGetSystemTimeX() + timeout;
deadline = osalTimeAddX(osalOsGetSystemTimeX(), timeout);
while (true) {
size_t size;
@ -380,7 +380,8 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
msg = ibqGetFullBufferTimeoutS(ibqp, timeout);
}
else {
sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX();
sysinterval_t next_timeout = osalTimeDiffX(osalOsGetSystemTimeX(),
deadline);
/* Handling the case where the system time went past the deadline,
in this case next becomes a very high number because the system
@ -740,14 +741,14 @@ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b,
size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
size_t n, sysinterval_t timeout) {
size_t w = 0;
sysinterval_t deadline;
systime_t deadline;
osalDbgCheck(n > 0U);
osalSysLock();
/* Time window for the whole operation.*/
deadline = osalOsGetSystemTimeX() + timeout;
deadline = osalTimeAddX(osalOsGetSystemTimeX(), timeout);
while (true) {
size_t size;
@ -762,7 +763,8 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
msg = obqGetEmptyBufferTimeoutS(obqp, timeout);
}
else {
sysinterval_t next_timeout = deadline - osalOsGetSystemTimeX();
sysinterval_t next_timeout = osalTimeDiffX(osalOsGetSystemTimeX(),
deadline);
/* Handling the case where the system time went past the deadline,
in this case next becomes a very high number because the system

View File

@ -117,7 +117,7 @@ void palSetBusMode(IOBus *bus, iomode_t mode) {
palSetGroupMode(bus->portid, bus->mask, bus->offset, mode);
}
#if PAL_USE_CALLBACKS || defined(__DOXYGEN__)
#if (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__)
/**
* @brief Associates a callback to a port/pad.
*
@ -151,9 +151,9 @@ void palSetLineCallbackI(ioline_t line, palcallback_t cb, void *arg) {
pep->cb = cb;
pep->arg = arg;
}
#endif /* PAL_USE_CALLBACKS */
#endif /* PAL_USE_CALLBACKS == TRUE */
#if PAL_USE_WAIT || defined(__DOXYGEN__)
#if (PAL_USE_WAIT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Waits for an edge on the specified port/pad.
*
@ -194,7 +194,7 @@ msg_t palWaitLineTimeoutS(ioline_t line,
palevent_t *pep = pal_lld_get_line_event(line);
return osalThreadEnqueueTimeoutS(&pep->threads, timeout);
}
#endif /* PAL_USE_WAIT */
#endif /* PAL_USE_WAIT == TRUE */
#endif /* HAL_USE_PAL == TRUE */

View File

@ -68,7 +68,9 @@ static size_t iq_read(input_queue_t *iqp, uint8_t *bp, size_t n) {
}
/* Number of bytes before buffer limit.*/
s1 = iqp->q_top - iqp->q_rdptr;
/*lint -save -e9033 [10.8] Checked to be safe.*/
s1 = (size_t)(iqp->q_top - iqp->q_rdptr);
/*lint -restore*/
if (n < s1) {
memcpy((void *)bp, (void *)iqp->q_rdptr, n);
iqp->q_rdptr += n;
@ -114,20 +116,22 @@ static size_t oq_write(output_queue_t *oqp, const uint8_t *bp, size_t n) {
}
/* Number of bytes before buffer limit.*/
s1 = oqp->q_top - oqp->q_wrptr;
/*lint -save -e9033 [10.8] Checked to be safe.*/
s1 = (size_t)(oqp->q_top - oqp->q_wrptr);
/*lint -restore*/
if (n < s1) {
memcpy((void *)oqp->q_wrptr, (void *)bp, n);
memcpy((void *)oqp->q_wrptr, (const void *)bp, n);
oqp->q_wrptr += n;
}
else if (n > s1) {
memcpy((void *)oqp->q_wrptr, (void *)bp, s1);
memcpy((void *)oqp->q_wrptr, (const void *)bp, s1);
bp += s1;
s2 = n - s1;
memcpy((void *)oqp->q_buffer, (void *)bp, s2);
memcpy((void *)oqp->q_buffer, (const void *)bp, s2);
oqp->q_wrptr = oqp->q_buffer + s2;
}
else { /* n == s1 */
memcpy((void *)oqp->q_wrptr, (void *)bp, n);
memcpy((void *)oqp->q_wrptr, (const void *)bp, n);
oqp->q_wrptr = oqp->q_buffer;
}
@ -395,7 +399,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp,
size_t done;
done = iq_read(iqp, bp, n);
if (done == 0) {
if (done == (size_t)0) {
msg_t msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, timeout);
/* Anything except MSG_OK causes the operation to stop.*/
@ -664,7 +668,7 @@ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp,
size_t done;
done = oq_write(oqp, bp, n);
if (done == 0) {
if (done == (size_t)0) {
msg_t msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, timeout);
/* Anything except MSG_OK causes the operation to stop.*/

View File

@ -100,13 +100,16 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
case CHN_CTL_NOP:
osalDbgCheck(arg == NULL);
break;
default:
#if defined(SD_LLD_IMPLEMENTS_CTL)
return sd_lld_control(sdp, operation, arg);
#endif
case CHN_CTL_INVALID:
osalDbgAssert(false, "invalid CTL operation");
break;
default:
#if defined(SD_LLD_IMPLEMENTS_CTL)
/* Delegating to the LLD if supported.*/
return sd_lld_control(sdp, operation, arg);
#else
break;
#endif
}
return MSG_OK;
}

View File

@ -135,6 +135,9 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
case CHN_CTL_NOP:
osalDbgCheck(arg == NULL);
break;
case CHN_CTL_INVALID:
osalDbgAssert(false, "invalid CTL operation");
break;
default:
#if defined(SDU_LLD_IMPLEMENTS_CTL)
/* The SDU driver does not have a LLD but the application can use this
@ -143,10 +146,9 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
unsigned int operation,
void *arg);
return sdu_lld_control(sdup, operation, arg);
#endif
case CHN_CTL_INVALID:
osalDbgAssert(false, "invalid CTL operation");
#else
break;
#endif
}
return MSG_OK;
}

View File

@ -132,7 +132,7 @@ void i2c_lld_stop(I2CDriver *i2cp) {
*/
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
(void)i2cp;
(void)addr;
@ -169,7 +169,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout) {
sysinterval_t timeout) {
(void)i2cp;
(void)addr;

View File

@ -137,10 +137,10 @@ extern "C" {
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
const uint8_t *txbuf, size_t txbytes,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
uint8_t *rxbuf, size_t rxbytes,
systime_t timeout);
sysinterval_t timeout);
#ifdef __cplusplus
}
#endif

View File

@ -174,6 +174,8 @@ extern "C" {
void spi_lld_select(SPIDriver *spip);
void spi_lld_unselect(SPIDriver *spip);
#endif
void spi_lld_select(SPIDriver *spip);
void spi_lld_unselect(SPIDriver *spip);
void spi_lld_ignore(SPIDriver *spip, size_t n);
void spi_lld_exchange(SPIDriver *spip, size_t n,
const void *txbuf, void *rxbuf);

View File

@ -150,7 +150,7 @@ systime_t osalOsGetSystemTimeX(void) {
*
* @sclass
*/
void osalThreadSleepS(systime_t time) {
void osalThreadSleepS(sysinterval_t time) {
(void)time;
}
@ -167,7 +167,7 @@ void osalThreadSleepS(systime_t time) {
*
* @api
*/
void osalThreadSleep(systime_t time) {
void osalThreadSleep(sysinterval_t time) {
(void)time;
}
@ -208,7 +208,7 @@ msg_t osalThreadSuspendS(thread_reference_t *trp) {
*
* @sclass
*/
msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, systime_t timeout) {
msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout) {
osalDbgCheck(trp != NULL);
@ -274,7 +274,7 @@ void osalThreadResumeS(thread_reference_t *trp, msg_t msg) {
*
* @sclass
*/
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, systime_t timeout) {
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout) {
osalDbgCheck(tqp != NULL);

View File

@ -165,7 +165,7 @@ typedef int32_t msg_t;
typedef uint32_t systime_t;
/**
* @brief Type of system time counter.
* @brief Type of system time interval.
*/
typedef uint32_t sysinterval_t;
@ -344,7 +344,7 @@ typedef struct {
* @api
*/
#define OSAL_S2I(secs) \
((systime_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY))
((sysinterval_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY))
/**
* @brief Milliseconds to system ticks.
@ -357,7 +357,7 @@ typedef struct {
* @api
*/
#define OSAL_MS2I(msecs) \
((systime_t)((((((uint32_t)(msecs)) * \
((sysinterval_t)((((((uint32_t)(msecs)) * \
((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000UL) + 1UL))
/**
@ -371,7 +371,7 @@ typedef struct {
* @api
*/
#define OSAL_US2I(usecs) \
((systime_t)((((((uint32_t)(usecs)) * \
((sysinterval_t)((((((uint32_t)(usecs)) * \
((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
/** @} */