From c6f45c50224d7e24720f335162fd9958fdf9d524 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 31 Jan 2022 15:37:42 -0800 Subject: [PATCH] warnings fixes (#3851) * unused things * !!! actual bug !!! * dead * unused * unused * multi-bus lua RX was just broken * make the compiler angry about it * dead config * alphax 2 * just call, no store * compiler too angry --- .../alphax-2chan/board_configuration.cpp | 2 +- .../controllers/algo/engine_configuration.cpp | 2 +- firmware/controllers/bench_test.cpp | 4 +-- firmware/controllers/can/can_rx.cpp | 6 ++-- firmware/controllers/core/engine_module.h | 2 +- firmware/controllers/core/fsio_impl.cpp | 25 ------------- .../controllers/engine_cycle/knock_logic.cpp | 2 ++ .../engine_cycle/map_averaging.cpp | 1 - firmware/controllers/flash_main.cpp | 4 +-- firmware/controllers/lua/lua_can_rx.cpp | 35 +++++++++++-------- firmware/controllers/lua/lua_hooks.cpp | 2 +- firmware/controllers/lua/lua_hooks_util.cpp | 2 +- firmware/controllers/sensors/map.cpp | 2 -- .../digital_input/digital_input_exti.cpp | 2 +- .../mass_storage/mass_storage_init.cpp | 12 ++++--- firmware/init/sensor/init_map.cpp | 2 +- firmware/integration/rusefi_config.txt | 4 +-- 17 files changed, 46 insertions(+), 63 deletions(-) diff --git a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp index a979ea18d3..a95a847b91 100644 --- a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp @@ -103,7 +103,7 @@ void boardInitHardware() { boardOnConfigurationChange(nullptr); } -void boardOnConfigurationChange(engine_configuration_s *previousConfiguration) { +void boardOnConfigurationChange(engine_configuration_s * /*previousConfiguration*/) { alphaTachPullUp.setValue(engineConfiguration->boardUseTachPullUp); alphaTempPullUp.setValue(engineConfiguration->boardUseTempPullUp); alphaCrankPPullUp.setValue(engineConfiguration->boardUseCrankPullUp); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 1aca4aeb33..51809f37f6 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -158,7 +158,7 @@ void onBurnRequest() { } // Weak link a stub so that every board doesn't have to implement this function -__attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s *previousConfiguration) { } +__attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s* /*previousConfiguration*/) { } /** * this is the top-level method which should be called in case of any changes to engine configuration diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index 8d0f7a9228..b96943f54d 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -161,8 +161,8 @@ static void doTestSolenoid(int humanIndex, const char *delayStr, const char * on pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.tcuSolenoids[humanIndex - 1], b); } -static void doBenchTestFsio(int humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr, - const char *countStr) { +static void doBenchTestFsio(int /*humanIndex*/, const char * /*delayStr*/, const char * /*onTimeStr*/, const char * /*offTimeStr*/, + const char * /*countStr*/) { // if (humanIndex < 1 || humanIndex > FSIO_COMMAND_COUNT) { // efiPrintf("Invalid index: %d", humanIndex); // return; diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp index f30b1934f1..d9093c18d8 100644 --- a/firmware/controllers/can/can_rx.cpp +++ b/firmware/controllers/can/can_rx.cpp @@ -14,7 +14,7 @@ typedef float SCRIPT_TABLE_8x8_f32t_linear[SCRIPT_TABLE_8 * SCRIPT_TABLE_8]; -bool acceptCanRx(int sid) { +bool acceptCanRx(int /*sid*/) { if (!engineConfiguration->usescriptTableForCanSniffingFiltering) { // accept anything if filtering is not enabled return true; @@ -115,7 +115,7 @@ static int16_t getShiftedLSB_intel(const CANRxFrame& frame, int offset) { return getLSB_intel(frame, offset) - 0x8000; } -static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) { +static void processCanRxImu(const CANRxFrame& frame) { /* if (CAN_SID(frame) == 0x130) { float a = getShiftedLSB_intel(frame, 0); @@ -172,7 +172,7 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick processCanRxVss(frame, nowNt); // todo: convert to CanListener or not? - processCanRxImu(frame, nowNt); + processCanRxImu(frame); processLuaCan(busIndex, frame); diff --git a/firmware/controllers/core/engine_module.h b/firmware/controllers/core/engine_module.h index ab52cc4a53..5384b26f1b 100644 --- a/firmware/controllers/core/engine_module.h +++ b/firmware/controllers/core/engine_module.h @@ -12,5 +12,5 @@ public: virtual void onFastCallback() { } // Called whenever the ignition switch state changes - virtual void onIgnitionStateChanged(bool ignitionOn) { } + virtual void onIgnitionStateChanged(bool /*ignitionOn*/) { } }; diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index a99f325441..67e94695c5 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -187,31 +187,6 @@ void runFsio() { enginePins.o2heater.setValue(engine->rpmCalculator.isRunning()); } - -static void showFsio(const char *msg, LEElement *element) { -#if EFI_PROD_CODE || EFI_SIMULATOR - if (msg != NULL) - efiPrintf("%s:", msg); - while (element->action != LE_METHOD_RETURN) { - efiPrintf("action %d: fValue=%.2f", element->action, element->fValue); - element++; - } - efiPrintf(""); -#endif -} - -// todo: move somewhere else -static void showFsioInfo() { -#if EFI_PROD_CODE || EFI_SIMULATOR - for (int i = 0; i < SCRIPT_SETTING_COUNT; i++) { - float v = engineConfiguration->scriptSetting[i]; - if (!cisnan(v)) { - efiPrintf("user property #%d: %.2f", i + 1, v); - } - } -#endif -} - ValueProvider3D *getscriptTable(int index) { switch (index) { default: diff --git a/firmware/controllers/engine_cycle/knock_logic.cpp b/firmware/controllers/engine_cycle/knock_logic.cpp index 06138cf72a..e3be5fb107 100644 --- a/firmware/controllers/engine_cycle/knock_logic.cpp +++ b/firmware/controllers/engine_cycle/knock_logic.cpp @@ -140,6 +140,8 @@ void Engine::onSparkFireKnockSense(uint8_t cylinderNumber, efitick_t nowNt) { #if EFI_HIP_9011 || EFI_SOFTWARE_KNOCK scheduleByAngle(&startSampling, nowNt, /*angle*/engineConfiguration->knockDetectionWindowStart, { startKnockSampling, engine }); +#else + UNUSED(nowNt); #endif #if EFI_HIP_9011 diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index 416290f03d..8e6335e31f 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -92,7 +92,6 @@ static void startAveraging(scheduling_s *endAveragingScheduling) { } #if HAL_USE_ADC -static int fastMapCounter = 0; /** * This method is invoked from ADC callback. diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index 929d257020..3332fb05c9 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -285,8 +285,8 @@ void readFromFlash() { * HW_CHECK_MODE mode where we would not need actual address * todo: rename method to emphasis the fact of validation check? */ - auto firstCopyAddr = getFlashAddrFirstCopy(); - auto secondyCopyAddr = getFlashAddrSecondCopy(); + getFlashAddrFirstCopy(); + getFlashAddrSecondCopy(); resetConfigurationExt(DEFAULT_ENGINE_TYPE); #else diff --git a/firmware/controllers/lua/lua_can_rx.cpp b/firmware/controllers/lua/lua_can_rx.cpp index f78db940ba..aa81bef5bc 100644 --- a/firmware/controllers/lua/lua_can_rx.cpp +++ b/firmware/controllers/lua/lua_can_rx.cpp @@ -21,12 +21,18 @@ static bool shouldRxCanFrame(const CANRxFrame& frame) { return false; } +// Stores information about one received CAN frame: which bus, plus the actual frame +struct CanFrameData { + uint8_t BusIndex; + CANRxFrame Frame; +}; + constexpr size_t canFrameCount = 32; -static CANRxFrame canFrames[canFrameCount]; +static CanFrameData canFrames[canFrameCount]; // CAN frame buffers that are not in use -chibios_rt::Mailbox freeBuffers; +chibios_rt::Mailbox freeBuffers; // CAN frame buffers that are waiting to be processed by the lua thread -chibios_rt::Mailbox filledBuffers; +chibios_rt::Mailbox filledBuffers; void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { // Filter the frame if we aren't listening for it @@ -34,7 +40,7 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { return; } - CANRxFrame* frameBuffer; + CanFrameData* frameBuffer; msg_t msg; { @@ -50,7 +56,8 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { } // Copy the frame in to the buffer - *frameBuffer = frame; + frameBuffer->BusIndex = busIndex; + frameBuffer->Frame = frame; { // Push the frame in to the queue under lock @@ -59,7 +66,7 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { } } -static void handleCanFrame(LuaHandle& ls, CANRxFrame* frame) { +static void handleCanFrame(LuaHandle& ls, CanFrameData* data) { lua_getglobal(ls, "onCanRx"); if (lua_isnil(ls, -1)) { // no rx function, ignore @@ -68,17 +75,17 @@ static void handleCanFrame(LuaHandle& ls, CANRxFrame* frame) { return; } - auto dlc = frame->DLC; + auto dlc = data->Frame.DLC; // Push bus, ID and DLC - lua_pushinteger(ls, 1); // TODO: support multiple busses! - lua_pushinteger(ls, CAN_EID(*frame)); + lua_pushinteger(ls, data->BusIndex); // TODO: support multiple busses! + lua_pushinteger(ls, CAN_EID(data->Frame)); lua_pushinteger(ls, dlc); // Build table for data lua_newtable(ls); for (size_t i = 0; i < dlc; i++) { - lua_pushinteger(ls, frame->data8[i]); + lua_pushinteger(ls, data->Frame.data8[i]); // index is i+1 because Lua "arrays" (tables) are 1-indexed lua_rawseti(ls, -2, i + 1); @@ -98,9 +105,9 @@ static void handleCanFrame(LuaHandle& ls, CANRxFrame* frame) { } bool doOneLuaCanRx(LuaHandle& ls) { - CANRxFrame* frame; + CanFrameData* data; - msg_t msg = filledBuffers.fetch(&frame, TIME_IMMEDIATE); + msg_t msg = filledBuffers.fetch(&data, TIME_IMMEDIATE); if (msg == MSG_TIMEOUT) { // No new CAN messages rx'd, nothing more to do. @@ -114,10 +121,10 @@ bool doOneLuaCanRx(LuaHandle& ls) { } // We've accepted the frame, process it in Lua. - handleCanFrame(ls, frame); + handleCanFrame(ls, data); // We're done, return this frame to the free list - msg = freeBuffers.post(frame, TIME_IMMEDIATE); + msg = freeBuffers.post(data, TIME_IMMEDIATE); efiAssert(OBD_PCM_Processor_Fault, msg == MSG_OK, "lua can post to free buffer fail", false); // We processed a frame so we should check again diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index baa739f705..6d50b80b79 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -602,7 +602,7 @@ void configureRusefiLuaHooks(lua_State* l) { lua_register(l, "getAirmass", lua_getAirmass); lua_register(l, "setAirmass", lua_setAirmass); - lua_register(l, "stopEngine", [](lua_State* l) { + lua_register(l, "stopEngine", [](lua_State*) { doScheduleStopEngine(); return 0; }); diff --git a/firmware/controllers/lua/lua_hooks_util.cpp b/firmware/controllers/lua/lua_hooks_util.cpp index a87b505fbb..55b49a01b1 100644 --- a/firmware/controllers/lua/lua_hooks_util.cpp +++ b/firmware/controllers/lua/lua_hooks_util.cpp @@ -35,7 +35,7 @@ void configureRusefiLuaUtilHooks(lua_State* l) { lua_register(l, "interpolate", lua_interpolate); #if defined(STM32F4) || defined(STM32F7) - lua_register(l, "mcu_standby", [](lua_State* l) { + lua_register(l, "mcu_standby", [](lua_State*) { stm32_standby(); return 0; }); diff --git a/firmware/controllers/sensors/map.cpp b/firmware/controllers/sensors/map.cpp index 8fd79d4df1..45dd498aa6 100644 --- a/firmware/controllers/sensors/map.cpp +++ b/firmware/controllers/sensors/map.cpp @@ -14,8 +14,6 @@ * @return unchanged mapKPa parameter or NaN */ static float validateBaroMap(float mapKPa) { - const float atmoPressure = 100.0f; - // Highest interstate is the Eisenhower Tunnel at 11158 feet -> 66 kpa // Lowest point is the Dead Sea, -1411 feet -> 106 kpa if (cisnan(mapKPa) || mapKPa > 110 || mapKPa < 60) { diff --git a/firmware/hw_layer/digital_input/digital_input_exti.cpp b/firmware/hw_layer/digital_input/digital_input_exti.cpp index fcd5fd9162..72c01de267 100644 --- a/firmware/hw_layer/digital_input/digital_input_exti.cpp +++ b/firmware/hw_layer/digital_input/digital_input_exti.cpp @@ -108,7 +108,7 @@ void efiExtiDisablePin(brain_pin_e brainPin) channel.CallbackData = nullptr; } -digital_input_s* startDigitalCaptureExti(const char *msg, brain_pin_e brainPin) { +digital_input_s* startDigitalCaptureExti(const char * /*msg*/, brain_pin_e /*brainPin*/) { return nullptr; } diff --git a/firmware/hw_layer/mass_storage/mass_storage_init.cpp b/firmware/hw_layer/mass_storage/mass_storage_init.cpp index 4e637672fd..e4f2668a65 100644 --- a/firmware/hw_layer/mass_storage/mass_storage_init.cpp +++ b/firmware/hw_layer/mass_storage/mass_storage_init.cpp @@ -10,13 +10,9 @@ #ifdef EFI_USE_COMPRESSED_INI_MSD #include "compressed_block_device.h" #include "ramdisk_image_compressed.h" - - static CompressedBlockDevice cbd; #else #include "ramdisk.h" #include "ramdisk_image.h" - - static RamDisk ramdisk; #endif // If the ramdisk image told us not to use it, don't use it. @@ -26,6 +22,14 @@ #endif #endif +#if EFI_EMBED_INI_MSD + #ifdef EFI_USE_COMPRESSED_INI_MSD + static CompressedBlockDevice cbd; + #else + static RamDisk ramdisk; + #endif +#endif + #if STM32_USB_USE_OTG1 USBDriver *usb_driver = &USBD1; #elif STM32_USB_USE_OTG2 diff --git a/firmware/init/sensor/init_map.cpp b/firmware/init/sensor/init_map.cpp index 3b08e6bb8c..5a9a5a0925 100644 --- a/firmware/init/sensor/init_map.cpp +++ b/firmware/init/sensor/init_map.cpp @@ -87,7 +87,7 @@ static MapCfg getMapCfg(air_pressure_sensor_type_e sensorType) { } void configureMapFunction(LinearFunc& converter, air_pressure_sensor_type_e sensorType) { - auto cfg = getMapCfg(engineConfiguration->map.sensor.type); + auto cfg = getMapCfg(sensorType); converter.configure( cfg.v1, diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 76a1ebebbd..7eec339d49 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1176,9 +1176,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ uint8_t autoscale noFuelTrimAfterDfcoTime;Pause closed loop fueling after deceleration fuel cut occurs. Set this to a little longer than however long is required for normal fueling behavior to resume after fuel cut.;"sec", 0.1, 0, 0, 10, 1 float tpsAccelEnrichmentThreshold;+Maximum change delta of TPS percentage over the 'length'. Actual TPS change has to be above this value in order for TPS/TPS acceleration to kick in.;"roc", 1, 0, 0, 200, 1 - int engineLoadAccelLength;;"cycles", 1, 0, 1, 200, 0 - - + int unused1696;;"", 1, 0, 0, 1, 0 uint32_t uartConsoleSerialSpeed;Band rate for primary TTL;"BPs", 1, 0, 0, 1000000, 0 float tpsDecelEnleanmentThreshold;For decel we simply multiply delta of TPS and tFor decel we do not use table?!;"roc", 1, 0, 0, 200, 1