From fa42687082eb60aa662f274c22a7f52b74c46bc1 Mon Sep 17 00:00:00 2001 From: ttechnick Date: Wed, 11 Mar 2026 19:40:05 +0100 Subject: [PATCH] optimization 3 --- .../checks/sdcardCheck.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp index 2f55233e9f..c4bd99f775 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp @@ -185,26 +185,27 @@ void SdCardChecks::checkAndReport(const Context &context, Report &reporter) if (!sdcard_logging_enabled) { // Check if any SDLOG parameter differs from its default - auto param_changed = [](param_t p) { - int32_t val, def; - return (param_get(p, &val) == 0 && param_get_default_value(p, &def) == 0 && val != def); - }; + const param_t sdlog_params[] = {_param_sdlog_mode, _param_sdlog_profile, _param_sdlog_mission, _param_sdlog_dirs_max}; + bool sdlog_params_changed = false; - const bool sdlog_params_changed = (param_changed(_param_sdlog_mode) || - param_changed(_param_sdlog_profile) || - param_changed(_param_sdlog_mission) || - param_changed(_param_sdlog_dirs_max)); + for (auto p : sdlog_params) { + int32_t val, def; + + if (param_get(p, &val) == 0 && param_get_default_value(p, &def) == 0 && val != def) { + sdlog_params_changed = true; + break; + } + } if (sdlog_params_changed) { /* EVENT * @description * SD logging parameters (SDLOG_*) have been modified, but SD card logging - * is not enabled in SDLOG_BACKEND. These parameters will have no effect. + * is not enabled in SDLOG_BACKEND. * * - * Either enable SD card logging in SDLOG_BACKEND, - * or reset the SDLOG parameters to their default values. + * These parameters will have no effect. * */ reporter.healthFailure(NavModes::None, health_component_t::logging,