Skip to content

Commit

Permalink
Fix compile error on older g++ (#34630)
Browse files Browse the repository at this point in the history
- Older g++ in Ubuntu 20.04LTS seems to have issues
  with invalidly doing integer promotion in some cases
  where it otherwise should not happen. This broke for some developers
  with:

```
../../third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src/WhmDelegateImpl.cpp: In member function ‘void chip::app::Clusters::WaterHeaterManagement::WaterHeaterManagementDelegate::DrawOffHotWater(chip::Percent, uint16_t)’:
../../third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src/WhmDelegateImpl.cpp:306:29: error: conversion from ‘int’ to ‘chip::Percent’ {aka ‘unsigned char’} may change value [-Werror=conversion]
  306 |             mTankPercentage -= percentageReplaced;
      |             ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
cc1plus: all warnings being treated as errors
[17/171] c++ obj/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/src/chip-all-clusters-common.device-energy-management-mode.cpp.o
ninja: build stopped: subcommand failed.
```

- This PR fixes the issue (validated with one such user).
  • Loading branch information
tcarmelveilleux authored Jul 30, 2024
1 parent 3263e40 commit ccd8da9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class WaterHeaterManagementDelegate : public WaterHeaterManagement::Delegate
* @param percentageReplaced The % of water being replaced with water with a temperature of replacedWaterTemperature.
* @param replacedWaterTemperature The temperature of the percentageReplaced water.
*/
void DrawOffHotWater(uint8_t percentageReplaced, uint16_t replacedWaterTemperature);
void DrawOffHotWater(chip::Percent percentageReplaced, uint16_t replacedWaterTemperature);

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void WaterHeaterManagementDelegate::SetTargetWaterTemperature(uint16_t targetWat
CheckIfHeatNeedsToBeTurnedOnOrOff();
}

void WaterHeaterManagementDelegate::DrawOffHotWater(uint8_t percentageReplaced, uint16_t replacedWaterTemperature)
void WaterHeaterManagementDelegate::DrawOffHotWater(Percent percentageReplaced, uint16_t replacedWaterTemperature)
{
// Only supported in the kTankPercent is supported.
// Replaces percentageReplaced% of the water in the tank with water of a temperature replacedWaterTemperature
Expand All @@ -303,7 +303,7 @@ void WaterHeaterManagementDelegate::DrawOffHotWater(uint8_t percentageReplaced,
// See if all of the water has now been replaced with replacedWaterTemperature
if (mTankPercentage >= percentageReplaced)
{
mTankPercentage -= percentageReplaced;
mTankPercentage = static_cast<Percent>(mTankPercentage - percentageReplaced);
}
else
{
Expand Down

0 comments on commit ccd8da9

Please sign in to comment.