From dc4acf034636bd94f155da84683e52151cd1df3f Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 8 Jan 2025 07:48:38 +0800 Subject: [PATCH] [coap] use otError in C handlers (#11115) 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. --- src/core/meshcop/border_agent.cpp | 2 +- src/core/meshcop/border_agent.hpp | 2 +- src/core/meshcop/commissioner.cpp | 8 ++++---- src/core/meshcop/commissioner.hpp | 8 ++++---- src/core/meshcop/dataset_manager.cpp | 2 +- src/core/meshcop/dataset_manager.hpp | 2 +- src/core/meshcop/joiner.cpp | 2 +- src/core/meshcop/joiner.hpp | 2 +- src/core/meshcop/joiner_router.cpp | 2 +- src/core/meshcop/joiner_router.hpp | 2 +- src/core/thread/anycast_locator.cpp | 2 +- src/core/thread/anycast_locator.hpp | 2 +- src/core/thread/dua_manager.cpp | 2 +- src/core/thread/dua_manager.hpp | 2 +- src/core/thread/mle_router.cpp | 2 +- src/core/thread/mle_router.hpp | 2 +- src/core/thread/mlr_manager.cpp | 6 +++--- src/core/thread/mlr_manager.hpp | 6 +++--- src/core/thread/network_data_notifier.cpp | 5 ++++- src/core/thread/network_data_notifier.hpp | 2 +- src/core/thread/network_diagnostic.cpp | 7 +++++-- src/core/thread/network_diagnostic.hpp | 4 ++-- src/core/utils/channel_manager.cpp | 2 +- src/core/utils/channel_manager.hpp | 2 +- src/core/utils/mesh_diag.cpp | 2 +- src/core/utils/mesh_diag.hpp | 2 +- 26 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index fb62e1225ab..1c3c92820fd 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -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); diff --git a/src/core/meshcop/border_agent.hpp b/src/core/meshcop/border_agent.hpp index ba96bc926dd..25751c2ea42 100644 --- a/src/core/meshcop/border_agent.hpp +++ b/src/core/meshcop/border_agent.hpp @@ -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); diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 46c962a2c22..4557ea60297 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -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(aContext)->HandleMgmtCommissionerGetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); @@ -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(aContext)->HandleMgmtCommissionerSetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); @@ -757,7 +757,7 @@ Error Commissioner::SendPetition(void) void Commissioner::HandleLeaderPetitionResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult) + otError aResult) { static_cast(aContext)->HandleLeaderPetitionResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); @@ -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(aContext)->HandleLeaderKeepAliveResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/meshcop/commissioner.hpp b/src/core/meshcop/commissioner.hpp index f01dc11ce21..6de9e2c9f35 100644 --- a/src/core/meshcop/commissioner.hpp +++ b/src/core/meshcop/commissioner.hpp @@ -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, diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp index 114e334a6d8..049ce263bff 100644 --- a/src/core/meshcop/dataset_manager.cpp +++ b/src/core/meshcop/dataset_manager.cpp @@ -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(aContext)->HandleMgmtSetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aError); diff --git a/src/core/meshcop/dataset_manager.hpp b/src/core/meshcop/dataset_manager.hpp index 134ec843ab3..75ff7856296 100644 --- a/src/core/meshcop/dataset_manager.hpp +++ b/src/core/meshcop/dataset_manager.hpp @@ -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; diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index fea808e49c9..eaee089d23c 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -470,7 +470,7 @@ void Joiner::SendJoinerFinalize(void) void Joiner::HandleJoinerFinalizeResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult) + otError aResult) { static_cast(aContext)->HandleJoinerFinalizeResponse(AsCoapMessagePtr(aMessage), &AsCoreType(aMessageInfo), aResult); diff --git a/src/core/meshcop/joiner.hpp b/src/core/meshcop/joiner.hpp index e310db79f8d..3cdde0ae17d 100644 --- a/src/core/meshcop/joiner.hpp +++ b/src/core/meshcop/joiner.hpp @@ -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 void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index 3c29e8e42f3..6d515aa8147 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -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(aContext)->HandleJoinerEntrustResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp index b817bd31c6b..76b8f421b06 100644 --- a/src/core/meshcop/joiner_router.hpp +++ b/src/core/meshcop/joiner_router.hpp @@ -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); diff --git a/src/core/thread/anycast_locator.cpp b/src/core/thread/anycast_locator.cpp index a4ac3f29c27..99ed79d9b11 100644 --- a/src/core/thread/anycast_locator.cpp +++ b/src/core/thread/anycast_locator.cpp @@ -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(aContext)->HandleResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aError); diff --git a/src/core/thread/anycast_locator.hpp b/src/core/thread/anycast_locator.hpp index ad0e64ae7fb..dbc4dc02f95 100644 --- a/src/core/thread/anycast_locator.hpp +++ b/src/core/thread/anycast_locator.hpp @@ -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); diff --git a/src/core/thread/dua_manager.cpp b/src/core/thread/dua_manager.cpp index 3f61a9250b7..3cbf9f84aaf 100644 --- a/src/core/thread/dua_manager.cpp +++ b/src/core/thread/dua_manager.cpp @@ -544,7 +544,7 @@ void DuaManager::PerformNextRegistration(void) void DuaManager::HandleDuaResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult) + otError aResult) { static_cast(aContext)->HandleDuaResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/thread/dua_manager.hpp b/src/core/thread/dua_manager.hpp index f37875b6380..e3579f56bf6 100644 --- a/src/core/thread/dua_manager.hpp +++ b/src/core/thread/dua_manager.hpp @@ -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 void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 60d2752d93c..9095b4bee3d 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -3305,7 +3305,7 @@ void MleRouter::SendAddressRelease(void) void MleRouter::HandleAddressSolicitResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult) + otError aResult) { static_cast(aContext)->HandleAddressSolicitResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/thread/mle_router.hpp b/src/core/thread/mle_router.hpp index 9e85b575908..b5bd491c6c4 100644 --- a/src/core/thread/mle_router.hpp +++ b/src/core/thread/mle_router.hpp @@ -649,7 +649,7 @@ class MleRouter : public Mle static void HandleAddressSolicitResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult); + otError aResult); //------------------------------------------------------------------------------------------------------------------ // Variables diff --git a/src/core/thread/mlr_manager.cpp b/src/core/thread/mlr_manager.cpp index b6ab957696a..5027d3711b0 100644 --- a/src/core/thread/mlr_manager.cpp +++ b/src/core/thread/mlr_manager.cpp @@ -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(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); @@ -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(aContext)->HandleMlrResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/thread/mlr_manager.hpp b/src/core/thread/mlr_manager.hpp index e26c797e767..2fc69bf7c11 100644 --- a/src/core/thread/mlr_manager.hpp +++ b/src/core/thread/mlr_manager.hpp @@ -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, @@ -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 diff --git a/src/core/thread/network_data_notifier.cpp b/src/core/thread/network_data_notifier.cpp index 585a2c94df2..f7bf8afeff9 100644 --- a/src/core/thread/network_data_notifier.cpp +++ b/src/core/thread/network_data_notifier.cpp @@ -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); diff --git a/src/core/thread/network_data_notifier.hpp b/src/core/thread/network_data_notifier.hpp index d13dbf9106c..96c1e2b96bd 100644 --- a/src/core/thread/network_data_notifier.hpp +++ b/src/core/thread/network_data_notifier.hpp @@ -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 diff --git a/src/core/thread/network_diagnostic.cpp b/src/core/thread/network_diagnostic.cpp index 3b4b93f8af7..7f879c4bd75 100644 --- a/src/core/thread/network_diagnostic.cpp +++ b/src/core/thread/network_diagnostic.cpp @@ -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(aContext); @@ -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(aContext)->HandleGetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/thread/network_diagnostic.hpp b/src/core/thread/network_diagnostic.hpp index 47b08bb4a8d..23ed352f652 100644 --- a/src/core/thread/network_diagnostic.hpp +++ b/src/core/thread/network_diagnostic.hpp @@ -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, @@ -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 void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); diff --git a/src/core/utils/channel_manager.cpp b/src/core/utils/channel_manager.cpp index fd4f04bff94..823b1c175ea 100644 --- a/src/core/utils/channel_manager.cpp +++ b/src/core/utils/channel_manager.cpp @@ -180,7 +180,7 @@ void ChannelManager::StartDatasetUpdate(void) } } -void ChannelManager::HandleDatasetUpdateDone(Error aError, void *aContext) +void ChannelManager::HandleDatasetUpdateDone(otError aError, void *aContext) { static_cast(aContext)->HandleDatasetUpdateDone(aError); } diff --git a/src/core/utils/channel_manager.hpp b/src/core/utils/channel_manager.hpp index d1f1e1b39c0..6d20d768056 100644 --- a/src/core/utils/channel_manager.hpp +++ b/src/core/utils/channel_manager.hpp @@ -323,7 +323,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD void StartDatasetUpdate(void); - static void HandleDatasetUpdateDone(Error aError, void *aContext); + static void HandleDatasetUpdateDone(otError aError, void *aContext); void HandleDatasetUpdateDone(Error aError); #endif void HandleTimer(void); diff --git a/src/core/utils/mesh_diag.cpp b/src/core/utils/mesh_diag.cpp index cb35f255b76..8b729142f5c 100644 --- a/src/core/utils/mesh_diag.cpp +++ b/src/core/utils/mesh_diag.cpp @@ -110,7 +110,7 @@ Error MeshDiag::DiscoverTopology(const DiscoverConfig &aConfig, DiscoverCallback void MeshDiag::HandleDiagGetResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult) + otError aResult) { static_cast(aContext)->HandleDiagGetResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo), aResult); diff --git a/src/core/utils/mesh_diag.hpp b/src/core/utils/mesh_diag.hpp index cfce10236ca..f86a93261fd 100644 --- a/src/core/utils/mesh_diag.hpp +++ b/src/core/utils/mesh_diag.hpp @@ -291,7 +291,7 @@ class MeshDiag : public InstanceLocator static void HandleDiagGetResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, - Error aResult); + otError aResult); using TimeoutTimer = TimerMilliIn;