From 24559473d63dd881dd5b08673b2916930b6cae1b Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Mar 2017 17:54:03 -0400 Subject: [PATCH] improving internal consistency validation --- firmware/controllers/algo/engine.h | 1 + firmware/controllers/algo/engine_configuration.cpp | 2 ++ firmware/controllers/math/engine_math.cpp | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index ed42b84b96..25b2011aa9 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -436,5 +436,6 @@ void prepareShapes(DECLARE_ENGINE_PARAMETER_F); void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_S); void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S); void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F); +void assertEngineReference(DECLARE_ENGINE_PARAMETER_F); #endif /* H_ENGINE_H_ */ diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index eb9c1289ab..70b5e0eb57 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1068,6 +1068,8 @@ void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S scheduleMsg(logger, "applyNonPersistentConfiguration()"); #endif + assertEngineReference(PASS_ENGINE_PARAMETER_F); + #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) engine->triggerCentral.triggerShape.initializeTriggerShape(logger PASS_ENGINE_PARAMETER); #endif diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 8e253db55f..fab142f868 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -507,3 +507,7 @@ void setAlgorithm(engine_load_mode_e algo DECLARE_ENGINE_PARAMETER_S) { void setInjectorLag(float value DECLARE_ENGINE_PARAMETER_S) { setArrayValues(engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE, value); } + +void assertEngineReference(DECLARE_ENGINE_PARAMETER_F) { + efiAssertVoid(engine != NULL, "engine is NULL"); +}