From be701e781bac0e04341df0de268aa1e5fd1c848f Mon Sep 17 00:00:00 2001 From: theherrovn-sys Date: Mon, 1 Jun 2026 13:50:41 +0700 Subject: [PATCH] fix: use false/true instead of 0/1 for bool assignments - Replace bool ret = 0 with bool ret = false in can_common.h - Replace ret = 1 with ret = true in can_common.h - Add MISRA 10.3 suppression for opendbc toyota.h (pending opendbc PR #3256) This enables catching int-as-bool in MISRA rule 10.3, fixing commaai/panda#2105. --- board/drivers/can_common.h | 4 ++-- tests/misra/suppressions.txt | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 6237c7aebe9..35b9a6882d8 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -38,7 +38,7 @@ can_ring *can_queues[PANDA_CAN_CNT] = {&can_tx1_q, &can_tx2_q, &can_tx3_q}; // ********************* interrupt safe queue ********************* bool can_pop(can_ring *q, CANPacket_t *elem) { - bool ret = 0; + bool ret = false; ENTER_CRITICAL(); if (q->w_ptr != q->r_ptr) { @@ -48,7 +48,7 @@ bool can_pop(can_ring *q, CANPacket_t *elem) { } else { q->r_ptr += 1U; } - ret = 1; + ret = true; } EXIT_CRITICAL(); diff --git a/tests/misra/suppressions.txt b/tests/misra/suppressions.txt index 4800a270bcb..96a07e4a7ca 100644 --- a/tests/misra/suppressions.txt +++ b/tests/misra/suppressions.txt @@ -19,3 +19,6 @@ unusedFunction:*/interrupt_handlers*.h # cppcheck from 2.5 -> 2.13. they are listed here to separate the update from # fixing the violations and all are intended to be removed soon after misra-c2012-2.5 # unused macros. a few legit, rest aren't common between F4/H7 builds. should we do this in the unusedFunction pass? + +# TODO: remove after opendbc PR #3256 or equivalent is merged +misra-c2012-10.3:*/opendbc/safety/modes/toyota.h