mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
cppcheck: add/correct reason for cppcheck-suppress
Adding and correcting description/rational on why certain cppcheck warnings or errors are intentionally suppressed.
This commit is contained in:
parent
c3cc0101ab
commit
59e299635b
@ -134,7 +134,8 @@ clist_node_t *_clist_sort(clist_node_t *list, clist_cmp_func_t cmp)
|
|||||||
p = q;
|
p = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cppcheck-suppress nullPointer */
|
/* cppcheck-suppress nullPointer
|
||||||
|
* (reason: tail cannot be NULL at this point, because list != NULL) */
|
||||||
tail->next = list;
|
tail->next = list;
|
||||||
|
|
||||||
/* If we have done only one merge, we're finished. */
|
/* If we have done only one merge, we're finished. */
|
||||||
|
@ -237,7 +237,7 @@ __attribute__((used)) void hard_fault_handler(uint32_t* sp, uint32_t corrupted,
|
|||||||
* Fixes wrong compiler warning by gcc < 6.0. */
|
* Fixes wrong compiler warning by gcc < 6.0. */
|
||||||
uint32_t pc = 0;
|
uint32_t pc = 0;
|
||||||
/* cppcheck-suppress variableScope
|
/* cppcheck-suppress variableScope
|
||||||
* variable used in assembly-code below */
|
* (reason: used within __asm__ which cppcheck doesn't pick up) */
|
||||||
uint32_t* orig_sp = NULL;
|
uint32_t* orig_sp = NULL;
|
||||||
|
|
||||||
/* Check if the ISR stack overflowed previously. Not possible to detect
|
/* Check if the ISR stack overflowed previously. Not possible to detect
|
||||||
|
@ -80,7 +80,8 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
/* Calculate buadrate divisor given current CPU clk rate
|
/* Calculate buadrate divisor given current CPU clk rate
|
||||||
* Ignore the first run (icache needs to be warm) */
|
* Ignore the first run (icache needs to be warm) */
|
||||||
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
|
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
|
||||||
/* cppcheck-suppress redundantAssignment */
|
/* cppcheck-suppress redundantAssignment
|
||||||
|
* (reason: should ignore first cycle to get correct values) */
|
||||||
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
|
uartDiv = PRCI_measure_mcycle_freq(1000, RTC_FREQ);
|
||||||
uartDiv = uartDiv / baudrate;
|
uartDiv = uartDiv / baudrate;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ static uint8_t i2c_find_divider(unsigned freq, unsigned speed)
|
|||||||
static inline void i2c_clear_irq_flags(I2C_Type *i2c)
|
static inline void i2c_clear_irq_flags(I2C_Type *i2c)
|
||||||
{
|
{
|
||||||
/* cppcheck-suppress selfAssignment
|
/* cppcheck-suppress selfAssignment
|
||||||
* reason: intentional self assignment to clear all pending IRQs */
|
* (reason: intentional self assignment to clear all pending IRQs) */
|
||||||
i2c->S = i2c->S;
|
i2c->S = i2c->S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ static inline int lptmr_set(uint8_t dev, uint16_t timeout)
|
|||||||
hw->CNR = 0;
|
hw->CNR = 0;
|
||||||
hw->CMR = timeout + hw->CNR;
|
hw->CMR = timeout + hw->CNR;
|
||||||
/* cppcheck-suppress selfAssignment
|
/* cppcheck-suppress selfAssignment
|
||||||
* Clear IRQ flags */
|
* (reason: intentional self assignment to clear all pending IRQs) */
|
||||||
hw->CSR = hw->CSR;
|
hw->CSR = hw->CSR;
|
||||||
/* Enable timer and IRQ */
|
/* Enable timer and IRQ */
|
||||||
hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK;
|
hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK;
|
||||||
@ -469,7 +469,7 @@ static inline int lptmr_set_absolute(uint8_t dev, uint16_t target)
|
|||||||
/* TCF is set, safe to update CMR live */
|
/* TCF is set, safe to update CMR live */
|
||||||
hw->CMR = target - lptmr[dev].cnr;
|
hw->CMR = target - lptmr[dev].cnr;
|
||||||
/* cppcheck-suppress selfAssignment
|
/* cppcheck-suppress selfAssignment
|
||||||
* Clear IRQ flags */
|
* (reason: intentional self assignment to clear all pending IRQs) */
|
||||||
hw->CSR = hw->CSR;
|
hw->CSR = hw->CSR;
|
||||||
/* Enable timer and IRQ */
|
/* Enable timer and IRQ */
|
||||||
hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK;
|
hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK;
|
||||||
|
@ -69,11 +69,8 @@ void _exit(int n)
|
|||||||
{
|
{
|
||||||
exit(n);
|
exit(n);
|
||||||
|
|
||||||
/*
|
/* cppcheck-suppress unreachableCode
|
||||||
* Disable unreachableCode cppcheck as pm_off spins indefinately after
|
* (reason: pm_off spins indefinately after pulling the plug) */
|
||||||
* pulling the plug
|
|
||||||
*/
|
|
||||||
/* cppcheck-suppress unreachableCode */
|
|
||||||
pm_off();
|
pm_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
dist/tools/tunslip/tunslip6.c
vendored
2
dist/tools/tunslip/tunslip6.c
vendored
@ -191,7 +191,7 @@ serial_to_tun(FILE *inslip, int outfd)
|
|||||||
} uip;
|
} uip;
|
||||||
static unsigned int inbufptr = 0;
|
static unsigned int inbufptr = 0;
|
||||||
/* cppcheck-suppress variableScope
|
/* cppcheck-suppress variableScope
|
||||||
* rationale: cannot be reduced if built on linux */
|
* (reason: cannot be reduced if built on linux) */
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
|
@ -218,8 +218,8 @@ float adt7310_read_float(const adt7310_t *dev)
|
|||||||
{
|
{
|
||||||
int16_t raw = adt7310_read_raw(dev);
|
int16_t raw = adt7310_read_raw(dev);
|
||||||
if (raw == INT16_MIN) {
|
if (raw == INT16_MIN) {
|
||||||
/* ignore cppcheck: we want to create a NaN here */
|
/* cppcheck-suppress duplicateExpression
|
||||||
/* cppcheck-suppress duplicateExpression */
|
* (reason: we want to create a NaN here) */
|
||||||
return (0.0f / 0.0f); /* return NaN */
|
return (0.0f / 0.0f); /* return NaN */
|
||||||
}
|
}
|
||||||
if (!dev->high_res) {
|
if (!dev->high_res) {
|
||||||
|
@ -55,7 +55,8 @@ static int _send(gnrc_pktsnip_t *pkt)
|
|||||||
|
|
||||||
/* Search for TCP header */
|
/* Search for TCP header */
|
||||||
LL_SEARCH_SCALAR(pkt, tcp, type, GNRC_NETTYPE_TCP);
|
LL_SEARCH_SCALAR(pkt, tcp, type, GNRC_NETTYPE_TCP);
|
||||||
/* cppcheck-suppress knownConditionTrueFalse */
|
/* cppcheck-suppress knownConditionTrueFalse
|
||||||
|
* (reason: tcp *can* be != NULL after LL_SEARCH_SCALAR) */
|
||||||
if (tcp == NULL) {
|
if (tcp == NULL) {
|
||||||
DEBUG("gnrc_tcp_eventloop : _send() : tcp header missing.\n");
|
DEBUG("gnrc_tcp_eventloop : _send() : tcp header missing.\n");
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
|
@ -482,7 +482,8 @@ static int _fsm_rcvd_pkt(gnrc_tcp_tcb_t *tcb, gnrc_pktsnip_t *in_pkt)
|
|||||||
if (ipv6_addr_is_link_local((ipv6_addr_t *) tcb->peer_addr)) {
|
if (ipv6_addr_is_link_local((ipv6_addr_t *) tcb->peer_addr)) {
|
||||||
gnrc_pktsnip_t *tmp = NULL;
|
gnrc_pktsnip_t *tmp = NULL;
|
||||||
LL_SEARCH_SCALAR(in_pkt, tmp, type, GNRC_NETTYPE_NETIF);
|
LL_SEARCH_SCALAR(in_pkt, tmp, type, GNRC_NETTYPE_NETIF);
|
||||||
/* cppcheck-suppress knownConditionTrueFalse */
|
/* cppcheck-suppress knownConditionTrueFalse
|
||||||
|
* (reason: tmp *can* be != NULL after LL_SEARCH_SCALAR) */
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
DEBUG("gnrc_tcp_fsm.c : _fsm_rcvd_pkt() :\
|
DEBUG("gnrc_tcp_fsm.c : _fsm_rcvd_pkt() :\
|
||||||
incomming packet had no netif header\n");
|
incomming packet had no netif header\n");
|
||||||
|
@ -79,7 +79,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq)
|
|||||||
static volatile const unsigned int zero = 0;
|
static volatile const unsigned int zero = 0;
|
||||||
|
|
||||||
/* cppcheck-suppress zerodiv
|
/* cppcheck-suppress zerodiv
|
||||||
* Divission by zero is on purpose here */
|
* (reason: division by zero is on purpose here) */
|
||||||
tmp.ul[H] = tmp.ul[L] = 1 / zero;
|
tmp.ul[H] = tmp.ul[L] = 1 / zero;
|
||||||
|
|
||||||
if (arq) {
|
if (arq) {
|
||||||
|
@ -98,7 +98,8 @@ static universal_address_container_t *universal_address_get_next_unused_entry(vo
|
|||||||
* (reason: UNIVERSAL_ADDRESS_MAX_ENTRIES may be zero in which case this
|
* (reason: UNIVERSAL_ADDRESS_MAX_ENTRIES may be zero in which case this
|
||||||
* code is optimized out) */
|
* code is optimized out) */
|
||||||
if (universal_address_table_filled < UNIVERSAL_ADDRESS_MAX_ENTRIES) {
|
if (universal_address_table_filled < UNIVERSAL_ADDRESS_MAX_ENTRIES) {
|
||||||
/* cppcheck-suppress unsignedLessThanZero */
|
/* cppcheck-suppress unsignedLessThanZero
|
||||||
|
* (reason: UNIVERSAL_ADDRESS_MAX_ENTRIES may be zero, see above) */
|
||||||
for (size_t i = 0; i < UNIVERSAL_ADDRESS_MAX_ENTRIES; ++i) {
|
for (size_t i = 0; i < UNIVERSAL_ADDRESS_MAX_ENTRIES; ++i) {
|
||||||
if (universal_address_table[i].use_count == 0) {
|
if (universal_address_table[i].use_count == 0) {
|
||||||
return &(universal_address_table[i]);
|
return &(universal_address_table[i]);
|
||||||
|
@ -69,7 +69,7 @@ int main(void)
|
|||||||
|
|
||||||
puts("On-board button test\n");
|
puts("On-board button test\n");
|
||||||
/* cppcheck-suppress knownConditionTrueFalse
|
/* cppcheck-suppress knownConditionTrueFalse
|
||||||
* rationale: board-dependent ifdefs */
|
* (reason: board-dependent ifdefs) */
|
||||||
if (cnt == 0) {
|
if (cnt == 0) {
|
||||||
puts("[FAILED] no buttons available!");
|
puts("[FAILED] no buttons available!");
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -53,7 +53,7 @@ int main() {
|
|||||||
{
|
{
|
||||||
lock_guard<mutex> lk(m);
|
lock_guard<mutex> lk(m);
|
||||||
/* cppcheck-suppress unreadVariable
|
/* cppcheck-suppress unreadVariable
|
||||||
* (reason variable is read in the thread created above) */
|
* (reason: variable is read in the thread created above) */
|
||||||
ready = true;
|
ready = true;
|
||||||
cv.notify_one();
|
cv.notify_one();
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ int main(void)
|
|||||||
|
|
||||||
puts("On-board LED test\n");
|
puts("On-board LED test\n");
|
||||||
/* cppcheck-suppress knownConditionTrueFalse
|
/* cppcheck-suppress knownConditionTrueFalse
|
||||||
* rationale: board-dependent ifdefs */
|
* (reason: board-dependent ifdefs) */
|
||||||
if (numof == 0) {
|
if (numof == 0) {
|
||||||
puts("NO LEDs AVAILABLE");
|
puts("NO LEDs AVAILABLE");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user