mirror of
https://github.com/espressif/openthread.git
synced 2026-09-07 09:40:12 +00:00
[ip6] update where HandlePayload() check message is not null (#9462)
This commit updates `Ip6::HandlePayload()` to check the `message` pointer for null in the common flow, instead of in the `if()` block where the message is cloned when `aMessageOwnership` is set to `kCopyToUse`. If `aMessageOwnership` is `kTakeCustody` the `message` is initialized as `&aMessage` already which cannot be `nullptr`. This protects against code checker warnings that `message` may remain null if the given `aMessageOwnership` enum value is not one of its two defined enumerator values.
This commit is contained in:
@@ -901,9 +901,11 @@ Error Ip6::HandlePayload(Header &aIp6Header,
|
||||
|
||||
if (aMessageOwnership == Message::kCopyToUse)
|
||||
{
|
||||
VerifyOrExit((message = aMessage.Clone()) != nullptr, error = kErrorNoBufs);
|
||||
message = aMessage.Clone();
|
||||
}
|
||||
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
|
||||
switch (aIpProto)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_TCP_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user