diff --git a/board/drivers/uart.h b/board/drivers/uart.h index 0eae2a4a63..b62bc97998 100644 --- a/board/drivers/uart.h +++ b/board/drivers/uart.h @@ -69,7 +69,7 @@ uart_ring *get_ring_by_number(int a) { } // ************************* Low-level buffer functions ************************* -bool getc(uart_ring *q, char *elem) { +bool get_char(uart_ring *q, char *elem) { bool ret = false; ENTER_CRITICAL(); @@ -105,7 +105,7 @@ bool injectc(uart_ring *q, char elem) { return ret; } -bool putc(uart_ring *q, char elem) { +bool put_char(uart_ring *q, char elem) { bool ret = false; uint16_t next_w_ptr; diff --git a/board/jungle/main.c b/board/jungle/main.c index 3ab39ba1d6..25e2147276 100644 --- a/board/jungle/main.c +++ b/board/jungle/main.c @@ -31,7 +31,7 @@ void debug_ring_callback(uart_ring *ring) { char rcv; - while (getc(ring, &rcv)) { + while (get_char(ring, &rcv)) { (void)injectc(ring, rcv); } } diff --git a/board/jungle/main_comms.h b/board/jungle/main_comms.h index 49d16e5745..737c90840c 100644 --- a/board/jungle/main_comms.h +++ b/board/jungle/main_comms.h @@ -192,7 +192,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { // **** 0xe0: debug read case 0xe0: // read - while ((resp_len < MIN(req->length, USBPACKET_MAX_SIZE)) && getc(get_ring_by_number(0), (char*)&resp[resp_len])) { + while ((resp_len < MIN(req->length, USBPACKET_MAX_SIZE)) && get_char(get_ring_by_number(0), (char*)&resp[resp_len])) { ++resp_len; } break; diff --git a/board/libc.h b/board/libc.h index 1e32d4206e..7f669b95ab 100644 --- a/board/libc.h +++ b/board/libc.h @@ -5,6 +5,7 @@ void delay(uint32_t a) { for (i = 0; i < a; i++); } +// cppcheck-suppress misra-c2012-21.2 void *memset(void *str, int c, unsigned int n) { uint8_t *s = str; for (unsigned int i = 0; i < n; i++) { @@ -17,6 +18,7 @@ void *memset(void *str, int c, unsigned int n) { #define UNALIGNED(X, Y) \ (((uint32_t)(X) & (sizeof(uint32_t) - 1U)) | ((uint32_t)(Y) & (sizeof(uint32_t) - 1U))) +// cppcheck-suppress misra-c2012-21.2 void *memcpy(void *dest, const void *src, unsigned int len) { unsigned int n = len; uint8_t *d8 = dest; @@ -48,6 +50,7 @@ void *memcpy(void *dest, const void *src, unsigned int len) { return dest; } +// cppcheck-suppress misra-c2012-21.2 int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { int ret = 0; const uint8_t *p1 = ptr1; diff --git a/board/main.c b/board/main.c index 4fdb98d4a5..b9f12bff8f 100644 --- a/board/main.c +++ b/board/main.c @@ -40,8 +40,8 @@ bool check_started(void) { void debug_ring_callback(uart_ring *ring) { char rcv; - while (getc(ring, &rcv)) { - (void)putc(ring, rcv); // misra-c2012-17.7: cast to void is ok: debug function + while (get_char(ring, &rcv)) { + (void)put_char(ring, rcv); // misra-c2012-17.7: cast to void is ok: debug function // only allow bootloader entry on debug builds #ifdef ALLOW_DEBUG diff --git a/board/main_comms.h b/board/main_comms.h index e5ba719faf..6fd2037870 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -60,7 +60,7 @@ void comms_endpoint2_write(uint8_t *data, uint32_t len) { if ((len != 0U) && (ur != NULL)) { if ((data[0] < 2U) || (data[0] >= 4U)) { for (uint32_t i = 1; i < len; i++) { - while (!putc(ur, data[i])) { + while (!put_char(ur, data[i])) { // wait } } @@ -325,7 +325,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { // read while ((resp_len < MIN(req->length, USBPACKET_MAX_SIZE)) && - getc(ur, (char*)&resp[resp_len])) { + get_char(ur, (char*)&resp[resp_len])) { ++resp_len; } break; diff --git a/board/pedal/main.c b/board/pedal/main.c index 0c8be8a0d8..132044b705 100644 --- a/board/pedal/main.c +++ b/board/pedal/main.c @@ -36,8 +36,8 @@ void __initialize_hardware_early(void) { void debug_ring_callback(uart_ring *ring) { char rcv; - while (getc(ring, &rcv) != 0) { - (void)putc(ring, rcv); + while (get_char(ring, &rcv) != 0) { + (void)put_char(ring, rcv); } } @@ -73,7 +73,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { } // read while ((resp_len < MIN(req->length, USBPACKET_MAX_SIZE)) && - getc(ur, (char*)&resp[resp_len])) { + get_char(ur, (char*)&resp[resp_len])) { ++resp_len; } break; diff --git a/tests/misra/suppressions.txt b/tests/misra/suppressions.txt index a77a3d8a6d..4f51e0e2c2 100644 --- a/tests/misra/suppressions.txt +++ b/tests/misra/suppressions.txt @@ -32,7 +32,6 @@ misra-c2012-10.3 misra-c2012-10.5 misra-c2012-12.2 misra-c2012-17.3 -misra-c2012-21.2 misra-c2012-21.15 misra-c2012-21.16