Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable misra-c2012-21.2 #1819

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions board/drivers/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion board/jungle/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion board/jungle/main_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions board/libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions board/main_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions board/pedal/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/misra/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Loading