diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index ce856008f4..362db1a5b5 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -356,7 +356,7 @@ static void showFsioInfo(void) { static void setFsioFrequency(int index, int frequency) { index--; - if (index < 0 || index > LE_COMMAND_COUNT) { + if (index < 0 || index >= LE_COMMAND_COUNT) { scheduleMsg(&logger, "invalid index %d", index); return; } @@ -366,7 +366,7 @@ static void setFsioFrequency(int index, int frequency) { static void setFsioPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr) - 1; - if (index < 0 || index > LE_COMMAND_COUNT) { + if (index < 0 || index >= LE_COMMAND_COUNT) { scheduleMsg(&logger, "invalid index %d", index); return; } @@ -382,7 +382,7 @@ static void setFsioPin(const char *indexStr, const char *pinName) { static void setUserOutput(const char *indexStr, const char *quotedLine, Engine *engine) { int index = atoi(indexStr) - 1; - if (index < 0 || index > LE_COMMAND_COUNT) { + if (index < 0 || index >= LE_COMMAND_COUNT) { scheduleMsg(&logger, "invalid index %d", index); return; } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index cef24c3fba..19a6d2b314 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -463,7 +463,7 @@ static void setPotSpi(int spi) { static void setIgnitionPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr) - 1; // convert from human index into software index - if (index < 0 || index > IGNITION_PIN_COUNT) + if (index < 0 || index >= IGNITION_PIN_COUNT) return; brain_pin_e pin = parseBrainPin(pinName); // todo: extract method - code duplication with other 'set_xxx_pin' methods? @@ -500,7 +500,7 @@ static void setFuelPumpPin(const char *pinName) { static void setInjectionPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr) - 1; // convert from human index into software index - if (index < 0 || index > INJECTION_PIN_COUNT) + if (index < 0 || index >= INJECTION_PIN_COUNT) return; brain_pin_e pin = parseBrainPin(pinName); // todo: extract method - code duplication with other 'set_xxx_pin' methods? @@ -528,7 +528,7 @@ static void setTriggerInputPin(const char *indexStr, const char *pinName) { static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) { int index = atoi(indexStr); - if (index < 0 || index > TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE) { + if (index < 0 || index >= TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE) { return; } int mode = atoi(modeCode); @@ -540,7 +540,7 @@ static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) static void setEgtCSPin(const char *indexStr, const char *pinName, board_configuration_s * board_configuration_s) { int index = atoi(indexStr); - if (index < 0 || index > MAX31855_CS_COUNT || absI(index) == ERROR_CODE) + if (index < 0 || index >= MAX31855_CS_COUNT || absI(index) == ERROR_CODE) return; brain_pin_e pin = parseBrainPin(pinName); if (pin == GPIO_INVALID) { @@ -553,7 +553,7 @@ static void setEgtCSPin(const char *indexStr, const char *pinName, board_configu static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr); - if (index < 0 || index > TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE) + if (index < 0 || index >= TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE) return; brain_pin_e pin = parseBrainPin(pinName); if (pin == GPIO_INVALID) {