From ddc25b0611a7ed7e5fe13baec983ea7b363ea968 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 18 Jun 2021 14:24:15 -0700 Subject: [PATCH] Update cppcheck and misra, suppress for now (#663) * Update cppcheck and misra, suppress for now * Add FIXME to suppression tags * Missed one spot --- Dockerfile.panda | 4 ++-- board/crc.h | 4 ++++ board/drivers/can.h | 30 ++++++++++++++++++++++-------- board/drivers/interrupts.h | 3 ++- board/drivers/llcan.h | 2 ++ board/drivers/registers.h | 2 ++ board/drivers/uart.h | 19 ++++++++++++++----- board/drivers/usb.h | 6 ++++++ board/gpio.h | 6 +++--- board/pedal/main.c | 5 ++--- board/power_saving.h | 4 ++++ board/safety/safety_chrysler.h | 7 ++++++- board/safety/safety_gm.h | 2 ++ board/safety/safety_honda.h | 4 ++++ board/safety/safety_hyundai.h | 5 ++++- board/safety/safety_mazda.h | 3 ++- board/safety/safety_nissan.h | 2 ++ board/safety/safety_subaru.h | 5 ++++- board/safety/safety_toyota.h | 3 ++- board/safety/safety_volkswagen.h | 6 ++++-- board/safety_declarations.h | 2 ++ tests/misra/suppressions.txt | 12 +++++++----- 22 files changed, 102 insertions(+), 34 deletions(-) diff --git a/Dockerfile.panda b/Dockerfile.panda index 25dadac5..f9f0f128 100644 --- a/Dockerfile.panda +++ b/Dockerfile.panda @@ -50,10 +50,10 @@ RUN pyenv install 3.8.5 && \ pip install --no-cache-dir -r /tmp/requirements.txt RUN cd /tmp && \ - git clone https://github.com/danmar/cppcheck.git && \ + git clone https://github.com/commaai/cppcheck.git && \ cd cppcheck && \ git fetch && \ - git checkout e46191e6e809272d8b34feca8999ee413f716b80 && \ + git checkout b440734ba7bda34c9d4e3cd2d9c26dc2303db542 && \ FILESDIR=/usr/share/cppcheck make -j4 install RUN cd /tmp && \ diff --git a/board/crc.h b/board/crc.h index ab969e51..d1f87f69 100644 --- a/board/crc.h +++ b/board/crc.h @@ -1,5 +1,9 @@ uint8_t crc_checksum(uint8_t *dat, int len, const uint8_t poly) { + // FIXME: + // cppcheck-suppress misra-c2012-7.2 uint8_t crc = 0xFF; + // FIXME: + // cppcheck-suppress misra-c2012-12.3 int i, j; for (i = len - 1; i >= 0; i--) { crc ^= dat[i]; diff --git a/board/drivers/can.h b/board/drivers/can.h index 2ca7cbc7..18fb8d4c 100644 --- a/board/drivers/can.h +++ b/board/drivers/can.h @@ -18,9 +18,13 @@ uint32_t can_rx_errs = 0; uint32_t can_send_errs = 0; uint32_t can_fwd_errs = 0; uint32_t gmlan_send_errs = 0; +// FIXME: +// cppcheck-suppress misra-c2012-12.3 extern int can_live, pending_can_live; // must reinit after changing these +// FIXME: +// cppcheck-suppress misra-c2012-12.3 extern int can_loopback, can_silent; extern uint32_t can_speed[4]; @@ -41,11 +45,13 @@ uint32_t ignition_can_cnt = 0U; #define ALL_CAN_SILENT 0xFF #define ALL_CAN_LIVE 0 - +// FIXME: +// cppcheck-suppress misra-c2012-12.3 int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = ALL_CAN_SILENT; // ********************* instantiate queues ********************* - +// FIXME: +// cppcheck-suppress misra-c2012-20.7 #define can_buffer(x, size) \ CAN_FIFOMailBox_TypeDef elems_##x[size]; \ can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = size, .elems = (CAN_FIFOMailBox_TypeDef *)&elems_##x }; @@ -55,6 +61,8 @@ can_buffer(tx1_q, 0x100) can_buffer(tx2_q, 0x100) can_buffer(tx3_q, 0x100) can_buffer(txgmlan_q, 0x100) +// FIXME: +// cppcheck-suppress misra-c2012-9.3 can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q}; // global CAN stats @@ -65,7 +73,8 @@ int can_err_cnt = 0; int can_overflow_cnt = 0; // ********************* interrupt safe queue ********************* - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = 0; @@ -286,7 +295,8 @@ void can_sce(CAN_TypeDef *CAN) { } // ***************************** CAN ***************************** - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 void process_can(uint8_t can_number) { if (can_number != 0xffU) { @@ -428,7 +438,8 @@ void CAN2_SCE_IRQ_Handler(void) { can_sce(CAN2); } void CAN3_TX_IRQ_Handler(void) { process_can(2); } void CAN3_RX0_IRQ_Handler(void) { can_rx(2); } void CAN3_SCE_IRQ_Handler(void) { can_sce(CAN3); } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 bool can_tx_check_min_slots_free(uint32_t min) { return (can_slots_empty(&can_tx1_q) >= min) && @@ -436,7 +447,8 @@ bool can_tx_check_min_slots_free(uint32_t min) { (can_slots_empty(&can_tx3_q) >= min) && (can_slots_empty(&can_txgmlan_q) >= min); } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook) { if (skip_tx_hook || safety_tx_hook(to_push) != 0) { if (bus_number < BUS_MAX) { @@ -452,11 +464,13 @@ void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx } } } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 void can_set_forwarding(int from, int to) { can_forwarding[from] = to; } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 bool can_init(uint8_t can_number) { bool ret = false; diff --git a/board/drivers/interrupts.h b/board/drivers/interrupts.h index f15c441a..2e5287d9 100644 --- a/board/drivers/interrupts.h +++ b/board/drivers/interrupts.h @@ -14,7 +14,8 @@ void unused_interrupt_handler(void) { #define NUM_INTERRUPTS 102U // There are 102 external interrupt sources (see stm32f413.h) interrupt interrupts[NUM_INTERRUPTS]; - +// FIXME: +// cppcheck-suppress misra-c2012-20.7 #define REGISTER_INTERRUPT(irq_num, func_ptr, call_rate, rate_fault) \ interrupts[irq_num].irq_type = irq_num; \ interrupts[irq_num].handler = func_ptr; \ diff --git a/board/drivers/llcan.h b/board/drivers/llcan.h index 01e9e258..c75faf99 100644 --- a/board/drivers/llcan.h +++ b/board/drivers/llcan.h @@ -14,6 +14,8 @@ #define GET_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0xFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) #define GET_BYTES_04(msg) ((msg)->RDLR) #define GET_BYTES_48(msg) ((msg)->RDHR) +// FIXME: +// cppcheck-suppress misra-c2012-20.7 #define GET_FLAG(value, mask) (((__typeof__(mask))value & mask) == mask) #define CAN_INIT_TIMEOUT_MS 500U diff --git a/board/drivers/registers.h b/board/drivers/registers.h index 76748295..94fef9ae 100644 --- a/board/drivers/registers.h +++ b/board/drivers/registers.h @@ -8,6 +8,8 @@ typedef struct reg { // 10 bit hash with 23 as a prime #define REGISTER_MAP_SIZE 0x3FFU #define HASHING_PRIME 23U +// FIXME: +// cppcheck-suppress misra-c2012-20.7 #define CHECK_COLLISION(hash, addr) (((uint32_t) register_map[hash].address != 0U) && (register_map[hash].address != addr)) reg register_map[REGISTER_MAP_SIZE]; diff --git a/board/drivers/uart.h b/board/drivers/uart.h index e4f23ead..afde2f5c 100644 --- a/board/drivers/uart.h +++ b/board/drivers/uart.h @@ -17,7 +17,8 @@ typedef struct uart_ring { void (*callback)(struct uart_ring*); bool dma_rx; } uart_ring; - +// FIXME: +// cppcheck-suppress misra-c2012-20.7 #define UART_BUFFER(x, size_rx, size_tx, uart_ptr, callback_ptr, rx_dma) \ uint8_t elems_rx_##x[size_rx]; \ uint8_t elems_tx_##x[size_tx]; \ @@ -270,7 +271,8 @@ void uart_set_baud(USART_TypeDef *u, unsigned int baud) { u->BRR = __USART_BRR(24000000U, baud); } } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 void uart_init(uart_ring *q, int baud) { // Register interrupts (max data rate: 115200 baud) if(q->uart == USART1){ @@ -315,7 +317,8 @@ void uart_init(uart_ring *q, int baud) { } // ************************* Low-level buffer functions ************************* - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 bool getc(uart_ring *q, char *elem) { bool ret = false; @@ -345,7 +348,8 @@ bool injectc(uart_ring *q, char elem) { return ret; } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 bool putc(uart_ring *q, char elem) { bool ret = false; uint16_t next_w_ptr; @@ -427,6 +431,8 @@ void putui(uint32_t i) { } void puth(unsigned int i) { + // FIXME: + // cppcheck-suppress misra-c2012-7.4 char c[] = "0123456789abcdef"; for (int pos = 28; pos != -4; pos -= 4) { putch(c[(i >> (unsigned int)(pos)) & 0xFU]); @@ -434,12 +440,15 @@ void puth(unsigned int i) { } void puth2(unsigned int i) { + // FIXME: + // cppcheck-suppress misra-c2012-7.4 char c[] = "0123456789abcdef"; for (int pos = 4; pos != -4; pos -= 4) { putch(c[(i >> (unsigned int)(pos)) & 0xFU]); } } - +// FIXME: +// cppcheck-suppress misra-c2012-8.2 void hexdump(const void *a, int l) { if (a != NULL) { for (int i=0; i < l; i++) { diff --git a/board/drivers/usb.h b/board/drivers/usb.h index e85af95a..48f0bd94 100644 --- a/board/drivers/usb.h +++ b/board/drivers/usb.h @@ -415,6 +415,8 @@ void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) { count32b = (len + 3U) / 4U; // TODO: revisit this + // FIXME: + // cppcheck-suppress misra-c2012-12.2 USBx_INEP(ep)->DIEPTSIZ = ((numpacket << 19) & USB_OTG_DIEPTSIZ_PKTCNT) | (len & USB_OTG_DIEPTSIZ_XFRSIZ); USBx_INEP(ep)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA); @@ -422,7 +424,11 @@ void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) { // load the FIFO const uint32_t *src_copy = (const uint32_t *)src; for (uint32_t i = 0; i < count32b; i++) { + // FIXME: + // cppcheck-suppress nullPointer USBx_DFIFO(ep) = *src_copy; + // FIXME: + // cppcheck-suppress nullPointerArithmetic src_copy++; } } diff --git a/board/gpio.h b/board/gpio.h index 01d3b8a3..589f4266 100644 --- a/board/gpio.h +++ b/board/gpio.h @@ -1,7 +1,7 @@ // Early bringup -#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef -#define ENTER_SOFTLOADER_MAGIC 0xdeadc0de -#define BOOT_NORMAL 0xdeadb111 +#define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU +#define ENTER_SOFTLOADER_MAGIC 0xdeadc0deU +#define BOOT_NORMAL 0xdeadb111U extern void *g_pfnVectors; extern uint32_t enter_bootloader_mode; diff --git a/board/pedal/main.c b/board/pedal/main.c index 3d7bd03a..02b98228 100644 --- a/board/pedal/main.c +++ b/board/pedal/main.c @@ -41,7 +41,7 @@ } #endif -#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef +#define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU uint32_t enter_bootloader_mode; // cppcheck-suppress unusedFunction ; used in headers not included in cppcheck @@ -136,8 +136,7 @@ uint32_t current_index = 0; #define FAULT_TIMEOUT 5U #define FAULT_INVALID 6U uint8_t state = FAULT_STARTUP; - -const uint8_t crc_poly = 0xD5; // standard crc8 +const uint8_t crc_poly = 0xD5U; // standard crc8 void CAN1_RX0_IRQ_Handler(void) { while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { diff --git a/board/power_saving.h b/board/power_saving.h index 2cb79cb6..a9649cd0 100644 --- a/board/power_saving.h +++ b/board/power_saving.h @@ -14,6 +14,8 @@ void set_power_save_state(int state) { if (state == POWER_SAVE_STATUS_ENABLED) { puts("enable power savings\n"); if (board_has_gps()) { + // FIXME: + // cppcheck-suppress misra-c2012-7.4 char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78"; uart_ring *ur = get_ring_by_number(1); for (unsigned int i = 0; i < sizeof(UBLOX_SLEEP_MSG) - 1U; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i])); @@ -21,6 +23,8 @@ void set_power_save_state(int state) { } else { puts("disable power savings\n"); if (board_has_gps()) { + // FIXME: + // cppcheck-suppress misra-c2012-7.4 char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a"; uart_ring *ur = get_ring_by_number(1); for (unsigned int i = 0; i < sizeof(UBLOX_WAKE_MSG) - 1U; i++) while (!putc(ur, UBLOX_WAKE_MSG[i])); diff --git a/board/safety/safety_chrysler.h b/board/safety/safety_chrysler.h index 044485cb..0941fd6f 100644 --- a/board/safety/safety_chrysler.h +++ b/board/safety/safety_chrysler.h @@ -7,7 +7,8 @@ const int CHRYSLER_MAX_TORQUE_ERROR = 80; // max torque cmd in excess of torq const int CHRYSLER_GAS_THRSLD = 30; // 7% more than 2m/s const int CHRYSLER_STANDSTILL_THRSLD = 10; // about 1m/s const CanMsg CHRYSLER_TX_MSGS[] = {{571, 0, 3}, {658, 0, 6}, {678, 0, 8}}; - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct chrysler_rx_checks[] = { {.msg = {{544, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, {.msg = {{514, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, @@ -25,9 +26,13 @@ static uint8_t chrysler_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { static uint8_t chrysler_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { /* This function does not want the checksum byte in the input data. jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */ + // FIXME: + // cppcheck-suppress misra-c2012-7.2 uint8_t checksum = 0xFF; int len = GET_LEN(to_push); for (int j = 0; j < (len - 1); j++) { + // FIXME: + // cppcheck-suppress misra-c2012-7.2 uint8_t shift = 0x80; uint8_t curr = (uint8_t)GET_BYTE(to_push, j); for (int i=0; i<8; i++) { diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index 0e9624dd..51478fc8 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -24,6 +24,8 @@ const CanMsg GM_TX_MSGS[] = {{384, 0, 4}, {1033, 0, 7}, {1034, 0, 7}, {715, 0, 8 {0x104c006c, 3, 3}, {0x10400060, 3, 5}}; // gmlan // TODO: do checksum and counter checks. Add correct timestep, 0.1s for now. +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct gm_rx_checks[] = { {.msg = {{388, 0, 8, .expected_timestep = 100000U}}}, {.msg = {{842, 0, 5, .expected_timestep = 100000U}}}, diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 1d851dc6..482b9a2e 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -25,6 +25,8 @@ const int HONDA_BOSCH_GAS_MAX = 2000; const int HONDA_BOSCH_ACCEL_MIN = -350; // max braking == -3.5m/s2 // Nidec and Bosch giraffe have pt on bus 0 +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct honda_rx_checks[] = { {.msg = {{0x1A6, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}, {0x296, 0, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}}}, @@ -34,6 +36,8 @@ AddrCheckStruct honda_rx_checks[] = { const int HONDA_RX_CHECKS_LEN = sizeof(honda_rx_checks) / sizeof(honda_rx_checks[0]); // Bosch harness has pt on bus 1 +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct honda_bh_rx_checks[] = { {.msg = {{0x296, 1, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}}}, {.msg = {{0x158, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}}}, diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index a5574c5e..f20c58ca 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -16,7 +16,8 @@ const CanMsg HYUNDAI_TX_MSGS[] = { // {905, 0, 8}, // SCC14, Bus 0 // {1186, 0, 8} // 4a2SCC, Bus 0 }; - + // FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct hyundai_rx_checks[] = { {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, {881, 0, 8, .expected_timestep = 10000U}}}, @@ -27,6 +28,8 @@ AddrCheckStruct hyundai_rx_checks[] = { const int HYUNDAI_RX_CHECK_LEN = sizeof(hyundai_rx_checks) / sizeof(hyundai_rx_checks[0]); // older hyundai models have less checks due to missing counters and checksums +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct hyundai_legacy_rx_checks[] = { {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, {881, 0, 8, .expected_timestep = 10000U}}}, diff --git a/board/safety/safety_mazda.h b/board/safety/safety_mazda.h index 12e92404..04b7bdb5 100644 --- a/board/safety/safety_mazda.h +++ b/board/safety/safety_mazda.h @@ -29,7 +29,8 @@ const CanMsg MAZDA_TX_MSGS[] = {{MAZDA_LKAS, 0, 8}, {MAZDA_CRZ_BTNS, 0, 8}}; bool mazda_lkas_allowed = false; - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct mazda_rx_checks[] = { {.msg = {{MAZDA_CRZ_CTRL, 0, 8, .expected_timestep = 20000U}}}, {.msg = {{MAZDA_CRZ_BTNS, 0, 8, .expected_timestep = 100000U}}}, diff --git a/board/safety/safety_nissan.h b/board/safety/safety_nissan.h index ca0f54e5..b54b6a12 100644 --- a/board/safety/safety_nissan.h +++ b/board/safety/safety_nissan.h @@ -14,6 +14,8 @@ const int NISSAN_DEG_TO_CAN = 100; const CanMsg NISSAN_TX_MSGS[] = {{0x169, 0, 8}, {0x2b1, 0, 8}, {0x4cc, 0, 8}, {0x20b, 2, 6}, {0x20b, 1, 6}, {0x280, 2, 8}}; // Signals duplicated below due to the fact that these messages can come in on either CAN bus, depending on car model. +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct nissan_rx_checks[] = { {.msg = {{0x2, 0, 5, .expected_timestep = 10000U}, {0x2, 1, 5, .expected_timestep = 10000U}}}, // STEER_ANGLE_SENSOR (100Hz) diff --git a/board/safety/safety_subaru.h b/board/safety/safety_subaru.h index b2e8c073..4483078e 100644 --- a/board/safety/safety_subaru.h +++ b/board/safety/safety_subaru.h @@ -14,7 +14,8 @@ const int SUBARU_L_DRIVER_TORQUE_FACTOR = 10; const CanMsg SUBARU_TX_MSGS[] = {{0x122, 0, 8}, {0x221, 0, 8}, {0x322, 0, 8}}; const int SUBARU_TX_MSGS_LEN = sizeof(SUBARU_TX_MSGS) / sizeof(SUBARU_TX_MSGS[0]); - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct subaru_rx_checks[] = { {.msg = {{ 0x40, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, {.msg = {{0x119, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}}}, @@ -28,6 +29,8 @@ const CanMsg SUBARU_L_TX_MSGS[] = {{0x161, 0, 8}, {0x164, 0, 8}}; const int SUBARU_L_TX_MSGS_LEN = sizeof(SUBARU_L_TX_MSGS) / sizeof(SUBARU_L_TX_MSGS[0]); // TODO: do checksum and counter checks after adding the signals to the outback dbc file +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct subaru_l_rx_checks[] = { {.msg = {{0x140, 0, 8, .expected_timestep = 10000U}}}, {.msg = {{0x371, 0, 8, .expected_timestep = 20000U}}}, diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 241e5798..b6120a50 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -33,7 +33,8 @@ const CanMsg TOYOTA_TX_MSGS[] = {{0x283, 0, 7}, {0x2E6, 0, 8}, {0x2E7, 0, 8}, {0 {0x128, 1, 6}, {0x141, 1, 4}, {0x160, 1, 8}, {0x161, 1, 7}, {0x470, 1, 4}, // DSU bus 1 {0x2E4, 0, 5}, {0x191, 0, 8}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, // LKAS + ACC {0x200, 0, 6}}; // interceptor - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct toyota_rx_checks[] = { {.msg = {{ 0xaa, 0, 8, .check_checksum = false, .expected_timestep = 12000U}}}, {.msg = {{0x260, 0, 8, .check_checksum = true, .expected_timestep = 20000U}}}, diff --git a/board/safety/safety_volkswagen.h b/board/safety/safety_volkswagen.h index 3df1fcbd..0b2f4d95 100644 --- a/board/safety/safety_volkswagen.h +++ b/board/safety/safety_volkswagen.h @@ -20,7 +20,8 @@ const int VOLKSWAGEN_DRIVER_TORQUE_FACTOR = 3; // Transmit of GRA_ACC_01 is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration const CanMsg VOLKSWAGEN_MQB_TX_MSGS[] = {{MSG_HCA_01, 0, 8}, {MSG_GRA_ACC_01, 0, 8}, {MSG_GRA_ACC_01, 2, 8}, {MSG_LDW_02, 0, 8}}; const int VOLKSWAGEN_MQB_TX_MSGS_LEN = sizeof(VOLKSWAGEN_MQB_TX_MSGS) / sizeof(VOLKSWAGEN_MQB_TX_MSGS[0]); - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct volkswagen_mqb_rx_checks[] = { {.msg = {{MSG_ESP_19, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}}}, {.msg = {{MSG_LH_EPS_03, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, @@ -42,7 +43,8 @@ const int VOLKSWAGEN_MQB_RX_CHECKS_LEN = sizeof(volkswagen_mqb_rx_checks) / size // Transmit of GRA_Neu is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration const CanMsg VOLKSWAGEN_PQ_TX_MSGS[] = {{MSG_HCA_1, 0, 5}, {MSG_GRA_NEU, 0, 4}, {MSG_GRA_NEU, 2, 4}, {MSG_LDW_1, 0, 8}}; const int VOLKSWAGEN_PQ_TX_MSGS_LEN = sizeof(VOLKSWAGEN_PQ_TX_MSGS) / sizeof(VOLKSWAGEN_PQ_TX_MSGS[0]); - +// FIXME: +// cppcheck-suppress misra-c2012-9.3 AddrCheckStruct volkswagen_pq_rx_checks[] = { {.msg = {{MSG_LENKHILFE_3, 0, 6, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}}}, {.msg = {{MSG_MOTOR_2, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 20000U}}}, diff --git a/board/safety_declarations.h b/board/safety_declarations.h index 3f8221c9..0948382e 100644 --- a/board/safety_declarations.h +++ b/board/safety_declarations.h @@ -6,6 +6,8 @@ struct sample_t { int values[6]; int min; int max; + // FIXME: + // cppcheck-suppress misra-c2012-9.4 } sample_t_default = {{0}, 0, 0}; // safety code requires floats diff --git a/tests/misra/suppressions.txt b/tests/misra/suppressions.txt index 0a479bc5..44e59ace 100644 --- a/tests/misra/suppressions.txt +++ b/tests/misra/suppressions.txt @@ -1,10 +1,12 @@ # Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well -misra.11.4 +misra-c2012-11.4 # Advisory: casting from void pointer to type pointer is ok. Done by STM libraries as well -misra.11.5 +misra-c2012-11.5 # Advisory: as stated in the Misra document, use of goto statements in accordance to 15.2 and 15.3 is ok -misra.15.1 +misra-c2012-15.1 # Advisory: union types can be used -misra.19.2 +misra-c2012-19.2 +# Advisory: The # and ## preprocessor operators should not be used +misra-c2012-20.10 # Required: it's ok re-defining potentially reserved Macro names. Not likely to cause confusion -misra.21.1 +misra-c2012-21.1 \ No newline at end of file