mirror of
https://github.com/espressif/openthread.git
synced 2026-09-09 02:30:11 +00:00
[ip6] fix conversion of enum value to uint8_t (#4522)
This commit updates how the `otMessagePriority` enumeration variable is updated in `otMessageSettings` structure. This addresses an issue where the enum variable was being treated as an `uint8_t` which may not necessarily be correct (since complier can choose any integral type which covers all the enumerator values as the underlying storage for an unscoped enumeration type).
This commit is contained in:
@@ -76,13 +76,15 @@ Message *Ip6::NewMessage(const uint8_t *aData, uint16_t aDataLength, const otMes
|
||||
{
|
||||
otMessageSettings settings = {true, OT_MESSAGE_PRIORITY_NORMAL};
|
||||
Message * message = NULL;
|
||||
uint8_t priority;
|
||||
|
||||
if (aSettings != NULL)
|
||||
{
|
||||
settings = *aSettings;
|
||||
}
|
||||
|
||||
SuccessOrExit(GetDatagramPriority(aData, aDataLength, *reinterpret_cast<uint8_t *>(&settings.mPriority)));
|
||||
SuccessOrExit(GetDatagramPriority(aData, aDataLength, priority));
|
||||
settings.mPriority = static_cast<otMessagePriority>(priority);
|
||||
VerifyOrExit((message = Get<MessagePool>().New(Message::kTypeIp6, 0, &settings)) != NULL);
|
||||
|
||||
if (message->Append(aData, aDataLength) != OT_ERROR_NONE)
|
||||
|
||||
Reference in New Issue
Block a user