Skip to content

Commit

Permalink
[coap] use otError in C handlers (openthread#11115)
Browse files Browse the repository at this point in the history
This commit changes CoAP handlers to use otError in the function or
method definitions. This ensures the definitions are consistent with
the declaration in coap.h.
  • Loading branch information
bukepo authored Jan 7, 2025
1 parent f3dded4 commit dc4acf0
Show file tree
Hide file tree
Showing 26 changed files with 44 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/core/meshcop/border_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Error BorderAgent::ForwardToLeader(const Coap::Message &aMessage, const Ip6::Mes
void BorderAgent::HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
OT_UNUSED_VARIABLE(aMessageInfo);

Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/border_agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class BorderAgent : public InstanceLocator, private NonCopyable
static void HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleCoapResponse(const ForwardContext &aForwardContext, const Coap::Message *aResponse, Error aResult);
static bool HandleUdpReceive(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo);
bool HandleUdpReceive(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
Expand Down
8 changes: 4 additions & 4 deletions src/core/meshcop/commissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ Error Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs, uint8_t
void Commissioner::HandleMgmtCommissionerGetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<Commissioner *>(aContext)->HandleMgmtCommissionerGetResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down Expand Up @@ -704,7 +704,7 @@ Error Commissioner::SendMgmtCommissionerSetRequest(const CommissioningDataset &a
void Commissioner::HandleMgmtCommissionerSetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<Commissioner *>(aContext)->HandleMgmtCommissionerSetResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down Expand Up @@ -757,7 +757,7 @@ Error Commissioner::SendPetition(void)
void Commissioner::HandleLeaderPetitionResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<Commissioner *>(aContext)->HandleLeaderPetitionResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down Expand Up @@ -844,7 +844,7 @@ void Commissioner::SendKeepAlive(uint16_t aSessionId)
void Commissioner::HandleLeaderKeepAliveResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<Commissioner *>(aContext)->HandleLeaderKeepAliveResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down
8 changes: 4 additions & 4 deletions src/core/meshcop/commissioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,22 @@ class Commissioner : public InstanceLocator, private NonCopyable
static void HandleMgmtCommissionerSetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleMgmtCommissionerSetResponse(Coap::Message *aMessage,
const Ip6::MessageInfo *aMessageInfo,
Error aResult);
static void HandleMgmtCommissionerGetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleMgmtCommissionerGetResponse(Coap::Message *aMessage,
const Ip6::MessageInfo *aMessageInfo,
Error aResult);
static void HandleLeaderPetitionResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
void HandleLeaderPetitionResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);
otError aResult);
void HandleLeaderPetitionResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, otError aResult);
static void HandleLeaderKeepAliveResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/dataset_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ Error DatasetManager::SendSetRequest(const Dataset &aDataset)
void DatasetManager::HandleMgmtSetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aError)
otError aError)
{
static_cast<DatasetManager *>(aContext)->HandleMgmtSetResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aError);
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/dataset_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class DatasetManager : public InstanceLocator
static void HandleMgmtSetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aError);
otError aError);

#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
void MoveKeysToSecureStorage(Dataset &aDataset) const;
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/joiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void Joiner::SendJoinerFinalize(void)
void Joiner::HandleJoinerFinalizeResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<Joiner *>(aContext)->HandleJoinerFinalizeResponse(AsCoapMessagePtr(aMessage), &AsCoreType(aMessageInfo),
aResult);
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/joiner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Joiner : public InstanceLocator, private NonCopyable
static void HandleJoinerFinalizeResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleJoinerFinalizeResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);

template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/joiner_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Coap::Message *JoinerRouter::PrepareJoinerEntrustMessage(void)
void JoinerRouter::HandleJoinerEntrustResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<JoinerRouter *>(aContext)->HandleJoinerEntrustResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down
2 changes: 1 addition & 1 deletion src/core/meshcop/joiner_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class JoinerRouter : public InstanceLocator, private NonCopyable
static void HandleJoinerEntrustResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleJoinerEntrustResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);

void HandleTimer(void);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/anycast_locator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Error AnycastLocator::Locate(const Ip6::Address &aAnycastAddress, LocatorCallbac
void AnycastLocator::HandleResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aError)
otError aError)
{
static_cast<AnycastLocator *>(aContext)->HandleResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
aError);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/anycast_locator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AnycastLocator : public InstanceLocator, private NonCopyable
bool IsInProgress(void) const { return mCallback.IsSet(); }

private:
static void HandleResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aError);
static void HandleResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aError);

void HandleResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aError);

Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/dua_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ void DuaManager::PerformNextRegistration(void)
void DuaManager::HandleDuaResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<DuaManager *>(aContext)->HandleDuaResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
aResult);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/dua_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class DuaManager : public InstanceLocator, private NonCopyable
static void HandleDuaResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleDuaResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);

template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3305,7 +3305,7 @@ void MleRouter::SendAddressRelease(void)
void MleRouter::HandleAddressSolicitResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<MleRouter *>(aContext)->HandleAddressSolicitResponse(AsCoapMessagePtr(aMessage),
AsCoreTypePtr(aMessageInfo), aResult);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/mle_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class MleRouter : public Mle
static void HandleAddressSolicitResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);

//------------------------------------------------------------------------------------------------------------------
// Variables
Expand Down
6 changes: 3 additions & 3 deletions src/core/thread/mlr_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ Error MlrManager::RegisterMulticastListeners(const Ip6::Address *aAddresses,
void MlrManager::HandleRegisterResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<MlrManager *>(aContext)->HandleRegisterResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
aResult);
}

void MlrManager::HandleRegisterResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult)
void MlrManager::HandleRegisterResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
{
OT_UNUSED_VARIABLE(aMessageInfo);

Expand Down Expand Up @@ -428,7 +428,7 @@ Error MlrManager::SendMlrMessage(const Ip6::Address *aAddresses,
void MlrManager::HandleMlrResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult)
otError aResult)
{
static_cast<MlrManager *>(aContext)->HandleMlrResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
aResult);
Expand Down
6 changes: 3 additions & 3 deletions src/core/thread/mlr_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MlrManager : public InstanceLocator, private NonCopyable
static void HandleMlrResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleMlrResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);
static Error ParseMlrResponse(Error aResult,
Coap::Message *aMessage,
Expand All @@ -170,8 +170,8 @@ class MlrManager : public InstanceLocator, private NonCopyable
static void HandleRegisterResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
void HandleRegisterResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult);
otError aResult);
void HandleRegisterResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult);
#endif

#if OPENTHREAD_CONFIG_MLR_ENABLE
Expand Down
5 changes: 4 additions & 1 deletion src/core/thread/network_data_notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ void Notifier::HandleNotifierEvents(Events aEvents)

void Notifier::HandleTimer(void) { SynchronizeServerData(); }

void Notifier::HandleCoapResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult)
void Notifier::HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult)
{
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aMessageInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/network_data_notifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Notifier : public InstanceLocator, private NonCopyable
static void HandleCoapResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleCoapResponse(Error aResult);

#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL
Expand Down
7 changes: 5 additions & 2 deletions src/core/thread/network_diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,10 @@ void Server::SendNextAnswer(Coap::Message &aAnswer, const Ip6::Address &aDestina
}
}

void Server::HandleAnswerResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult)
void Server::HandleAnswerResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult)
{
Coap::Message *nextAnswer = static_cast<Coap::Message *>(aContext);

Expand Down Expand Up @@ -935,7 +938,7 @@ Error Client::SendCommand(Uri aUri,
return error;
}

void Client::HandleGetResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, Error aResult)
void Client::HandleGetResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
{
static_cast<Client *>(aContext)->HandleGetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
aResult);
Expand Down
4 changes: 2 additions & 2 deletions src/core/thread/network_diagnostic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Server : public InstanceLocator, private NonCopyable
static void HandleAnswerResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleAnswerResponse(Coap::Message &aNextAnswer,
Coap::Message *aResponse,
const Ip6::MessageInfo *aMessageInfo,
Expand Down Expand Up @@ -316,7 +316,7 @@ class Client : public InstanceLocator, private NonCopyable
static void HandleGetResponse(void *aContext,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
Error aResult);
otError aResult);
void HandleGetResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);

template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
Expand Down
Loading

0 comments on commit dc4acf0

Please sign in to comment.