Skip to content

Commit 60d803c

Browse files
fix byte-aligned issue
1 parent 389c477 commit 60d803c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/k32w0/platform/radio.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
/* Openthread general */
4747
#include "openthread-system.h"
48-
48+
#include <utils/encoding.h>
4949
#include <utils/code_utils.h>
5050
#include <utils/mac_frame.h>
5151
#include "utils/link_metrics.h"
@@ -660,15 +660,13 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
660660
tmp.m8[i] = aExtAddress->m8[sizeof(*aExtAddress) - 1 - i];
661661
}
662662

663-
uint32_t v1 = *(uint32_t *)tmp.m8;
664-
uint32_t v2 = *(uint32_t *)(tmp.m8 + sizeof(uint32_t));
663+
uint64_t v = otEncodingReadUint64Le(tmp.m8);
665664

666665
for (; idx < MAX_FP_ADDRS; idx++)
667666
{
668-
uint32_t t1 = *(uint32_t *)sFpExtAddr[idx].extAddr.m8;
669-
uint32_t t2 = *(uint32_t *)(sFpExtAddr[idx].extAddr.m8 + sizeof(uint32_t));
667+
uint64_t t = otEncodingReadUint64Le(sFpExtAddr[idx].extAddr.m8);
670668

671-
if (BIT_TST(sFpExtAddrMask, idx) && (t1 == v1) && (t2 == v2))
669+
if (BIT_TST(sFpExtAddrMask, idx) && (t == v))
672670
{
673671
BIT_CLR(sFpExtAddrMask, idx);
674672
error = OT_ERROR_NONE;
@@ -1183,15 +1181,13 @@ static bool K32WCheckIfFpRequired(tsPhyFrame *aRxFrame)
11831181
else if (srcAddr.mType == OT_MAC_ADDRESS_TYPE_EXTENDED)
11841182
{
11851183
/* srcAddr.mAddress.mExtAddress is returned in reverse order (big endian) */
1186-
uint32_t v1 = *(uint32_t *)srcAddr.mAddress.mExtAddress.m8;
1187-
uint32_t v2 = *(uint32_t *)(srcAddr.mAddress.mExtAddress.m8 + sizeof(uint32_t));
1184+
uint64_t v = otEncodingReadUint64Le(srcAddr.mAddress.mExtAddress.m8);
11881185

11891186
for (idx = 0; idx < MAX_FP_ADDRS; idx++)
11901187
{
1191-
uint32_t t1 = *(uint32_t *)sFpExtAddr[idx].extAddr.m8;
1192-
uint32_t t2 = *(uint32_t *)(sFpExtAddr[idx].extAddr.m8 + sizeof(uint32_t));
1188+
uint64_t t = otEncodingReadUint64Le(sFpExtAddr[idx].extAddr.m8);
11931189

1194-
if (BIT_TST(sFpExtAddrMask, idx) && (t1 == v1) && (t2 == v2))
1190+
if (BIT_TST(sFpExtAddrMask, idx) && (t == v))
11951191
{
11961192
isFpRequired = TRUE;
11971193
break;

0 commit comments

Comments
 (0)