From b5982b1dafd9ee9c0f5ca134b447fde43a755142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jasi=C5=84ski?= Date: Thu, 21 Sep 2023 16:36:38 +0200 Subject: [PATCH] apply comments - add module LogError, remove mContext and mTransportContext --- src/core/meshcop/dtls.cpp | 5 ----- src/core/meshcop/tcat_agent.cpp | 10 ++++++++++ src/core/meshcop/tcat_agent.hpp | 6 ++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index 80730d2c8692..74ee348fa620 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -84,9 +84,7 @@ Dtls::Dtls(Instance &aInstance, bool aLayerTwoSecurity, bool aDatagramTransport) , mLayerTwoSecurity(aLayerTwoSecurity) , mDatagramTransport(aDatagramTransport) , mReceiveMessage(nullptr) - , mContext(nullptr) , mSocket(aInstance) - , mTransportContext(nullptr) , mMessageSubType(Message::kSubTypeNone) , mMessageDefaultSubType(Message::kSubTypeNone) { @@ -150,7 +148,6 @@ Error Dtls::Open(ReceiveHandler aReceiveHandler, ConnectedHandler aConnectedHand mConnectedCallback.Set(aConnectedHandler, aContext); mReceiveCallback.Set(aReceiveHandler, aContext); - mContext = aContext; mState = kStateOpen; exit: @@ -245,7 +242,6 @@ Error Dtls::Bind(TransportCallback aCallback, void *aContext) VerifyOrExit(!mTransportCallback.IsSet(), error = kErrorAlready); mTransportCallback.Set(aCallback, aContext); - mTransportContext = aContext; exit: return error; @@ -458,7 +454,6 @@ void Dtls::Close(void) Disconnect(); mState = kStateClosed; - mTransportContext = nullptr; mTimerSet = false; mTransportCallback.Clear(); diff --git a/src/core/meshcop/tcat_agent.cpp b/src/core/meshcop/tcat_agent.cpp index f88be696cd52..0ca0718bb495 100644 --- a/src/core/meshcop/tcat_agent.cpp +++ b/src/core/meshcop/tcat_agent.cpp @@ -508,6 +508,16 @@ Error TcatAgent::HandleStartThreadInterface(void) return error; } +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) +void TcatAgent::LogError(const char *aActionText, Error aError) +{ + if (aError != kErrorNone) + { + LogWarn("Failed to %s: %s", aActionText, ErrorToString(aError)); + } +} +#endif + } // namespace MeshCoP } // namespace ot diff --git a/src/core/meshcop/tcat_agent.hpp b/src/core/meshcop/tcat_agent.hpp index 312dab8812a8..45b4b2a3ab03 100644 --- a/src/core/meshcop/tcat_agent.hpp +++ b/src/core/meshcop/tcat_agent.hpp @@ -380,6 +380,12 @@ class TcatAgent : public InstanceLocator, private NonCopyable Error HandleSetActiveOperationalDataset(const Message &aIncommingMessage, uint32_t aOffset, uint32_t aLength); Error HandleStartThreadInterface(void); +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) + void LogError(const char *aActionText, Error aError); +#else + void LogError(const char *, Error) {} +#endif + static constexpr uint16_t kJoinerUdpPort = OPENTHREAD_CONFIG_JOINER_UDP_PORT; JoinerPskd mJoinerPskd;