From 2ba795eb81935f936a9ed892b7c8d62a9bbaaa2e Mon Sep 17 00:00:00 2001 From: Matthias Kolja Miehl Date: Sun, 21 Aug 2016 02:14:01 +0200 Subject: [PATCH] cpu/stm32f0: uart: make sure that 'port' and 'dev' are !=NULL This fixes some cppcheck nullPointer errors. --- cpu/stm32f0/periph/uart.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpu/stm32f0/periph/uart.c b/cpu/stm32f0/periph/uart.c index 64f9aef80..20365cd6b 100644 --- a/cpu/stm32f0/periph/uart.c +++ b/cpu/stm32f0/periph/uart.c @@ -113,6 +113,12 @@ int init_base(uart_t uart, uint32_t baudrate) return -1; } + /* Make sure port and dev are != NULL here, i.e. that the variables are + * assigned in all non-returning branches of the switch at the top of this + * function. */ + assert(port != NULL); + assert(dev != NULL); + /* configure RX and TX pins, set pin to use alternative function mode */ port->MODER &= ~(3 << (rx_pin * 2) | 3 << (tx_pin * 2)); port->MODER |= 2 << (rx_pin * 2) | 2 << (tx_pin * 2);