Skip to content

Commit

Permalink
Fixed potential divide by 0 - Update examples/energy-management-app/e…
Browse files Browse the repository at this point in the history
…nergy-management-common/water-heater/src/WhmDelegateImpl.cpp
  • Loading branch information
jamesharrow authored Aug 29, 2024
1 parent 82e120e commit a614aa0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ uint8_t WaterHeaterManagementDelegate::CalculateTankPercentage() const
int32_t divisor = static_cast<int32_t>(GetActiveTargetWaterTemperature()) - static_cast<int32_t>(mColdWaterTemperature);

tankPercentage = 100;
if (divisor >= 0)
if (divisor > 0)
{
tankPercentage = 100 * (static_cast<int32_t>(mWaterTemperature) - static_cast<int32_t>(mColdWaterTemperature)) / divisor;
}
Expand Down

0 comments on commit a614aa0

Please sign in to comment.