From 07e9f61a9388149b1c3fbf3e89907e39728d6481 Mon Sep 17 00:00:00 2001 From: Jason Young Date: Tue, 13 Feb 2024 14:33:16 -0500 Subject: [PATCH] Revert "update cppcheck (#1859)" This reverts commit 54459e694eaa6dcc3f5eab0c4c9a15c6a88aa93d. --- .github/workflows/test.yaml | 2 +- board/can_definitions.h | 2 -- board/drivers/can_common.h | 4 ++-- board/drivers/usb.h | 34 +++++++++++++++++----------------- board/health.h | 6 +++--- board/main_comms.h | 6 +++--- tests/misra/install.sh | 5 +---- 7 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5f65560dd5..718aaa8a6d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -120,7 +120,7 @@ jobs: timeout-minutes: 1 run: ${{ env.RUN }} "cd tests/misra && ./test_misra.sh" - name: MISRA mutation tests - timeout-minutes: 4 + timeout-minutes: 3 run: ${{ env.RUN }} "cd tests/misra && ./test_mutation.py" python_linter: diff --git a/board/can_definitions.h b/board/can_definitions.h index db3d621706..daae4d0443 100644 --- a/board/can_definitions.h +++ b/board/can_definitions.h @@ -15,7 +15,6 @@ const uint8_t PANDA_BUS_CNT = 4U; #define CANPACKET_DATA_SIZE_MAX 8U #endif -#ifndef STM32F2 typedef struct { unsigned char reserved : 1; unsigned char bus : 3; @@ -27,7 +26,6 @@ typedef struct { unsigned char checksum; unsigned char data[CANPACKET_DATA_SIZE_MAX]; } __attribute__((packed, aligned(4))) CANPacket_t; -#endif const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index db77617e75..574c7cfd56 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -277,10 +277,10 @@ void can_send(CANPacket_t *to_push, uint8_t bus_number, bool skip_tx_hook) { } } -bool is_speed_valid(uint32_t speed, const uint32_t *all_speeds, uint8_t len) { +bool is_speed_valid(uint32_t speed, const uint32_t *speeds, uint8_t len) { bool ret = false; for (uint8_t i = 0U; i < len; i++) { - if (all_speeds[i] == speed) { + if (speeds[i] == speed) { ret = true; } } diff --git a/board/drivers/usb.h b/board/drivers/usb.h index ed74b93287..99ba126cec 100644 --- a/board/drivers/usb.h +++ b/board/drivers/usb.h @@ -79,7 +79,7 @@ void refresh_can_tx_slots_available(void); #define STS_SETUP_COMP 4 #define STS_SETUP_UPDT 6 -uint8_t response[USBPACKET_MAX_SIZE]; +uint8_t resp[USBPACKET_MAX_SIZE]; // for the repeating interfaces #define DSCR_INTERFACE_LEN 9 @@ -557,19 +557,19 @@ void usb_setup(void) { break; case STRING_OFFSET_ISERIAL: #ifdef UID_BASE - response[0] = 0x02 + (12 * 4); - response[1] = 0x03; + resp[0] = 0x02 + (12 * 4); + resp[1] = 0x03; // 96 bits = 12 bytes for (int i = 0; i < 12; i++){ uint8_t cc = ((uint8_t *)UID_BASE)[i]; - response[2 + (i * 4)] = to_hex_char((cc >> 4) & 0xFU); - response[2 + (i * 4) + 1] = '\0'; - response[2 + (i * 4) + 2] = to_hex_char((cc >> 0) & 0xFU); - response[2 + (i * 4) + 3] = '\0'; + resp[2 + (i * 4)] = to_hex_char((cc >> 4) & 0xFU); + resp[2 + (i * 4) + 1] = '\0'; + resp[2 + (i * 4) + 2] = to_hex_char((cc >> 0) & 0xFU); + resp[2 + (i * 4) + 3] = '\0'; } - USB_WritePacket(response, MIN(response[0], setup.b.wLength.w), 0); + USB_WritePacket(resp, MIN(resp[0], setup.b.wLength.w), 0); #else USB_WritePacket((const uint8_t *)string_serial_desc, MIN(sizeof(string_serial_desc), setup.b.wLength.w), 0); #endif @@ -599,10 +599,10 @@ void usb_setup(void) { } break; case USB_REQ_GET_STATUS: - // empty response? - response[0] = 0; - response[1] = 0; - USB_WritePacket((void*)&response, 2, 0); + // empty resp? + resp[0] = 0; + resp[1] = 0; + USB_WritePacket((void*)&resp, 2, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_REQ_SET_INTERFACE: @@ -648,10 +648,10 @@ void usb_setup(void) { control_req.param2 = setup.b.wIndex.w; control_req.length = setup.b.wLength.w; - resp_len = comms_control_handler(&control_req, response); + resp_len = comms_control_handler(&control_req, resp); // response pending if -1 was returned if (resp_len != -1) { - USB_WritePacket(response, MIN(resp_len, setup.b.wLength.w), 0); + USB_WritePacket(resp, MIN(resp_len, setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } } @@ -877,7 +877,7 @@ void usb_irqhandler(void) { print(" IN PACKET QUEUE\n"); #endif // TODO: always assuming max len, can we get the length? - USB_WritePacket((void *)response, comms_can_read(response, 0x40), 1); + USB_WritePacket((void *)resp, comms_can_read(resp, 0x40), 1); } break; @@ -888,9 +888,9 @@ void usb_irqhandler(void) { print(" IN PACKET QUEUE\n"); #endif // TODO: always assuming max len, can we get the length? - int len = comms_can_read(response, 0x40); + int len = comms_can_read(resp, 0x40); if (len > 0) { - USB_WritePacket((void *)response, len, 1); + USB_WritePacket((void *)resp, len, 1); } } break; diff --git a/board/health.h b/board/health.h index fc7661ca9c..8745cb0e70 100644 --- a/board/health.h +++ b/board/health.h @@ -21,10 +21,10 @@ struct __attribute__((packed)) health_t { uint8_t power_save_enabled_pkt; uint8_t heartbeat_lost_pkt; uint16_t alternative_experience_pkt; - float interrupt_load_pkt; + float interrupt_load; uint8_t fan_power; - uint8_t safety_rx_checks_invalid_pkt; - uint16_t spi_checksum_error_count_pkt; + uint8_t safety_rx_checks_invalid; + uint16_t spi_checksum_error_count; uint8_t fan_stall_count; uint16_t sbu1_voltage_mV; uint16_t sbu2_voltage_mV; diff --git a/board/main_comms.h b/board/main_comms.h index f535af662f..116f95d0ed 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -28,14 +28,14 @@ int get_health_pkt(void *dat) { health->alternative_experience_pkt = alternative_experience; health->power_save_enabled_pkt = power_save_status == POWER_SAVE_STATUS_ENABLED; health->heartbeat_lost_pkt = heartbeat_lost; - health->safety_rx_checks_invalid_pkt = safety_rx_checks_invalid; + health->safety_rx_checks_invalid = safety_rx_checks_invalid; - health->spi_checksum_error_count_pkt = spi_checksum_error_count; + health->spi_checksum_error_count = spi_checksum_error_count; health->fault_status_pkt = fault_status; health->faults_pkt = faults; - health->interrupt_load_pkt = interrupt_load; + health->interrupt_load = interrupt_load; health->fan_power = fan_state.power; health->fan_stall_count = fan_state.total_stall_count; diff --git a/tests/misra/install.sh b/tests/misra/install.sh index a29b111176..2139626450 100755 --- a/tests/misra/install.sh +++ b/tests/misra/install.sh @@ -9,11 +9,8 @@ if [ ! -d "$CPPCHECK_DIR" ]; then fi cd $CPPCHECK_DIR - VERS="2.13.0" -git fetch --all --tags +git fetch --tags origin $VERS git checkout $VERS -git cherry-pick -n f6b538e855f0bacea33c4074664628024ef39dc6 - #make clean make MATCHCOMPILTER=yes CXXFLAGS="-O2" -j8