From 87393f83f9141489853301466379e225b0d0195e Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 30 Jul 2024 09:45:15 -0400 Subject: [PATCH] Fix int promotion compile errors on thermostat application (#34627) * Fix int promotion compile errors * Fix cast types * Minimize cast size * Fix typo --------- Co-authored-by: Andrei Litvin --- examples/thermostat/linux/thermostat-delegate-impl.cpp | 4 ++-- examples/thermostat/linux/thermostat-manager.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/thermostat/linux/thermostat-delegate-impl.cpp b/examples/thermostat/linux/thermostat-delegate-impl.cpp index fa7bd9a259a475..491e44a311c3e8 100644 --- a/examples/thermostat/linux/thermostat-delegate-impl.cpp +++ b/examples/thermostat/linux/thermostat-delegate-impl.cpp @@ -96,10 +96,10 @@ void ThermostatDelegate::InitializePresets() const uint8_t handle[] = { static_cast(presetScenario) }; mPresets[index].SetPresetHandle(DataModel::MakeNullable(ByteSpan(handle))); mPresets[index].SetName(NullOptional); - int16_t coolingSetpointValue = 2500 + index * 100; + int16_t coolingSetpointValue = static_cast(2500 + (index * 100)); mPresets[index].SetCoolingSetpoint(MakeOptional(coolingSetpointValue)); - int16_t heatingSetpointValue = 2100 - index * 100; + int16_t heatingSetpointValue = static_cast(2100 - (index * 100)); mPresets[index].SetHeatingSetpoint(MakeOptional(heatingSetpointValue)); mPresets[index].SetBuiltIn(DataModel::MakeNullable(true)); index++; diff --git a/examples/thermostat/linux/thermostat-manager.cpp b/examples/thermostat/linux/thermostat-manager.cpp index 00266161007d59..e96f04a78d49e9 100644 --- a/examples/thermostat/linux/thermostat-manager.cpp +++ b/examples/thermostat/linux/thermostat-manager.cpp @@ -398,8 +398,8 @@ void ThermostatManager::EvalThermostatState() void ThermostatManager::UpdateRunningModeForHeating() { - const int16_t heatingOnThreshold = mOccupiedHeatingSetpoint - mOccupiedSetback * 10; - const int16_t heatingOffThreshold = mOccupiedHeatingSetpoint + mOccupiedSetback * 10; + const int16_t heatingOnThreshold = mOccupiedHeatingSetpoint - static_cast(mOccupiedSetback * 10); + const int16_t heatingOffThreshold = mOccupiedHeatingSetpoint + static_cast(mOccupiedSetback * 10); if (mRunningMode == ThermostatRunningModeEnum::kHeat) { @@ -429,8 +429,8 @@ void ThermostatManager::UpdateRunningModeForHeating() void ThermostatManager::UpdateRunningModeForCooling() { - const int16_t coolingOffThreshold = mOccupiedCoolingSetpoint - mOccupiedSetback * 10; - const int16_t coolingOnThreshold = mOccupiedCoolingSetpoint + mOccupiedSetback * 10; + const int16_t coolingOffThreshold = mOccupiedCoolingSetpoint - static_cast(mOccupiedSetback * 10); + const int16_t coolingOnThreshold = mOccupiedCoolingSetpoint + static_cast(mOccupiedSetback * 10); if (mRunningMode == ThermostatRunningModeEnum::kCool) {