diff --git a/core/clist.c b/core/clist.c index 1e7db16269..a89bbc549e 100644 --- a/core/clist.c +++ b/core/clist.c @@ -134,7 +134,8 @@ clist_node_t *_clist_sort(clist_node_t *list, clist_cmp_func_t cmp) p = q; } - /* cppcheck-suppress nullPointer */ + /* cppcheck-suppress nullPointer + * (reason: tail cannot be NULL at this point, because list != NULL) */ tail->next = list; /* If we have done only one merge, we're finished. */ diff --git a/cpu/cortexm_common/vectors_cortexm.c b/cpu/cortexm_common/vectors_cortexm.c index 25b9cf18cb..3bf56daa50 100644 --- a/cpu/cortexm_common/vectors_cortexm.c +++ b/cpu/cortexm_common/vectors_cortexm.c @@ -237,7 +237,7 @@ __attribute__((used)) void hard_fault_handler(uint32_t* sp, uint32_t corrupted, * Fixes wrong compiler warning by gcc < 6.0. */ uint32_t pc = 0; /* cppcheck-suppress variableScope - * variable used in assembly-code below */ + * (reason: used within __asm__ which cppcheck doesn't pick up) */ uint32_t* orig_sp = NULL; /* Check if the ISR stack overflowed previously. Not possible to detect diff --git a/cpu/fe310/periph/uart.c b/cpu/fe310/periph/uart.c index 675d34f4e8..dbc0182d77 100644 --- a/cpu/fe310/periph/uart.c +++ b/cpu/fe310/periph/uart.c @@ -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 * Ignore the first run (icache needs to be warm) */ 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 = uartDiv / baudrate; diff --git a/cpu/kinetis/periph/i2c.c b/cpu/kinetis/periph/i2c.c index 64d14c6d26..2e5eeb0f78 100644 --- a/cpu/kinetis/periph/i2c.c +++ b/cpu/kinetis/periph/i2c.c @@ -170,7 +170,7 @@ static uint8_t i2c_find_divider(unsigned freq, unsigned speed) static inline void i2c_clear_irq_flags(I2C_Type *i2c) { /* 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; } diff --git a/cpu/kinetis/periph/timer.c b/cpu/kinetis/periph/timer.c index 1f6edbdeb7..021c6bee3e 100644 --- a/cpu/kinetis/periph/timer.c +++ b/cpu/kinetis/periph/timer.c @@ -436,7 +436,7 @@ static inline int lptmr_set(uint8_t dev, uint16_t timeout) hw->CNR = 0; hw->CMR = timeout + hw->CNR; /* cppcheck-suppress selfAssignment - * Clear IRQ flags */ + * (reason: intentional self assignment to clear all pending IRQs) */ hw->CSR = hw->CSR; /* Enable timer and IRQ */ 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 */ hw->CMR = target - lptmr[dev].cnr; /* cppcheck-suppress selfAssignment - * Clear IRQ flags */ + * (reason: intentional self assignment to clear all pending IRQs) */ hw->CSR = hw->CSR; /* Enable timer and IRQ */ hw->CSR = LPTMR_CSR_TEN_MASK | LPTMR_CSR_TFC_MASK | LPTMR_CSR_TIE_MASK; diff --git a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c index 3f0d7e49a6..87efbb0c57 100644 --- a/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c +++ b/cpu/mips32r2_common/newlib_syscalls_mips_uhi/syscalls.c @@ -69,11 +69,8 @@ void _exit(int n) { exit(n); - /* - * Disable unreachableCode cppcheck as pm_off spins indefinately after - * pulling the plug - */ - /* cppcheck-suppress unreachableCode */ + /* cppcheck-suppress unreachableCode + * (reason: pm_off spins indefinately after pulling the plug) */ pm_off(); } diff --git a/dist/tools/tunslip/tunslip6.c b/dist/tools/tunslip/tunslip6.c index 67ad3a0d5c..b77958845e 100644 --- a/dist/tools/tunslip/tunslip6.c +++ b/dist/tools/tunslip/tunslip6.c @@ -191,7 +191,7 @@ serial_to_tun(FILE *inslip, int outfd) } uip; static unsigned int inbufptr = 0; /* cppcheck-suppress variableScope - * rationale: cannot be reduced if built on linux */ + * (reason: cannot be reduced if built on linux) */ int ret; unsigned char c; diff --git a/drivers/adt7310/adt7310.c b/drivers/adt7310/adt7310.c index 8af6ad7707..1cd5aabfc0 100644 --- a/drivers/adt7310/adt7310.c +++ b/drivers/adt7310/adt7310.c @@ -218,8 +218,8 @@ float adt7310_read_float(const adt7310_t *dev) { int16_t raw = adt7310_read_raw(dev); 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 */ } if (!dev->high_res) { diff --git a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c index e8d8acce57..db7fb5621c 100644 --- a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c +++ b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c @@ -55,7 +55,8 @@ static int _send(gnrc_pktsnip_t *pkt) /* Search for TCP header */ 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) { DEBUG("gnrc_tcp_eventloop : _send() : tcp header missing.\n"); gnrc_pktbuf_release(pkt); diff --git a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_fsm.c b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_fsm.c index ffa8ad9595..3a8ffe3e18 100644 --- a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_fsm.c +++ b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_fsm.c @@ -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)) { gnrc_pktsnip_t *tmp = NULL; 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) { DEBUG("gnrc_tcp_fsm.c : _fsm_rcvd_pkt() :\ incomming packet had no netif header\n"); diff --git a/sys/quad_math/qdivrem.c b/sys/quad_math/qdivrem.c index 8ff7ecb15b..b4d7940f95 100644 --- a/sys/quad_math/qdivrem.c +++ b/sys/quad_math/qdivrem.c @@ -79,7 +79,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq) static volatile const unsigned int zero = 0; /* 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; if (arq) { diff --git a/sys/universal_address/universal_address.c b/sys/universal_address/universal_address.c index b581c9d302..56e4a292f1 100644 --- a/sys/universal_address/universal_address.c +++ b/sys/universal_address/universal_address.c @@ -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 * code is optimized out) */ 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) { if (universal_address_table[i].use_count == 0) { return &(universal_address_table[i]); diff --git a/tests/buttons/main.c b/tests/buttons/main.c index de18b9528d..6946ce728a 100644 --- a/tests/buttons/main.c +++ b/tests/buttons/main.c @@ -69,7 +69,7 @@ int main(void) puts("On-board button test\n"); /* cppcheck-suppress knownConditionTrueFalse - * rationale: board-dependent ifdefs */ + * (reason: board-dependent ifdefs) */ if (cnt == 0) { puts("[FAILED] no buttons available!"); return 2; diff --git a/tests/cpp11_condition_variable/main.cpp b/tests/cpp11_condition_variable/main.cpp index 7a1cff84e5..035190ed1d 100644 --- a/tests/cpp11_condition_variable/main.cpp +++ b/tests/cpp11_condition_variable/main.cpp @@ -53,7 +53,7 @@ int main() { { lock_guard lk(m); /* cppcheck-suppress unreadVariable - * (reason variable is read in the thread created above) */ + * (reason: variable is read in the thread created above) */ ready = true; cv.notify_one(); } diff --git a/tests/leds/main.c b/tests/leds/main.c index fc329a8146..8ff384870f 100644 --- a/tests/leds/main.c +++ b/tests/leds/main.c @@ -78,7 +78,7 @@ int main(void) puts("On-board LED test\n"); /* cppcheck-suppress knownConditionTrueFalse - * rationale: board-dependent ifdefs */ + * (reason: board-dependent ifdefs) */ if (numof == 0) { puts("NO LEDs AVAILABLE"); }