From 909a17caef8a4f1cfa59ef019f5959405281b65d Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Sun, 5 May 2024 18:45:25 +0300 Subject: [PATCH] adc: fix unit tests --- unit_tests/adc_inputs.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/unit_tests/adc_inputs.h b/unit_tests/adc_inputs.h index 7a3a83455e..f2420cc6d6 100644 --- a/unit_tests/adc_inputs.h +++ b/unit_tests/adc_inputs.h @@ -10,18 +10,16 @@ #include "rusefi_hw_enums.h" inline bool isAdcChannelValid(adc_channel_e hwChannel) { - if (hwChannel <= EFI_ADC_NONE) { - return false; - } else if (hwChannel >= EFI_ADC_LAST_CHANNEL) { + /* Compiler will optimize, keep following if as a reminder */ + if (hwChannel >= EFI_ADC_TOTAL_CHANNELS) { /* this should not happen! * if we have enum out of range somewhere in settings * that means something goes terribly wrong * TODO: should we say something? */ return false; - } else { - return true; } + return ((hwChannel > EFI_ADC_NONE) && (hwChannel < EFI_ADC_TOTAL_CHANNELS)); } #define adcToVoltsDivided(adc) (adcToVolts(adc) * engineConfiguration->analogInputDividerCoefficient)