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-10.6 #1811

Merged
merged 16 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions board/drivers/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ int current_int0_alt_setting = 0;

void *USB_ReadPacket(void *dest, uint16_t len) {
uint32_t *dest_copy = (uint32_t *)dest;
uint32_t count32b = (len + 3U) / 4U;
uint16_t count32b = (len + 3U) / 4U;

for (uint32_t i = 0; i < count32b; i++) {
*dest_copy = USBx_DFIFO(0);
Expand All @@ -384,8 +384,8 @@ void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) {
hexdump(src, len);
#endif

uint32_t numpacket = (len + (USBPACKET_MAX_SIZE - 1U)) / USBPACKET_MAX_SIZE;
uint32_t count32b = 0;
uint16_t numpacket = (len + (USBPACKET_MAX_SIZE - 1U)) / USBPACKET_MAX_SIZE;
uint16_t count32b = 0;
count32b = (len + 3U) / 4U;

// TODO: revisit this
Expand Down
4 changes: 2 additions & 2 deletions board/safety/safety_chrysler.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void chrysler_rx_hook(CANPacket_t *to_push) {
}

// enter controls on rising edge of ACC, exit controls on ACC off
const int das_3_bus = (chrysler_platform == CHRYSLER_PACIFICA) ? 0 : 2;
const int das_3_bus = (chrysler_platform == CHRYSLER_PACIFICA) ? (int) 0 : (int) 2;
0x41head marked this conversation as resolved.
Show resolved Hide resolved
if ((bus == das_3_bus) && (addr == chrysler_addrs->DAS_3)) {
bool cruise_engaged = GET_BIT(to_push, 21U) == 1U;
pcm_cruise_check(cruise_engaged);
Expand Down Expand Up @@ -219,7 +219,7 @@ static bool chrysler_tx_hook(CANPacket_t *to_send) {

// STEERING
if (addr == chrysler_addrs->LKAS_COMMAND) {
int start_byte = (chrysler_platform == CHRYSLER_PACIFICA) ? 0 : 1;
int start_byte = (chrysler_platform == CHRYSLER_PACIFICA) ? (int) 0 : (int) 1;
int desired_torque = ((GET_BYTE(to_send, start_byte) & 0x7U) << 8) | GET_BYTE(to_send, start_byte + 1);
desired_torque -= 1024;

Expand Down
2 changes: 1 addition & 1 deletion board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void honda_rx_hook(CANPacket_t *to_push) {
}
}

int bus_rdr_car = (honda_hw == HONDA_BOSCH) ? 0 : 2; // radar bus, car side
int bus_rdr_car = (honda_hw == HONDA_BOSCH) ? (int)0 : (int)2; // radar bus, car side
bool stock_ecu_detected = false;

// If steering controls messages are received on the destination bus, it's an indication
Expand Down
8 changes: 4 additions & 4 deletions board/safety/safety_hyundai_canfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static void hyundai_canfd_rx_hook(CANPacket_t *to_push) {
int bus = GET_BUS(to_push);
int addr = GET_ADDR(to_push);

const int pt_bus = hyundai_canfd_hda2 ? 1 : 0;
const int pt_bus = hyundai_canfd_hda2 ? (int) 1 : (int) 0;
const int scc_bus = hyundai_camera_scc ? 2 : pt_bus;

if (bus == pt_bus) {
Expand All @@ -168,7 +168,7 @@ static void hyundai_canfd_rx_hook(CANPacket_t *to_push) {
}

// cruise buttons
const int button_addr = hyundai_canfd_alt_buttons ? 0x1aa : 0x1cf;
const int button_addr = hyundai_canfd_alt_buttons ? (int) 0x1aa : (int) 0x1cf;
if (addr == button_addr) {
int main_button = 0;
int cruise_button = 0;
Expand Down Expand Up @@ -220,7 +220,7 @@ static void hyundai_canfd_rx_hook(CANPacket_t *to_push) {
if (hyundai_longitudinal) {
// on HDA2, ensure ADRV ECU is still knocked out
// on others, ensure accel msg is blocked from camera
const int stock_scc_bus = hyundai_canfd_hda2 ? 1 : 0;
const int stock_scc_bus = hyundai_canfd_hda2 ? (int) 1 : (int) 0;
stock_ecu_detected = stock_ecu_detected || ((addr == 0x1a0) && (bus == stock_scc_bus));
}
generic_rx_checks(stock_ecu_detected);
Expand Down Expand Up @@ -294,7 +294,7 @@ static int hyundai_canfd_fwd_hook(int bus_num, int addr) {
}
if (bus_num == 2) {
// LKAS for HDA2, LFA for HDA1
int hda2_lfa_block_addr = hyundai_canfd_hda2_alt_steering ? 0x362 : 0x2a4;
int hda2_lfa_block_addr = hyundai_canfd_hda2_alt_steering ? (int) 0x362 : (int) 0x2a4;
bool is_lkas_msg = ((addr == hyundai_canfd_hda2_get_lkas_addr()) || (addr == hda2_lfa_block_addr)) && hyundai_canfd_hda2;
bool is_lfa_msg = ((addr == 0x12a) && !hyundai_canfd_hda2);

Expand Down
2 changes: 1 addition & 1 deletion board/safety/safety_subaru.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static uint32_t subaru_compute_checksum(CANPacket_t *to_push) {

static void subaru_rx_hook(CANPacket_t *to_push) {
const int bus = GET_BUS(to_push);
const int alt_main_bus = subaru_gen2 ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS;
const int alt_main_bus = subaru_gen2 ? (int) SUBARU_ALT_BUS : (int) SUBARU_MAIN_BUS;

int addr = GET_ADDR(to_push);
if ((addr == MSG_SUBARU_Steering_Torque) && (bus == SUBARU_MAIN_BUS)) {
Expand Down
4 changes: 2 additions & 2 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void tesla_rx_hook(CANPacket_t *to_push) {
}

if (bus == 2) {
int das_control_addr = (tesla_powertrain ? 0x2bf : 0x2b9);
int das_control_addr = (tesla_powertrain ? (int) 0x2bf : (int) 0x2b9);
if (tesla_longitudinal && (addr == das_control_addr)) {
// "AEB_ACTIVE"
tesla_stock_aeb = ((GET_BYTE(to_push, 2) & 0x03U) == 1U);
Expand Down Expand Up @@ -184,7 +184,7 @@ static int tesla_fwd_hook(int bus_num, int addr) {

if(bus_num == 2) {
// Autopilot to chassis/PT
int das_control_addr = (tesla_powertrain ? 0x2bf : 0x2b9);
int das_control_addr = (tesla_powertrain ? (int) 0x2bf : (int) 0x2b9);

bool block_msg = false;
if (!tesla_powertrain && (addr == 0x488)) {
Expand Down
2 changes: 1 addition & 1 deletion board/safety/safety_volkswagen_pq.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static uint32_t volkswagen_pq_compute_checksum(CANPacket_t *to_push) {
int addr = GET_ADDR(to_push);
int len = GET_LEN(to_push);
uint8_t checksum = 0U;
int checksum_byte = (addr == MSG_MOTOR_5) ? 7 : 0;
int checksum_byte = (addr == MSG_MOTOR_5) ? (int) 7 : (int) 0;

// Simple XOR over the payload, except for the byte where the checksum lives.
for (int i = 0; i < len; i++) {
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-7.2
misra-c2012-8.2
misra-c2012-8.4
misra-c2012-8.6
misra-c2012-10.6
misra-c2012-10.3
misra-c2012-10.5
misra-c2012-10.7
Expand Down
Loading