Skip to content

Commit

Permalink
Revert "update cppcheck (commaai#1859)"
Browse files Browse the repository at this point in the history
This reverts commit 54459e6.
  • Loading branch information
jyoung8607 committed Feb 13, 2024
1 parent 4480ba8 commit 07e9f61
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions board/can_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};

Expand Down
4 changes: 2 additions & 2 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
34 changes: 17 additions & 17 deletions board/drivers/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions board/health.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions board/main_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions tests/misra/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 07e9f61

Please sign in to comment.