Skip to content

Commit

Permalink
[instance] fix index computation in multi-instances context (#11099)
Browse files Browse the repository at this point in the history
In multi instances context, the GetIdx function did not return the
correct instance index.
  • Loading branch information
seb-fae authored Jan 9, 2025
1 parent d7a2668 commit 3ae741f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/core/instance/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ Instance &Instance::Get(uint8_t aIdx)

uint8_t Instance::GetIdx(Instance *aInstance)
{
return static_cast<uint8_t>(
(reinterpret_cast<uint8_t *>(aInstance) - reinterpret_cast<uint8_t *>(gMultiInstanceRaw)) /
INSTANCE_SIZE_ALIGNED);
return static_cast<uint8_t>((reinterpret_cast<uint64_t *>(aInstance) - gMultiInstanceRaw) / INSTANCE_SIZE_ALIGNED);
}

#endif // #if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
Expand Down

0 comments on commit 3ae741f

Please sign in to comment.