[coap] ensure InvokeResponseFallback() adheres to style guide (#12223)

This commit moves the implementation of `InvokeResponseFallback()` to
the `cpp` file. It also ensures that the implementation follows the
style guide requirement of single `return` from any method/function.
This commit is contained in:
Abtin Keshavarzian
2025-12-17 19:59:55 -08:00
committed by GitHub
parent b9bbf71d34
commit 7bbff74893
2 changed files with 15 additions and 10 deletions
+14 -1
View File
@@ -1310,7 +1310,9 @@ exit:
if (error == kErrorNone && request == nullptr)
{
if (!InvokeResponseFallback(aMessage, aMessageInfo) && aMessage.RequireResetOnError())
bool didHandle = InvokeResponseFallback(aMessage, aMessageInfo);
if (!didHandle && aMessage.RequireResetOnError())
{
// Successfully parsed a header but no matching request was
// found - reject the message by sending reset.
@@ -1319,6 +1321,17 @@ exit:
}
}
bool CoapBase::InvokeResponseFallback(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const
{
bool didHandle = false;
VerifyOrExit(mResponseFallback.IsSet());
didHandle = mResponseFallback.Invoke(&aMessage, &aMessageInfo);
exit:
return didHandle;
}
void CoapBase::ProcessReceivedRequest(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
char uriPath[Message::kMaxReceivedUriPath + 1];
+1 -9
View File
@@ -849,15 +849,7 @@ private:
Message *aResponse,
const Ip6::MessageInfo *aMessageInfo,
Error aResult);
inline bool InvokeResponseFallback(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
if (mResponseFallback.IsSet())
{
return mResponseFallback.Invoke(&aMessage, &aMessageInfo);
}
return false;
}
bool InvokeResponseFallback(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const;
#if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE
void FreeLastBlockResponse(void);