Skip to content

Commit

Permalink
enable misra-c2012-10.4 (commaai#1796)
Browse files Browse the repository at this point in the history
* enable misrac-10.4

* changes

* cleaner
  • Loading branch information
bongbui321 authored Jan 13, 2024
1 parent 3ef9c3f commit 817d68f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion board/drivers/fdcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ void process_can(uint8_t can_number) {
fifo = (canfd_fifo *)(TxFIFOSA + (tx_index * FDCAN_TX_FIFO_EL_SIZE));

fifo->header[0] = (to_send.extended << 30) | ((to_send.extended != 0U) ? (to_send.addr) : (to_send.addr << 18));
fifo->header[1] = (to_send.data_len_code << 16) | (bus_config[can_number].canfd_enabled << 21) | (bus_config[can_number].brs_enabled << 20);
uint32_t canfd_enabled_header = bus_config[can_number].canfd_enabled ? (1 << 21) : 0;
uint32_t brs_enabled_header = bus_config[can_number].brs_enabled ? (1 << 20) : 0;
fifo->header[1] = (to_send.data_len_code << 16) | canfd_enabled_header | brs_enabled_header;

uint8_t data_len_w = (dlc_to_len[to_send.data_len_code] / 4U);
data_len_w += ((dlc_to_len[to_send.data_len_code] % 4U) > 0U) ? 1U : 0U;
Expand Down
4 changes: 2 additions & 2 deletions board/drivers/gmlan_alt.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int do_bitstuff(char *out, char *in, int in_len) {
j++;

// do the stuffing
if (bit == last_bit) {
if (bit == (char)last_bit) {
bit_cnt++;
if (bit_cnt == 5) {
// 5 in a row the same, do stuff
Expand Down Expand Up @@ -205,7 +205,7 @@ void TIM12_IRQ_Handler(void) {
bool retry = 0;
// in send loop
if ((gmlan_sending > 0) && // not first bit
((read == 0) && (pkt_stuffed[gmlan_sending-1] == 1)) && // bus wrongly dominant
((read == 0) && (pkt_stuffed[gmlan_sending-1] == (char)1)) && // bus wrongly dominant
(gmlan_sending != (gmlan_sendmax - 11))) { //not ack bit
print("GMLAN ERR: bus driven at ");
puth(gmlan_sending);
Expand Down
4 changes: 2 additions & 2 deletions board/drivers/harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void set_intercept_relay(bool intercept, bool ignition_relay) {
}

// wait until we're not reading the analog voltages anymore
while (harness.sbu_adc_lock == true) {}
while (harness.sbu_adc_lock) {}

if (harness.status == HARNESS_STATUS_NORMAL) {
set_gpio_output(current_board->harness_config->GPIO_relay_SBU1, current_board->harness_config->pin_relay_SBU1, !ignition_relay);
Expand All @@ -59,7 +59,7 @@ bool harness_check_ignition(void) {
bool ret = false;

// wait until we're not reading the analog voltages anymore
while (harness.sbu_adc_lock == true) {}
while (harness.sbu_adc_lock) {}

switch(harness.status){
case HARNESS_STATUS_NORMAL:
Expand Down
2 changes: 1 addition & 1 deletion board/safety/safety_nissan.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static bool nissan_tx_hook(CANPacket_t *to_send) {
bool lka_active = (GET_BYTE(to_send, 6) >> 4) & 1U;

// Factor is -0.01, offset is 1310. Flip to correct sign, but keep units in CAN scale
desired_angle = -desired_angle + (1310 * NISSAN_STEERING_LIMITS.angle_deg_to_can);
desired_angle = -desired_angle + (1310.0f * NISSAN_STEERING_LIMITS.angle_deg_to_can);

if (steer_angle_cmd_checks(desired_angle, lka_active, NISSAN_STEERING_LIMITS)) {
violation = true;
Expand Down
1 change: 0 additions & 1 deletion tests/misra/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ misra-c2012-8.6
misra-c2012-10.1
misra-c2012-10.6
misra-c2012-10.3
misra-c2012-10.4
misra-c2012-10.5
misra-c2012-10.7
misra-c2012-12.2
Expand Down

0 comments on commit 817d68f

Please sign in to comment.