[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:
Abtin Keshavarzian
2023-09-27 10:59:37 -07:00
committed by GitHub
parent 17286dbd24
commit 09a0fbe9c6
+3 -1
View File
@@ -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