Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Dishwasher Comparison Always false fix #36234

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ void ElectricalSensorManager::UpdateEPMAttributes(OperationalStateEnum state)
{
if (gEPMDelegate)
{
uint16_t updateState = to_underlying(state);
uint16_t ERROR_STATE_INDEX = ArraySize(kAttributes) - 1;
uint8_t updateState = to_underlying(state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, I would recommend auto in this situation. That prevents accidental narrowing (which would also be prevented if this code were built with -Wconversion, but I bet it's not).


// Check state range
if ((updateState < 0) || (updateState > ERROR_STATE_INDEX))
if (updateState >= ArraySize(kAttributes))
{
updateState = ERROR_STATE_INDEX;
updateState = ArraySize(kAttributes) - 1;
}

ChipLogDetail(AppServer, "UpdateAllAttributes to Operational State : %d", updateState);
Expand Down
Loading