diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 778a8d75ea..8756559660 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -214,7 +214,7 @@ void TriggerStateWithRunningStatistics::movePreSynchTimestamps(DECLARE_ENGINE_PA float TriggerStateWithRunningStatistics::calculateInstantRpm(TriggerFormDetails *triggerFormDetails, int *prevIndexOut, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { int current_index = currentCycle.current_index; // local copy so that noone changes the value on us - assertIsInBounds(current_index, timeOfLastEvent, "calc timeOfLastEvent"); + assertIsInBoundsWithResult(current_index, timeOfLastEvent, "calc timeOfLastEvent", 0); timeOfLastEvent[current_index] = nowNt; /** * Here we calculate RPM based on last 90 degrees @@ -251,7 +251,7 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(TriggerFormDetails return prevInstantRpmValue; float instantRpm = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time; - assertIsInBounds(current_index, instantRpmValue, "instantRpmValue"); + assertIsInBoundsWithResult(current_index, instantRpmValue, "instantRpmValue", 0); instantRpmValue[current_index] = instantRpm; // This fixes early RPM instability based on incomplete data diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 258333ea36..14403436ee 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -107,6 +107,8 @@ constexpr size_t size(const T(&)[N]) { #define assertIsInBounds(length, array, msg) efiAssertVoid(OBD_PCM_Processor_Fault, (length) >= 0 && (length) < efi::size(array), msg) +#define assertIsInBoundsWithResult(length, array, msg, failedResult) efiAssert(OBD_PCM_Processor_Fault, (length) >= 0 && (length) < efi::size(array), msg, failedResult) + /** * Copies an array from src to dest. The lengths of the arrays must match. */