Skip to content

Commit

Permalink
Fix casts when determining endpoint indices. (project-chip#36047)
Browse files Browse the repository at this point in the history
Not everything got updated correctly when endpoint indices changed from uint8 to
uint16.

Fixes project-chip#36007
  • Loading branch information
bzbarsky-apple authored and yyzhong-g committed Dec 11, 2024
1 parent 4689a2d commit 9b225de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ uint16_t emberAfGetDynamicIndexFromEndpoint(EndpointId id)
{
if (emAfEndpoints[index].endpoint == id)
{
return static_cast<uint8_t>(index - FIXED_ENDPOINT_COUNT);
return static_cast<uint16_t>(index - FIXED_ENDPOINT_COUNT);
}
}
return kEmberInvalidEndpointIndex;
Expand Down Expand Up @@ -322,7 +322,7 @@ EndpointId emberAfClearDynamicEndpoint(uint16_t index)
{
EndpointId ep = 0;

index = static_cast<uint8_t>(index + FIXED_ENDPOINT_COUNT);
index = static_cast<uint16_t>(index + FIXED_ENDPOINT_COUNT);

if ((index < MAX_ENDPOINT_COUNT) && (emAfEndpoints[index].endpoint != kInvalidEndpointId) &&
(emberAfEndpointIndexIsEnabled(index)))
Expand Down

0 comments on commit 9b225de

Please sign in to comment.