Skip to content

Commit

Permalink
Refactored for size conversion error
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs authored and pull[bot] committed Aug 4, 2023
1 parent 538d6a3 commit 1075920
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/clusters/scenes/SceneTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,17 @@ CHIP_ERROR DefaultSceneTableImpl::RegisterHandler(SceneHandler * handler)
return err;
}

CHIP_ERROR DefaultSceneTableImpl::UnregisterHandler(uint8_t position)
CHIP_ERROR DefaultSceneTableImpl::UnregisterHandler(uint8_t pos)
{
VerifyOrReturnError(position < kMaxSceneHandlers, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnValue(!this->HandlerListEmpty() && !(this->mHandlers[position] == nullptr), CHIP_NO_ERROR);
VerifyOrReturnError(pos < kMaxSceneHandlers, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnValue(!this->HandlerListEmpty() && !(this->mHandlers[pos] == nullptr), CHIP_NO_ERROR);

uint8_t next = position + 1;
uint8_t moveNum = kMaxSceneHandlers - next;
uint8_t nextPos = pos++;
uint8_t moveNum = kMaxSceneHandlers - nextPos;

// TODO: Implement general array management methods
// Compress array after removal
memmove(&this->mHandlers[position], &this->mHandlers[next], sizeof(SceneHandler *) * moveNum);
memmove(&this->mHandlers[pos], &this->mHandlers[nextPos], sizeof(SceneHandler *) * moveNum);

this->handlerNum--;
// Clear last occupied position
Expand Down

0 comments on commit 1075920

Please sign in to comment.