From a9a0edefe833bf71ab6cf2443d2a9ebed57daf3c Mon Sep 17 00:00:00 2001 From: Neil Horne <15316949+elecpower@users.noreply.github.com> Date: Sun, 17 Aug 2025 20:17:47 +1000 Subject: [PATCH] chore(cpn): stop compiler warnings (#6523) --- companion/src/firmwares/generalsettings.cpp | 13 ++++++++++++- companion/src/firmwares/generalsettings.h | 3 +++ companion/src/firmwares/modeldata.cpp | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 7350ba6b1..d5ab99688 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -436,7 +436,7 @@ void GeneralSettings::convert(RadioDataConversionState & cstate) // Try to intelligently copy any custom controls // step 1 clear current config memset(&inputConfig[0], 0, sizeof(InputConfig) * CPN_MAX_INPUTS); - memset(&switchConfig[0], 0, sizeof(SwitchConfig) * CPN_MAX_SWITCHES); + switchConfigClear(); // step 2 load default config setDefaultControlTypes(cstate.toType); // step 3 copy matching config based on tags @@ -1006,3 +1006,14 @@ AbstractStaticItemModel * GeneralSettings::templateSetupItemModel() mdl->loadItemList(); return mdl; } + +GeneralSettings::SwitchConfig::SwitchConfig() +{ + memset((void*)this, 0, sizeof(SwitchConfig)); +} + +void GeneralSettings::switchConfigClear() +{ + for (int i = 0; i < CPN_MAX_SWITCHES; i++) + switchConfig[i] = SwitchConfig(); +} diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 75d704f3b..bb31d7e60 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -379,9 +379,12 @@ class GeneralSettings { unsigned int offColorLuaOverride; RGBLedColor onColor; RGBLedColor offColor; + + SwitchConfig(); }; SwitchConfig switchConfig[CPN_MAX_SWITCHES]; + void switchConfigClear(); bool switchPositionAllowed(int index) const; bool switchSourceAllowed(int index) const; diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index c574fc467..c94838897 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -1814,7 +1814,7 @@ AbstractStaticItemModel * ModelData::funcSwitchGroupsModel() mdl->setName(AIM_MODELDATA_FUNCSWITCHGROUPS); mdl->appendToItemList(tr("---"), 0); - for (unsigned int i = 1; i <= Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups); i += 1) { + for (int i = 1; i <= Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups); i++) { mdl->appendToItemList(tr("Group ") + QString::number(i), i); } @@ -1838,7 +1838,7 @@ void ModelData::setFuncSwitchGroup(unsigned int index, unsigned int value) unsigned int ModelData::getFuncSwitchAlwaysOnGroup(unsigned int group) const { - if (group > 0 && group <= Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups)) { + if (group > 0 && group <= (unsigned int)Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups)) { return cfsGroupOn[group]; } else @@ -1855,7 +1855,7 @@ unsigned int ModelData::getFuncSwitchAlwaysOnGroupForSwitch(unsigned int index) void ModelData::setFuncSwitchAlwaysOnGroup(unsigned int group, unsigned int value) { - if (group > 0 && group <= Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups)) { + if (group > 0 && group <= (unsigned int)Boards::getCapability(getCurrentBoard(), Board::FunctionSwitchGroups)) { cfsGroupOn[group] = value; } }