From 3ae741f95e7dfb391dec35c48742862049eb62e8 Mon Sep 17 00:00:00 2001 From: seb-fae <71495014+seb-fae@users.noreply.github.com> Date: Fri, 10 Jan 2025 00:11:39 +0100 Subject: [PATCH] [instance] fix index computation in multi-instances context (#11099) In multi instances context, the GetIdx function did not return the correct instance index. --- src/core/instance/instance.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/instance/instance.cpp b/src/core/instance/instance.cpp index d00129c70..94b930289 100644 --- a/src/core/instance/instance.cpp +++ b/src/core/instance/instance.cpp @@ -351,9 +351,7 @@ Instance &Instance::Get(uint8_t aIdx) uint8_t Instance::GetIdx(Instance *aInstance) { - return static_cast( - (reinterpret_cast(aInstance) - reinterpret_cast(gMultiInstanceRaw)) / - INSTANCE_SIZE_ALIGNED); + return static_cast((reinterpret_cast(aInstance) - gMultiInstanceRaw) / INSTANCE_SIZE_ALIGNED); } #endif // #if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE