From ac89fd54965eec4342800e9da2b457216705bf6d Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 1 Feb 2019 09:03:24 -0800 Subject: [PATCH] [style] return void where code always returns OT_ERROR_NONE (#3543) --- src/core/api/crypto_api.cpp | 2 +- src/core/api/jam_detection_api.cpp | 4 +- src/core/api/joiner_api.cpp | 6 ++- src/core/api/link_api.cpp | 6 +-- src/core/api/thread_api.cpp | 2 +- src/core/api/thread_ftd_api.cpp | 4 +- src/core/coap/coap_secure.cpp | 3 +- src/core/common/message.cpp | 4 +- src/core/common/message.hpp | 4 +- src/core/crypto/aes_ccm.cpp | 3 +- src/core/crypto/aes_ccm.hpp | 2 +- src/core/mac/mac.cpp | 15 +++--- src/core/mac/mac.hpp | 16 ++---- src/core/mac/mac_frame.cpp | 55 ++++++--------------- src/core/mac/mac_frame.hpp | 54 +++++--------------- src/core/meshcop/dataset.cpp | 7 +-- src/core/meshcop/dataset.hpp | 11 ++--- src/core/meshcop/dtls.cpp | 8 ++- src/core/meshcop/dtls.hpp | 8 +-- src/core/meshcop/joiner.cpp | 4 +- src/core/meshcop/joiner.hpp | 4 +- src/core/meshcop/joiner_router.cpp | 4 +- src/core/meshcop/joiner_router.hpp | 4 +- src/core/net/dhcp6_client.cpp | 7 +-- src/core/net/dhcp6_client.hpp | 4 +- src/core/net/dhcp6_server.cpp | 8 ++- src/core/net/dhcp6_server.hpp | 4 +- src/core/net/icmp6.cpp | 3 +- src/core/net/icmp6.hpp | 5 +- src/core/net/ip6.cpp | 4 +- src/core/net/ip6_routes.cpp | 4 +- src/core/net/ip6_routes.hpp | 5 +- src/core/net/udp6.cpp | 23 +++++---- src/core/net/udp6.hpp | 13 ++--- src/core/thread/key_manager.cpp | 4 +- src/core/thread/key_manager.hpp | 2 +- src/core/thread/lowpan.cpp | 4 +- src/core/thread/lowpan.hpp | 2 +- src/core/thread/mesh_forwarder.cpp | 22 +++------ src/core/thread/mesh_forwarder.hpp | 10 ++-- src/core/thread/mesh_forwarder_ftd.cpp | 4 +- src/core/thread/mle.cpp | 18 +++---- src/core/thread/mle.hpp | 14 ++---- src/core/thread/mle_router.cpp | 48 +++++++----------- src/core/thread/mle_router_ftd.hpp | 18 +++---- src/core/thread/mle_router_mtd.hpp | 4 +- src/core/thread/network_data.cpp | 6 +-- src/core/thread/network_data.hpp | 9 +--- src/core/thread/network_data_leader_ftd.cpp | 36 ++++---------- src/core/thread/network_data_leader_ftd.hpp | 26 +++++----- src/core/thread/network_data_local.cpp | 21 +++----- src/core/thread/network_data_local.hpp | 12 ++--- src/core/utils/jam_detector.cpp | 4 +- src/core/utils/jam_detector.hpp | 4 +- src/ncp/ncp_buffer.cpp | 4 +- src/ncp/ncp_buffer.hpp | 5 +- src/ncp/spinel_encoder.cpp | 3 +- tests/unit/test_ncp_buffer.cpp | 26 +++++----- 58 files changed, 217 insertions(+), 399 deletions(-) diff --git a/src/core/api/crypto_api.cpp b/src/core/api/crypto_api.cpp index 2319880bd..7a330487b 100644 --- a/src/core/api/crypto_api.cpp +++ b/src/core/api/crypto_api.cpp @@ -76,7 +76,7 @@ void otCryptoAesCcm(const uint8_t *aKey, assert((aKey != NULL) && (aNonce != NULL) && (aPlainText != NULL) && (aCipherText != NULL) && (aTag != NULL)); - SuccessOrExit(aesCcm.SetKey(aKey, aKeyLength)); + aesCcm.SetKey(aKey, aKeyLength); SuccessOrExit(aesCcm.Init(aHeaderLength, aLength, aTagLength, aNonce, aNonceLength)); if (aHeaderLength != 0) diff --git a/src/core/api/jam_detection_api.cpp b/src/core/api/jam_detection_api.cpp index edfd77ed6..a17e22a85 100644 --- a/src/core/api/jam_detection_api.cpp +++ b/src/core/api/jam_detection_api.cpp @@ -45,7 +45,9 @@ otError otJamDetectionSetRssiThreshold(otInstance *aInstance, int8_t aRssiThresh { Instance &instance = *static_cast(aInstance); - return instance.GetThreadNetif().GetJamDetector().SetRssiThreshold(aRssiThreshold); + instance.GetThreadNetif().GetJamDetector().SetRssiThreshold(aRssiThreshold); + + return OT_ERROR_NONE; } int8_t otJamDetectionGetRssiThreshold(otInstance *aInstance) diff --git a/src/core/api/joiner_api.cpp b/src/core/api/joiner_api.cpp index 19bd5de40..620bfff02 100644 --- a/src/core/api/joiner_api.cpp +++ b/src/core/api/joiner_api.cpp @@ -72,14 +72,16 @@ otError otJoinerStart(otInstance * aInstance, otError otJoinerStop(otInstance *aInstance) { - otError error = OT_ERROR_DISABLED_FEATURE; + otError error; #if OPENTHREAD_ENABLE_JOINER Instance &instance = *static_cast(aInstance); - error = instance.GetThreadNetif().GetJoiner().Stop(); + instance.GetThreadNetif().GetJoiner().Stop(); + error = OT_ERROR_NONE; #else OT_UNUSED_VARIABLE(aInstance); + error = OT_ERROR_DISABLED_FEATURE; #endif return error; diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index 8cb151483..6ad3dcadb 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -104,7 +104,7 @@ otError otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExt instance.GetThreadNetif().GetMac().SetExtAddress(*static_cast(aExtAddress)); - SuccessOrExit(error = instance.GetThreadNetif().GetMle().UpdateLinkLocalAddress()); + instance.GetThreadNetif().GetMle().UpdateLinkLocalAddress(); exit: return error; @@ -130,7 +130,7 @@ otError otLinkSetPanId(otInstance *aInstance, otPanId aPanId) VerifyOrExit(instance.GetThreadNetif().GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED, error = OT_ERROR_INVALID_STATE); - error = instance.GetThreadNetif().GetMac().SetPanId(aPanId); + instance.GetThreadNetif().GetMac().SetPanId(aPanId); instance.GetThreadNetif().GetActiveDataset().Clear(); instance.GetThreadNetif().GetPendingDataset().Clear(); @@ -318,7 +318,7 @@ otError otLinkSetEnabled(otInstance *aInstance, bool aEnable) // cannot disable the link layer if the Thread interface is enabled VerifyOrExit(instance.GetThreadNetif().IsUp() == false, error = OT_ERROR_INVALID_STATE); - error = instance.GetThreadNetif().GetMac().SetEnabled(aEnable); + instance.GetThreadNetif().GetMac().SetEnabled(aEnable); exit: return error; diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index 92d1e6a01..bba3cba99 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -451,7 +451,7 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled) } else { - error = instance.GetThreadNetif().GetMle().Stop(true); + instance.GetThreadNetif().GetMle().Stop(true); } exit: diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp index 6c7963446..ee21adc92 100644 --- a/src/core/api/thread_ftd_api.cpp +++ b/src/core/api/thread_ftd_api.cpp @@ -119,7 +119,9 @@ otError otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort) { Instance &instance = *static_cast(aInstance); - return instance.GetThreadNetif().GetJoinerRouter().SetJoinerUdpPort(aJoinerUdpPort); + instance.GetThreadNetif().GetJoinerRouter().SetJoinerUdpPort(aJoinerUdpPort); + + return OT_ERROR_NONE; } uint32_t otThreadGetContextIdReuseDelay(otInstance *aInstance) diff --git a/src/core/coap/coap_secure.cpp b/src/core/coap/coap_secure.cpp index 1641fb057..f3d5c8727 100644 --- a/src/core/coap/coap_secure.cpp +++ b/src/core/coap/coap_secure.cpp @@ -151,7 +151,8 @@ otError CoapSecure::Disconnect(void) Ip6::SockAddr sockAddr; otError error = OT_ERROR_NONE; - SuccessOrExit(error = GetNetif().GetDtls().Stop()); + GetNetif().GetDtls().Stop(); + // Disconnect from previous peer by connecting to any address SuccessOrExit(error = mSocket.Connect(sockAddr)); diff --git a/src/core/common/message.cpp b/src/core/common/message.cpp index 9c402022d..6eafd3228 100644 --- a/src/core/common/message.cpp +++ b/src/core/common/message.cpp @@ -493,7 +493,7 @@ exit: return error; } -otError Message::RemoveHeader(uint16_t aLength) +void Message::RemoveHeader(uint16_t aLength) { assert(aLength <= mBuffer.mHead.mInfo.mLength); @@ -508,8 +508,6 @@ otError Message::RemoveHeader(uint16_t aLength) { mBuffer.mHead.mInfo.mOffset = 0; } - - return OT_ERROR_NONE; } uint16_t Message::Read(uint16_t aOffset, uint16_t aLength, void *aBuf) const diff --git a/src/core/common/message.hpp b/src/core/common/message.hpp index 575142524..1649411e7 100644 --- a/src/core/common/message.hpp +++ b/src/core/common/message.hpp @@ -387,10 +387,8 @@ public: * * @param[in] aLength Number of header bytes to remove. * - * @retval OT_ERROR_NONE Successfully removed header bytes from the message. - * */ - otError RemoveHeader(uint16_t aLength); + void RemoveHeader(uint16_t aLength); /** * This method appends bytes to the end of the message. diff --git a/src/core/crypto/aes_ccm.cpp b/src/core/crypto/aes_ccm.cpp index 73c163c98..09c7e6c8f 100644 --- a/src/core/crypto/aes_ccm.cpp +++ b/src/core/crypto/aes_ccm.cpp @@ -39,10 +39,9 @@ namespace ot { namespace Crypto { -otError AesCcm::SetKey(const uint8_t *aKey, uint16_t aKeyLength) +void AesCcm::SetKey(const uint8_t *aKey, uint16_t aKeyLength) { mEcb.SetKey(aKey, 8 * aKeyLength); - return OT_ERROR_NONE; } otError AesCcm::Init(uint32_t aHeaderLength, diff --git a/src/core/crypto/aes_ccm.hpp b/src/core/crypto/aes_ccm.hpp index f4ca1df91..4001cb70e 100644 --- a/src/core/crypto/aes_ccm.hpp +++ b/src/core/crypto/aes_ccm.hpp @@ -66,7 +66,7 @@ public: * @param[in] aKeyLength Length of the key in bytes. * */ - otError SetKey(const uint8_t *aKey, uint16_t aKeyLength); + void SetKey(const uint8_t *aKey, uint16_t aKeyLength); /** * This method initializes the AES CCM computation. diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 499375e46..f09ff707f 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -349,10 +349,9 @@ exit: return; } -otError Mac::SetShortAddress(ShortAddress aShortAddress) +void Mac::SetShortAddress(ShortAddress aShortAddress) { mSubMac.SetShortAddress(aShortAddress); - return OT_ERROR_NONE; } otError Mac::SetPanChannel(uint8_t aChannel) @@ -461,7 +460,7 @@ exit: return error; } -otError Mac::SetPanId(PanId aPanId) +void Mac::SetPanId(PanId aPanId) { VerifyOrExit(mPanId != aPanId, GetNotifier().SignalIfFirst(OT_CHANGED_THREAD_PANID)); mPanId = aPanId; @@ -469,10 +468,10 @@ otError Mac::SetPanId(PanId aPanId) GetNotifier().Signal(OT_CHANGED_THREAD_PANID); exit: - return OT_ERROR_NONE; + return; } -otError Mac::SetExtendedPanId(const otExtendedPanId &aExtendedPanId) +void Mac::SetExtendedPanId(const otExtendedPanId &aExtendedPanId) { VerifyOrExit(memcmp(mExtendedPanId.m8, aExtendedPanId.m8, sizeof(mExtendedPanId)) != 0, GetNotifier().SignalIfFirst(OT_CHANGED_THREAD_EXT_PANID)); @@ -481,7 +480,7 @@ otError Mac::SetExtendedPanId(const otExtendedPanId &aExtendedPanId) GetNotifier().Signal(OT_CHANGED_THREAD_EXT_PANID); exit: - return OT_ERROR_NONE; + return; } otError Mac::SendFrameRequest(void) @@ -1756,11 +1755,9 @@ void Mac::SetPromiscuous(bool aPromiscuous) UpdateIdleMode(); } -otError Mac::SetEnabled(bool aEnable) +void Mac::SetEnabled(bool aEnable) { mEnabled = aEnable; - - return OT_ERROR_NONE; } void Mac::ResetCounters(void) diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index f7f41c7d4..3e51e7298 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -269,10 +269,8 @@ public: * * @param[in] aShortAddress The IEEE 802.15.4 Short Address. * - * @retval OT_ERROR_NONE Successfully set the IEEE 802.15.4 Short Address. - * */ - otError SetShortAddress(ShortAddress aShortAddress); + void SetShortAddress(ShortAddress aShortAddress); /** * This method returns the IEEE 802.15.4 PAN Channel. @@ -395,10 +393,8 @@ public: * * @param[in] aPanId The IEEE 802.15.4 PAN ID. * - * @retval OT_ERROR_NONE Successfully set the IEEE 802.15.4 PAN ID. - * */ - otError SetPanId(PanId aPanId); + void SetPanId(PanId aPanId); /** * This method returns the IEEE 802.15.4 Extended PAN ID. @@ -413,10 +409,8 @@ public: * * @param[in] aExtendedPanId The IEEE 802.15.4 Extended PAN ID. * - * @retval OT_ERROR_NONE Successfully set the IEEE 802.15.4 Extended PAN ID. - * */ - otError SetExtendedPanId(const otExtendedPanId &aExtendedPanId); + void SetExtendedPanId(const otExtendedPanId &aExtendedPanId); #if OPENTHREAD_ENABLE_MAC_FILTER /** @@ -572,10 +566,8 @@ public: * * @param[in] aEnable The requested State for the MAC layer. true - Start, false - Stop. * - * @retval OT_ERROR_NONE The operation succeeded or the new State equals the current State. - * */ - otError SetEnabled(bool aEnable); + void SetEnabled(bool aEnable); /** * This method indicates whether or not the link layer is enabled. diff --git a/src/core/mac/mac_frame.cpp b/src/core/mac/mac_frame.cpp index 645faeacd..80a30a0f3 100644 --- a/src/core/mac/mac_frame.cpp +++ b/src/core/mac/mac_frame.cpp @@ -89,7 +89,7 @@ Address::InfoString Address::ToString(void) const : (mType == kTypeNone ? InfoString("None") : InfoString("0x%04x", GetShort())); } -otError Frame::InitMacHeader(uint16_t aFcf, uint8_t aSecurityControl) +void Frame::InitMacHeader(uint16_t aFcf, uint8_t aSecurityControl) { uint8_t *bytes = GetPsdu(); uint8_t length = 0; @@ -180,8 +180,6 @@ otError Frame::InitMacHeader(uint16_t aFcf, uint8_t aSecurityControl) } SetPsduLength(length + GetFooterLength()); - - return OT_ERROR_NONE; } uint16_t Frame::GetFrameControlField(void) const @@ -250,14 +248,12 @@ exit: return error; } -otError Frame::SetDstPanId(PanId aPanId) +void Frame::SetDstPanId(PanId aPanId) { uint8_t index = FindDstPanIdIndex(); assert(index != kInvalidIndex); Encoding::LittleEndian::WriteUint16(aPanId, GetPsdu() + index); - - return OT_ERROR_NONE; } uint8_t Frame::FindDstAddrIndex(void) const @@ -291,15 +287,13 @@ exit: return error; } -otError Frame::SetDstAddr(ShortAddress aShortAddress) +void Frame::SetDstAddr(ShortAddress aShortAddress) { assert((GetFrameControlField() & kFcfDstAddrMask) == kFcfDstAddrShort); Encoding::LittleEndian::WriteUint16(aShortAddress, GetPsdu() + FindDstAddrIndex()); - - return OT_ERROR_NONE; } -otError Frame::SetDstAddr(const ExtAddress &aExtAddress) +void Frame::SetDstAddr(const ExtAddress &aExtAddress) { uint8_t index = FindDstAddrIndex(); uint8_t *buf = GetPsdu() + index; @@ -311,30 +305,24 @@ otError Frame::SetDstAddr(const ExtAddress &aExtAddress) { buf[i] = aExtAddress.m8[sizeof(ExtAddress) - 1 - i]; } - - return OT_ERROR_NONE; } -otError Frame::SetDstAddr(const Address &aAddress) +void Frame::SetDstAddr(const Address &aAddress) { - otError error = OT_ERROR_NONE; - switch (aAddress.GetType()) { case Address::kTypeShort: - error = SetDstAddr(aAddress.GetShort()); + SetDstAddr(aAddress.GetShort()); break; case Address::kTypeExtended: - error = SetDstAddr(aAddress.GetExtended()); + SetDstAddr(aAddress.GetExtended()); break; default: assert(false); break; } - - return error; } uint8_t Frame::FindSrcPanIdIndex(void) const @@ -471,7 +459,7 @@ exit: return error; } -otError Frame::SetSrcAddr(ShortAddress aShortAddress) +void Frame::SetSrcAddr(ShortAddress aShortAddress) { uint8_t index = FindSrcAddrIndex(); @@ -479,11 +467,9 @@ otError Frame::SetSrcAddr(ShortAddress aShortAddress) assert(index != kInvalidIndex); Encoding::LittleEndian::WriteUint16(aShortAddress, GetPsdu() + index); - - return OT_ERROR_NONE; } -otError Frame::SetSrcAddr(const ExtAddress &aExtAddress) +void Frame::SetSrcAddr(const ExtAddress &aExtAddress) { uint8_t index = FindSrcAddrIndex(); uint8_t *buf = GetPsdu() + index; @@ -495,30 +481,24 @@ otError Frame::SetSrcAddr(const ExtAddress &aExtAddress) { buf[i] = aExtAddress.m8[sizeof(aExtAddress) - 1 - i]; } - - return OT_ERROR_NONE; } -otError Frame::SetSrcAddr(const Address &aAddress) +void Frame::SetSrcAddr(const Address &aAddress) { - otError error = OT_ERROR_NONE; - switch (aAddress.GetType()) { case Address::kTypeShort: - error = SetSrcAddr(aAddress.GetShort()); + SetSrcAddr(aAddress.GetShort()); break; case Address::kTypeExtended: - error = SetSrcAddr(aAddress.GetExtended()); + SetSrcAddr(aAddress.GetExtended()); break; default: assert(false); break; } - - return error; } uint8_t Frame::FindSecurityHeaderIndex(void) const @@ -607,7 +587,7 @@ exit: return error; } -otError Frame::SetFrameCounter(uint32_t aFrameCounter) +void Frame::SetFrameCounter(uint32_t aFrameCounter) { uint8_t index = FindSecurityHeaderIndex(); @@ -617,8 +597,6 @@ otError Frame::SetFrameCounter(uint32_t aFrameCounter) index += kSecurityControlSize; Encoding::LittleEndian::WriteUint32(aFrameCounter, GetPsdu() + index); - - return OT_ERROR_NONE; } const uint8_t *Frame::GetKeySource(void) const @@ -694,7 +672,7 @@ exit: return error; } -otError Frame::SetKeyId(uint8_t aKeyId) +void Frame::SetKeyId(uint8_t aKeyId) { uint8_t keySourceLength; uint8_t index = FindSecurityHeaderIndex(); @@ -707,8 +685,6 @@ otError Frame::SetKeyId(uint8_t aKeyId) buf += kSecurityControlSize + kFrameCounterSize + keySourceLength; buf[0] = aKeyId; - - return OT_ERROR_NONE; } otError Frame::GetCommandId(uint8_t &aCommandId) const @@ -802,10 +778,9 @@ uint8_t Frame::GetPayloadLength(void) const return GetPsduLength() - (GetHeaderLength() + GetFooterLength()); } -otError Frame::SetPayloadLength(uint8_t aLength) +void Frame::SetPayloadLength(uint8_t aLength) { SetPsduLength(GetHeaderLength() + GetFooterLength() + aLength); - return OT_ERROR_NONE; } uint8_t Frame::SkipSecurityHeaderIndex(void) const diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index d1b44c7cf..31c921d81 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -552,11 +552,8 @@ public: * @param[in] aFcf The Frame Control field. * @param[in] aSecCtl The Security Control field. * - * @retval OT_ERROR_NONE Successfully initialized the MAC header. - * @retval OT_ERROR_INVALID_ARGS Invalid values for @p aFcf and/or @p aSecCtl. - * */ - otError InitMacHeader(uint16_t aFcf, uint8_t aSecCtl); + void InitMacHeader(uint16_t aFcf, uint8_t aSecCtl); /** * This method validates the frame. @@ -666,10 +663,8 @@ public: * * @param[in] aPanId The Destination PAN Identifier. * - * @retval OT_ERROR_NONE Successfully set the Destination PAN Identifier. - * */ - otError SetDstPanId(PanId aPanId); + void SetDstPanId(PanId aPanId); /** * This method gets the Destination Address. @@ -686,30 +681,24 @@ public: * * @param[in] aShortAddress The Destination Address. * - * @retval OT_ERROR_NONE Successfully set the Destination Address. - * */ - otError SetDstAddr(ShortAddress aShortAddress); + void SetDstAddr(ShortAddress aShortAddress); /** * This method sets the Destination Address. * * @param[in] aExtAddress The Destination Address. * - * @retval OT_ERROR_NONE Successfully set the Destination Address. - * */ - otError SetDstAddr(const ExtAddress &aExtAddress); + void SetDstAddr(const ExtAddress &aExtAddress); /** * This method sets the Destination Address. * * @param[in] aAddress The Destination Address. * - * @retval OT_ERROR_NONE Successfully set the Destination Address. - * */ - otError SetDstAddr(const Address &aAddress); + void SetDstAddr(const Address &aAddress); /** * This method indicates whether or not the Src PanId is present. @@ -754,30 +743,24 @@ public: * * @param[in] aShortAddress The Source Address. * - * @retval OT_ERROR_NONE Successfully set the Source Address. - * */ - otError SetSrcAddr(ShortAddress aShortAddress); + void SetSrcAddr(ShortAddress aShortAddress); /** * This method sets the Source Address. * * @param[in] aExtAddress The Source Address. * - * @retval OT_ERROR_NONE Successfully set the Source Address. - * */ - otError SetSrcAddr(const ExtAddress &aExtAddress); + void SetSrcAddr(const ExtAddress &aExtAddress); /** * This method sets the Source Address. * * @param[in] aAddress The Source Address. * - * @retval OT_ERROR_NONE Successfully set the Source Address. - * */ - otError SetSrcAddr(const Address &aAddress); + void SetSrcAddr(const Address &aAddress); /** * This method gets the Security Level Identifier. @@ -814,10 +797,8 @@ public: * * @param[in] aFrameCounter The Frame Counter. * - * @retval OT_ERROR_NONE Successfully set the Frame Counter. - * */ - otError SetFrameCounter(uint32_t aFrameCounter); + void SetFrameCounter(uint32_t aFrameCounter); /** * This method returns a pointer to the Key Source. @@ -850,10 +831,8 @@ public: * * @param[in] aKeyId The Key Identifier. * - * @retval OT_ERROR_NONE Successfully set the Key Identifier. - * */ - otError SetKeyId(uint8_t aKeyId); + void SetKeyId(uint8_t aKeyId); /** * This method gets the Command ID. @@ -896,14 +875,8 @@ public: * * @param[in] aLength The MAC Frame Length. * - * @retval OT_ERROR_NONE Successfully set the MAC Frame Length. - * */ - otError SetLength(uint8_t aLength) - { - SetPsduLength(aLength); - return OT_ERROR_NONE; - } + void SetLength(uint8_t aLength) { SetPsduLength(aLength); } /** * This method returns the MAC header size. @@ -940,11 +913,8 @@ public: /** * This method sets the MAC Payload length. * - * @retval OT_ERROR_NONE Successfully set the MAC Payload length. - * @retval OT_ERROR_INVALID_ARGS The @p aLength value was invalid. - * */ - otError SetPayloadLength(uint8_t aLength); + void SetPayloadLength(uint8_t aLength); /** * This method returns the IEEE 802.15.4 channel used for transmission or reception. diff --git a/src/core/meshcop/dataset.cpp b/src/core/meshcop/dataset.cpp index 6bb910d58..51c9ee971 100644 --- a/src/core/meshcop/dataset.cpp +++ b/src/core/meshcop/dataset.cpp @@ -240,7 +240,7 @@ void Dataset::Get(otOperationalDataset &aDataset) const } } -otError Dataset::Set(const Dataset &aDataset) +void Dataset::Set(const Dataset &aDataset) { memcpy(mTlvs, aDataset.mTlvs, aDataset.mLength); mLength = aDataset.mLength; @@ -252,8 +252,6 @@ otError Dataset::Set(const Dataset &aDataset) } mUpdateTime = aDataset.GetUpdateTime(); - - return OT_ERROR_NONE; } otError Dataset::Set(const otOperationalDataset &aDataset) @@ -620,12 +618,11 @@ exit: return error; } -otError Dataset::ConvertToActive(void) +void Dataset::ConvertToActive(void) { Remove(Tlv::kPendingTimestamp); Remove(Tlv::kDelayTimer); mType = Tlv::kActiveTimestamp; - return OT_ERROR_NONE; } } // namespace MeshCoP diff --git a/src/core/meshcop/dataset.hpp b/src/core/meshcop/dataset.hpp index a699cc2de..9aa50727c 100644 --- a/src/core/meshcop/dataset.hpp +++ b/src/core/meshcop/dataset.hpp @@ -187,17 +187,16 @@ public: * * @param[in] aDataset The input Dataset. * - * @retval OT_ERROR_NONE Successfully set the Dataset. - * */ - otError Set(const Dataset &aDataset); + void Set(const Dataset &aDataset); /** * This method sets the Dataset. * * @param[in] aDataset The input Dataset. * - * @retval OT_ERROR_NONE Successfully set the Dataset. + * @retval OT_ERROR_NONE Successfully set the Dataset. + * @retval OT_ERROR_INVALID_ARGS Dataset is missing Active and/or Pending Timestamp. * */ otError Set(const otOperationalDataset &aDataset); @@ -236,10 +235,8 @@ public: * * This method removes the Delay Timer and Pending Timestamp TLVs * - * @retval OT_ERROR_NONE Successfully converted to Active Dataset. - * */ - otError ConvertToActive(void); + void ConvertToActive(void); private: void Remove(uint8_t *aStart, uint8_t aLength); diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index d908684de..64c24384f 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -330,7 +330,7 @@ void Dtls::SetSslAuthMode(bool aVerifyPeerCertificate) #endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE -otError Dtls::Stop(void) +void Dtls::Stop(void) { VerifyOrExit((mState == kStateConnecting) || (mState == kStateConnected)); @@ -338,7 +338,7 @@ otError Dtls::Stop(void) Close(); exit: - return OT_ERROR_NONE; + return; } void Dtls::Close(void) @@ -489,15 +489,13 @@ exit: return error; } -otError Dtls::Receive(Message &aMessage, uint16_t aOffset, uint16_t aLength) +void Dtls::Receive(Message &aMessage, uint16_t aOffset, uint16_t aLength) { mReceiveMessage = &aMessage; mReceiveOffset = aOffset; mReceiveLength = aLength; Process(); - - return OT_ERROR_NONE; } int Dtls::HandleMbedtlsTransmit(void *aContext, const unsigned char *aBuf, size_t aLength) diff --git a/src/core/meshcop/dtls.hpp b/src/core/meshcop/dtls.hpp index 1c383eefc..8c5c50bf6 100644 --- a/src/core/meshcop/dtls.hpp +++ b/src/core/meshcop/dtls.hpp @@ -150,10 +150,8 @@ public: /** * This method stops the DTLS service. * - * @retval OT_ERROR_NONE Successfully stopped the DTLS service. - * */ - otError Stop(void); + void Stop(void); /** * This method returns the DTLS connection state. @@ -297,10 +295,8 @@ public: * @param[in] aOffset The offset within @p aMessage where the DTLS message starts. * @param[in] aLength The size of the DTLS message (bytes). * - * @retval OT_ERROR_NONE Successfully processed the received DTLS message. - * */ - otError Receive(Message &aMessage, uint16_t aOffset, uint16_t aLength); + void Receive(Message &aMessage, uint16_t aOffset, uint16_t aLength); /** * This method sets the default message sub-type that will be used for all messages without defined diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index 0b51108af..dbbc96c5e 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -142,11 +142,9 @@ exit: return error; } -otError Joiner::Stop(void) +void Joiner::Stop(void) { Close(); - - return OT_ERROR_NONE; } otJoinerState Joiner::GetState(void) const diff --git a/src/core/meshcop/joiner.hpp b/src/core/meshcop/joiner.hpp index 2a365cf52..64fd6892c 100644 --- a/src/core/meshcop/joiner.hpp +++ b/src/core/meshcop/joiner.hpp @@ -90,10 +90,8 @@ public: /** * This method stops the Joiner service. * - * @retval OT_ERROR_NONE Successfully stopped the Joiner service. - * */ - otError Stop(void); + void Stop(void); /** * This function returns the Joiner State. diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index 0710d28af..9ddd17c58 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -121,13 +121,11 @@ exit: return rval; } -otError JoinerRouter::SetJoinerUdpPort(uint16_t aJoinerUdpPort) +void JoinerRouter::SetJoinerUdpPort(uint16_t aJoinerUdpPort) { mJoinerUdpPort = aJoinerUdpPort; mIsJoinerPortConfigured = true; HandleStateChanged(OT_CHANGED_THREAD_NETDATA); - - return OT_ERROR_NONE; } void JoinerRouter::HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo) diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp index 01b397540..1df96572e 100644 --- a/src/core/meshcop/joiner_router.hpp +++ b/src/core/meshcop/joiner_router.hpp @@ -75,10 +75,8 @@ public: * * @param[in] The Joiner UDP Port number. * - * @retval OT_ERROR_NONE Successfully set the Joiner UDP Port. - * */ - otError SetJoinerUdpPort(uint16_t aJoinerUdpPort); + void SetJoinerUdpPort(uint16_t aJoinerUdpPort); private: enum diff --git a/src/core/net/dhcp6_client.cpp b/src/core/net/dhcp6_client.cpp index 657ecd1f4..24d1a04f3 100644 --- a/src/core/net/dhcp6_client.cpp +++ b/src/core/net/dhcp6_client.cpp @@ -170,7 +170,7 @@ void Dhcp6Client::UpdateAddresses(void) } } -otError Dhcp6Client::Start(void) +void Dhcp6Client::Start(void) { Ip6::SockAddr sockaddr; @@ -179,14 +179,11 @@ otError Dhcp6Client::Start(void) mSocket.Bind(sockaddr); ProcessNextIdentityAssociation(); - - return OT_ERROR_NONE; } -otError Dhcp6Client::Stop(void) +void Dhcp6Client::Stop(void) { mSocket.Close(); - return OT_ERROR_NONE; } bool Dhcp6Client::ProcessNextIdentityAssociation() diff --git a/src/core/net/dhcp6_client.hpp b/src/core/net/dhcp6_client.hpp index 850ae26e9..c7fdfa951 100644 --- a/src/core/net/dhcp6_client.hpp +++ b/src/core/net/dhcp6_client.hpp @@ -117,8 +117,8 @@ public: void UpdateAddresses(void); private: - otError Start(void); - otError Stop(void); + void Start(void); + void Stop(void); static bool MatchNetifAddressWithPrefix(const otNetifAddress &aNetifAddress, const otIp6Prefix &aIp6Prefix); diff --git a/src/core/net/dhcp6_server.cpp b/src/core/net/dhcp6_server.cpp index 659a36bc2..02aadf2be 100644 --- a/src/core/net/dhcp6_server.cpp +++ b/src/core/net/dhcp6_server.cpp @@ -188,20 +188,18 @@ exit: return error; } -otError Dhcp6Server::Start(void) +void Dhcp6Server::Start(void) { Ip6::SockAddr sockaddr; + sockaddr.mPort = kDhcpServerPort; mSocket.Open(&Dhcp6Server::HandleUdpReceive, this); mSocket.Bind(sockaddr); - - return OT_ERROR_NONE; } -otError Dhcp6Server::Stop(void) +void Dhcp6Server::Stop(void) { mSocket.Close(); - return OT_ERROR_NONE; } otError Dhcp6Server::AddPrefixAgent(otIp6Prefix &aIp6Prefix) diff --git a/src/core/net/dhcp6_server.hpp b/src/core/net/dhcp6_server.hpp index d3c3de8f4..29d7cb55e 100644 --- a/src/core/net/dhcp6_server.hpp +++ b/src/core/net/dhcp6_server.hpp @@ -113,8 +113,8 @@ public: otError UpdateService(); private: - otError Start(void); - otError Stop(void); + void Start(void); + void Stop(void); otError AddPrefixAgent(otIp6Prefix &aIp6Prefix); otError RemovePrefixAgent(const uint8_t *aIp6Address); diff --git a/src/core/net/icmp6.cpp b/src/core/net/icmp6.cpp index 83b024ff4..67454099a 100644 --- a/src/core/net/icmp6.cpp +++ b/src/core/net/icmp6.cpp @@ -250,7 +250,7 @@ exit: return error; } -otError Icmp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) +void Icmp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) { aChecksum = aMessage.UpdateChecksum(aChecksum, aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset()); @@ -261,7 +261,6 @@ otError Icmp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) aChecksum = HostSwap16(aChecksum); aMessage.Write(aMessage.GetOffset() + IcmpHeader::GetChecksumOffset(), sizeof(aChecksum), &aChecksum); - return OT_ERROR_NONE; } } // namespace Ip6 diff --git a/src/core/net/icmp6.hpp b/src/core/net/icmp6.hpp index 116121f07..84b3d67c1 100644 --- a/src/core/net/icmp6.hpp +++ b/src/core/net/icmp6.hpp @@ -312,11 +312,8 @@ public: * @param[in] aMessage A reference to the ICMPv6 message. * @param[in] aPseudoHeaderChecksum The pseudo-header checksum value. * - * @retval OT_ERROR_NONE Successfully updated the ICMPv6 checksum. - * @retval OT_ERROR_INVALID_ARGS The message was invalid. - * */ - otError UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum); + void UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum); /** * This method indicates whether or not ICMPv6 Echo processing is enabled. diff --git a/src/core/net/ip6.cpp b/src/core/net/ip6.cpp index 2c8e0f96c..9bfcf9b70 100644 --- a/src/core/net/ip6.cpp +++ b/src/core/net/ip6.cpp @@ -487,11 +487,11 @@ otError Ip6::SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, IpProto switch (aIpProto) { case kProtoUdp: - SuccessOrExit(error = mUdp.UpdateChecksum(aMessage, checksum)); + mUdp.UpdateChecksum(aMessage, checksum); break; case kProtoIcmp6: - SuccessOrExit(error = mIcmp.UpdateChecksum(aMessage, checksum)); + mIcmp.UpdateChecksum(aMessage, checksum); break; default: diff --git a/src/core/net/ip6_routes.cpp b/src/core/net/ip6_routes.cpp index 9b37c4600..a8dc8b1cd 100644 --- a/src/core/net/ip6_routes.cpp +++ b/src/core/net/ip6_routes.cpp @@ -64,7 +64,7 @@ exit: return error; } -otError Routes::Remove(Route &aRoute) +void Routes::Remove(Route &aRoute) { if (&aRoute == mRoutes) { @@ -83,8 +83,6 @@ otError Routes::Remove(Route &aRoute) } aRoute.mNext = NULL; - - return OT_ERROR_NONE; } int8_t Routes::Lookup(const Address &aSource, const Address &aDestination) diff --git a/src/core/net/ip6_routes.hpp b/src/core/net/ip6_routes.hpp index ff1646096..59470123c 100644 --- a/src/core/net/ip6_routes.hpp +++ b/src/core/net/ip6_routes.hpp @@ -96,11 +96,8 @@ public: * * @param[in] aRoute A reference to the IPv6 route. * - * @retval OT_ERROR_NONE Successfully removed the route. - * @retval OT_ERROR_NOT_FOUND The route was not added. - * */ - otError Remove(Route &aRoute); + void Remove(Route &aRoute); /** * This method performs source-destination route lookup. diff --git a/src/core/net/udp6.cpp b/src/core/net/udp6.cpp index 3d5b33953..2298f5ae2 100644 --- a/src/core/net/udp6.cpp +++ b/src/core/net/udp6.cpp @@ -76,7 +76,7 @@ Message *UdpSocket::NewMessage(uint16_t aReserved, const otMessageSettings *aSet otError UdpSocket::Open(otUdpReceive aHandler, void *aContext) { - otError error; + otError error = OT_ERROR_NONE; memset(&mSockName, 0, sizeof(mSockName)); memset(&mPeerName, 0, sizeof(mPeerName)); @@ -86,9 +86,12 @@ otError UdpSocket::Open(otUdpReceive aHandler, void *aContext) #if OPENTHREAD_ENABLE_PLATFORM_UDP SuccessOrExit(error = otPlatUdpSocket(this)); #endif - SuccessOrExit(error = GetUdp().AddSocket(*this)); + GetUdp().AddSocket(*this); + +#if OPENTHREAD_ENABLE_PLATFORM_UDP exit: +#endif return error; } @@ -140,11 +143,14 @@ otError UdpSocket::Close(void) #if OPENTHREAD_ENABLE_PLATFORM_UDP SuccessOrExit(error = otPlatUdpClose(this)); #endif - SuccessOrExit(error = GetUdp().RemoveSocket(*this)); + + GetUdp().RemoveSocket(*this); memset(&mSockName, 0, sizeof(mSockName)); memset(&mPeerName, 0, sizeof(mPeerName)); +#if OPENTHREAD_ENABLE_PLATFORM_UDP exit: +#endif return error; } @@ -253,7 +259,7 @@ otError Udp::RemoveReceiver(UdpReceiver &aReceiver) return error; } -otError Udp::AddSocket(UdpSocket &aSocket) +void Udp::AddSocket(UdpSocket &aSocket) { for (UdpSocket *cur = mSockets; cur; cur = cur->GetNext()) { @@ -267,10 +273,10 @@ otError Udp::AddSocket(UdpSocket &aSocket) mSockets = &aSocket; exit: - return OT_ERROR_NONE; + return; } -otError Udp::RemoveSocket(UdpSocket &aSocket) +void Udp::RemoveSocket(UdpSocket &aSocket) { if (mSockets == &aSocket) { @@ -289,8 +295,6 @@ otError Udp::RemoveSocket(UdpSocket &aSocket) } aSocket.SetNext(NULL); - - return OT_ERROR_NONE; } uint16_t Udp::GetEphemeralPort(void) @@ -431,7 +435,7 @@ void Udp::HandlePayload(Message &aMessage, MessageInfo &aMessageInfo) } } -otError Udp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) +void Udp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) { aChecksum = aMessage.UpdateChecksum(aChecksum, aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset()); @@ -442,7 +446,6 @@ otError Udp::UpdateChecksum(Message &aMessage, uint16_t aChecksum) aChecksum = HostSwap16(aChecksum); aMessage.Write(aMessage.GetOffset() + UdpHeader::GetChecksumOffset(), sizeof(aChecksum), &aChecksum); - return OT_ERROR_NONE; } } // namespace Ip6 diff --git a/src/core/net/udp6.hpp b/src/core/net/udp6.hpp index b4bd0e774..7c7decd8f 100644 --- a/src/core/net/udp6.hpp +++ b/src/core/net/udp6.hpp @@ -248,20 +248,16 @@ public: * * @param[in] aSocket A reference to the UDP socket. * - * @retval OT_ERROR_NONE Successfully added the UDP socket. - * */ - otError AddSocket(UdpSocket &aSocket); + void AddSocket(UdpSocket &aSocket); /** * This method removes a UDP socket. * * @param[in] aSocket A reference to the UDP socket. * - * @retval OT_ERROR_NONE Successfully removed the UDP socket. - * */ - otError RemoveSocket(UdpSocket &aSocket); + void RemoveSocket(UdpSocket &aSocket); /** * This method returns a new ephemeral port. @@ -322,11 +318,8 @@ public: * @param[in] aMessage A reference to the UDP message. * @param[in] aPseudoHeaderChecksum The pseudo-header checksum value. * - * @retval OT_ERROR_NONE Successfully updated the UDP checksum. - * @retval OT_ERROR_INVALID_ARGS The message was invalid. - * */ - otError UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum); + void UpdateChecksum(Message &aMessage, uint16_t aPseudoHeaderChecksum); #if OPENTHREAD_ENABLE_PLATFORM_UDP otUdpSocket *GetUdpSockets(void) { return mSockets; } diff --git a/src/core/thread/key_manager.cpp b/src/core/thread/key_manager.cpp index 2530fc946..6ca11e4ae 100644 --- a/src/core/thread/key_manager.cpp +++ b/src/core/thread/key_manager.cpp @@ -159,7 +159,7 @@ exit: return error; } -otError KeyManager::ComputeKey(uint32_t aKeySequence, uint8_t *aKey) +void KeyManager::ComputeKey(uint32_t aKeySequence, uint8_t *aKey) { Crypto::HmacSha256 hmac; uint8_t keySequenceBytes[4]; @@ -174,8 +174,6 @@ otError KeyManager::ComputeKey(uint32_t aKeySequence, uint8_t *aKey) hmac.Update(kThreadString, sizeof(kThreadString)); hmac.Finish(aKey); - - return OT_ERROR_NONE; } void KeyManager::SetCurrentKeySequence(uint32_t aKeySequence) diff --git a/src/core/thread/key_manager.hpp b/src/core/thread/key_manager.hpp index 660f5296f..27107615e 100644 --- a/src/core/thread/key_manager.hpp +++ b/src/core/thread/key_manager.hpp @@ -335,7 +335,7 @@ private: kOneHourIntervalInMsec = 3600u * 1000u, }; - otError ComputeKey(uint32_t aKeySequence, uint8_t *aKey); + void ComputeKey(uint32_t aKeySequence, uint8_t *aKey); void StartKeyRotationTimer(void); static void HandleKeyRotationTimer(Timer &aTimer); diff --git a/src/core/thread/lowpan.cpp b/src/core/thread/lowpan.cpp index 531b320ae..eeb94377f 100644 --- a/src/core/thread/lowpan.cpp +++ b/src/core/thread/lowpan.cpp @@ -53,7 +53,7 @@ Lowpan::Lowpan(Instance &aInstance) { } -otError Lowpan::CopyContext(const Context &aContext, Ip6::Address &aAddress) +void Lowpan::CopyContext(const Context &aContext, Ip6::Address &aAddress) { memcpy(&aAddress, aContext.mPrefix, aContext.mPrefixLength / CHAR_BIT); @@ -62,8 +62,6 @@ otError Lowpan::CopyContext(const Context &aContext, Ip6::Address &aAddress) aAddress.mFields.m8[i / CHAR_BIT] &= ~(0x80 >> (i % CHAR_BIT)); aAddress.mFields.m8[i / CHAR_BIT] |= aContext.mPrefix[i / CHAR_BIT] & (0x80 >> (i % CHAR_BIT)); } - - return OT_ERROR_NONE; } otError Lowpan::ComputeIid(const Mac::Address &aMacAddr, const Context &aContext, Ip6::Address &aIpAddress) diff --git a/src/core/thread/lowpan.hpp b/src/core/thread/lowpan.hpp index ce988eb19..78c3e3c1d 100644 --- a/src/core/thread/lowpan.hpp +++ b/src/core/thread/lowpan.hpp @@ -234,7 +234,7 @@ private: int DecompressUdpHeader(Message &aMessage, const uint8_t *aBuf, uint16_t aBufLength, uint16_t aDatagramLength); otError DispatchToNextHeader(uint8_t aDispatch, Ip6::IpProto &aNextHeader); - static otError CopyContext(const Context &aContext, Ip6::Address &aAddress); + static void CopyContext(const Context &aContext, Ip6::Address &aAddress); static otError ComputeIid(const Mac::Address &aMacAddr, const Context &aContext, Ip6::Address &aIpAddress); }; diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 8c8d60506..d34d713ea 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -411,7 +411,7 @@ void MeshForwarder::SetRxOnWhenIdle(bool aRxOnWhenIdle) } } -otError MeshForwarder::GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr) +void MeshForwarder::GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr) { ThreadNetif &netif = GetNetif(); @@ -421,11 +421,9 @@ otError MeshForwarder::GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Ad { aMacAddr.SetShort(netif.GetMac().GetShortAddress()); } - - return OT_ERROR_NONE; } -otError MeshForwarder::GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr) +void MeshForwarder::GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr) { if (aIp6Addr.IsMulticast()) { @@ -446,8 +444,6 @@ otError MeshForwarder::GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Ma { aIp6Addr.ToExtAddress(aMacAddr); } - - return OT_ERROR_NONE; } otError MeshForwarder::GetMeshHeader(const uint8_t *&aFrame, uint8_t &aFrameLength, Lowpan::MeshHeader &aMeshHeader) @@ -586,17 +582,17 @@ otError MeshForwarder::HandleFrameRequest(Mac::Frame &aFrame) break; case Message::kTypeMacDataPoll: - error = SendPoll(*mSendMessage, aFrame); + SendPoll(*mSendMessage, aFrame); break; #if OPENTHREAD_FTD case Message::kType6lowpan: - error = SendMesh(*mSendMessage, aFrame); + SendMesh(*mSendMessage, aFrame); break; case Message::kTypeSupervision: - error = SendEmptyFrame(aFrame, kSupervisionMsgAckRequest); + SendEmptyFrame(aFrame, kSupervisionMsgAckRequest); mMessageNextOffset = mSendMessage->GetLength(); break; @@ -651,7 +647,7 @@ exit: return error; } -otError MeshForwarder::SendPoll(Message &aMessage, Mac::Frame &aFrame) +void MeshForwarder::SendPoll(Message &aMessage, Mac::Frame &aFrame) { ThreadNetif &netif = GetNetif(); uint16_t fcf; @@ -677,8 +673,6 @@ otError MeshForwarder::SendPoll(Message &aMessage, Mac::Frame &aFrame) aFrame.SetCommandId(Mac::Frame::kMacCmdDataRequest); mMessageNextOffset = aMessage.GetLength(); - - return OT_ERROR_NONE; } otError MeshForwarder::SendFragment(Message &aMessage, Mac::Frame &aFrame) @@ -968,7 +962,7 @@ exit: return error; } -otError MeshForwarder::SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest) +void MeshForwarder::SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest) { ThreadNetif &netif = GetNetif(); uint16_t fcf; @@ -1005,8 +999,6 @@ otError MeshForwarder::SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest) aFrame.SetSrcAddr(macSource); aFrame.SetPayloadLength(0); aFrame.SetFramePending(false); - - return OT_ERROR_NONE; } void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, otError aError) diff --git a/src/core/thread/mesh_forwarder.hpp b/src/core/thread/mesh_forwarder.hpp index cb3d6b055..cb60acc82 100644 --- a/src/core/thread/mesh_forwarder.hpp +++ b/src/core/thread/mesh_forwarder.hpp @@ -391,8 +391,8 @@ private: const Mac::Address &aMacSource, const Mac::Address &aMacDest, Ip6::Header & aIp6Header); - otError GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr); - otError GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr); + void GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr); + void GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr); Message *GetDirectTransmission(void); otError GetIndirectTransmission(void); Message *GetIndirectTransmission(Child &aChild); @@ -419,10 +419,10 @@ private: uint8_t aFrameLength, Lowpan::FragmentHeader &aFragmentHeader); - otError SendPoll(Message &aMessage, Mac::Frame &aFrame); - otError SendMesh(Message &aMessage, Mac::Frame &aFrame); + void SendPoll(Message &aMessage, Mac::Frame &aFrame); + void SendMesh(Message &aMessage, Mac::Frame &aFrame); otError SendFragment(Message &aMessage, Mac::Frame &aFrame); - otError SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest); + void SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest); otError UpdateIp6Route(Message &aMessage); otError UpdateIp6RouteFtd(Ip6::Header &ip6Header); otError UpdateMeshRoute(Message &aMessage); diff --git a/src/core/thread/mesh_forwarder_ftd.cpp b/src/core/thread/mesh_forwarder_ftd.cpp index 6eda583ba..95d9ba679 100644 --- a/src/core/thread/mesh_forwarder_ftd.cpp +++ b/src/core/thread/mesh_forwarder_ftd.cpp @@ -529,7 +529,7 @@ void MeshForwarder::PrepareIndirectTransmission(Message &aMessage, const Child & } } -otError MeshForwarder::SendMesh(Message &aMessage, Mac::Frame &aFrame) +void MeshForwarder::SendMesh(Message &aMessage, Mac::Frame &aFrame) { ThreadNetif &netif = GetNetif(); uint16_t fcf; @@ -550,8 +550,6 @@ otError MeshForwarder::SendMesh(Message &aMessage, Mac::Frame &aFrame) aFrame.SetPayloadLength(static_cast(aMessage.GetLength())); mMessageNextOffset = aMessage.GetLength(); - - return OT_ERROR_NONE; } void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const otThreadLinkInfo &aLinkInfo) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index e968553c5..9ef17306e 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -228,7 +228,7 @@ otError Mle::Disable(void) { otError error = OT_ERROR_NONE; - SuccessOrExit(error = Stop(false)); + Stop(false); SuccessOrExit(error = mSocket.Close()); SuccessOrExit(error = GetNetif().RemoveUnicastAddress(mLinkLocal64)); @@ -280,7 +280,7 @@ exit: return error; } -otError Mle::Stop(bool aClearNetworkDatasets) +void Mle::Stop(bool aClearNetworkDatasets) { ThreadNetif &netif = GetNetif(); @@ -302,7 +302,7 @@ otError Mle::Stop(bool aClearNetworkDatasets) SetRole(OT_DEVICE_ROLE_DISABLED); exit: - return OT_ERROR_NONE; + return; } void Mle::SetRole(otDeviceRole aRole) @@ -784,7 +784,7 @@ exit: return; } -otError Mle::SetTimeout(uint32_t aTimeout) +void Mle::SetTimeout(uint32_t aTimeout) { VerifyOrExit(mTimeout != aTimeout); @@ -803,7 +803,7 @@ otError Mle::SetTimeout(uint32_t aTimeout) } exit: - return OT_ERROR_NONE; + return; } otError Mle::SetDeviceMode(uint8_t aDeviceMode) @@ -853,7 +853,7 @@ exit: return error; } -otError Mle::UpdateLinkLocalAddress(void) +void Mle::UpdateLinkLocalAddress(void) { ThreadNetif &netif = GetNetif(); @@ -862,8 +862,6 @@ otError Mle::UpdateLinkLocalAddress(void) netif.AddUnicastAddress(mLinkLocal64); GetNotifier().Signal(OT_CHANGED_THREAD_LL_ADDR); - - return OT_ERROR_NONE; } void Mle::SetMeshLocalPrefix(const otMeshLocalPrefix &aMeshLocalPrefix) @@ -951,7 +949,7 @@ uint16_t Mle::GetRloc16(void) const return GetNetif().GetMac().GetShortAddress(); } -otError Mle::SetRloc16(uint16_t aRloc16) +void Mle::SetRloc16(uint16_t aRloc16) { ThreadNetif &netif = GetNetif(); @@ -966,8 +964,6 @@ otError Mle::SetRloc16(uint16_t aRloc16) netif.GetMac().SetShortAddress(aRloc16); netif.GetIp6().GetMpl().SetSeedId(aRloc16); - - return OT_ERROR_NONE; } void Mle::SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLeaderRouterId) diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 025b41981..094b2a19b 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -509,10 +509,8 @@ public: * * @param[in] aClearNetworkDatasets True to clear network datasets, False not. * - * @retval OT_ERROR_NONE Successfully stopped the protocol operation. - * */ - otError Stop(bool aClearNetworkDatasets); + void Stop(bool aClearNetworkDatasets); /** * This method restores network information from non-volatile memory. @@ -730,10 +728,8 @@ public: * * Call this method when the IEEE 802.15.4 Extended Address has changed. * - * @retval OT_ERROR_NONE Successfully updated the link local address. - * */ - otError UpdateLinkLocalAddress(void); + void UpdateLinkLocalAddress(void); /** * This method returns a reference to the link-local all Thread nodes multicast address. @@ -814,7 +810,7 @@ public: * @param[in] aTimeout The Timeout value in seconds. * */ - otError SetTimeout(uint32_t aTimeout); + void SetTimeout(uint32_t aTimeout); /** * This method returns the RLOC16 assigned to the Thread interface. @@ -1512,10 +1508,8 @@ protected: * * @param[in] aRloc16 The RLOC16 to set. * - * @retval OT_ERROR_NONE Successfully set the RLOC16. - * */ - otError SetRloc16(uint16_t aRloc16); + void SetRloc16(uint16_t aRloc16); /** * This method sets the Device State to Detached. diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 52bc2b168..eee2cffd5 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -194,7 +194,7 @@ otError MleRouter::BecomeLeader(void) netif.GetNetworkDataLeader().Reset(); netif.GetLeader().SetEmptyCommissionerData(); - SuccessOrExit(error = SetStateLeader(GetRloc16(leaderId))); + SetStateLeader(GetRloc16(leaderId)); exit: return error; @@ -213,13 +213,11 @@ void MleRouter::StopLeader(void) netif.UnsubscribeAllRoutersMulticast(); } -otError MleRouter::HandleDetachStart(void) +void MleRouter::HandleDetachStart(void) { mRouterTable.ClearNeighbors(); StopLeader(); mStateUpdateTimer.Stop(); - - return OT_ERROR_NONE; } otError MleRouter::HandleChildStart(AttachMode aMode) @@ -301,7 +299,7 @@ exit: return error; } -otError MleRouter::SetStateRouter(uint16_t aRloc16) +void MleRouter::SetStateRouter(uint16_t aRloc16) { ThreadNetif &netif = GetNetif(); @@ -330,11 +328,9 @@ otError MleRouter::SetStateRouter(uint16_t aRloc16) RemoveNeighbor(*iter.GetChild()); } } - - return OT_ERROR_NONE; } -otError MleRouter::SetStateLeader(uint16_t aRloc16) +void MleRouter::SetStateLeader(uint16_t aRloc16) { ThreadNetif &netif = GetNetif(); @@ -373,8 +369,6 @@ otError MleRouter::SetStateLeader(uint16_t aRloc16) } otLogNoteMle("Leader partition id 0x%x", mLeaderData.GetPartitionId()); - - return OT_ERROR_NONE; } bool MleRouter::HandleAdvertiseTimer(TrickleTimer &aTimer) @@ -1675,7 +1669,7 @@ otError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::Messa child->SetTimeout(TimerMilli::MsecToSec(kMaxChildIdRequestTimeout)); } - SuccessOrExit(error = SendParentResponse(child, challenge, !scanMask.IsEndDeviceFlagSet())); + SendParentResponse(child, challenge, !scanMask.IsEndDeviceFlagSet()); exit: return error; @@ -1897,7 +1891,7 @@ exit: return; } -otError MleRouter::SendParentResponse(Child *aChild, const ChallengeTlv &aChallenge, bool aRoutersOnlyRequest) +void MleRouter::SendParentResponse(Child *aChild, const ChallengeTlv &aChallenge, bool aRoutersOnlyRequest) { otError error = OT_ERROR_NONE; Ip6::Address destination; @@ -1952,8 +1946,6 @@ exit: { message->Free(); } - - return OT_ERROR_NONE; } otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffset, Child &aChild) @@ -2540,7 +2532,7 @@ exit: return error; } -otError MleRouter::HandleNetworkDataUpdateRouter(void) +void MleRouter::HandleNetworkDataUpdateRouter(void) { static const uint8_t tlvs[] = {Tlv::kNetworkData}; Ip6::Address destination; @@ -2558,7 +2550,7 @@ otError MleRouter::HandleNetworkDataUpdateRouter(void) SynchronizeChildNetworkData(); exit: - return OT_ERROR_NONE; + return; } void MleRouter::SynchronizeChildNetworkData(void) @@ -2979,11 +2971,11 @@ exit: return error; } -otError MleRouter::SendChildUpdateResponse(Child * aChild, - const Ip6::MessageInfo &aMessageInfo, - const uint8_t * aTlvs, - uint8_t aTlvslength, - const ChallengeTlv * aChallenge) +void MleRouter::SendChildUpdateResponse(Child * aChild, + const Ip6::MessageInfo &aMessageInfo, + const uint8_t * aTlvs, + uint8_t aTlvslength, + const ChallengeTlv * aChallenge) { otError error = OT_ERROR_NONE; Message *message; @@ -3056,8 +3048,6 @@ exit: { message->Free(); } - - return OT_ERROR_NONE; } otError MleRouter::SendDataResponse(const Ip6::Address &aDestination, @@ -3154,13 +3144,13 @@ otError MleRouter::RemoveNeighbor(const Mac::Address &aAddress) Neighbor *neighbor; VerifyOrExit((neighbor = GetNeighbor(aAddress)) != NULL, error = OT_ERROR_NOT_FOUND); - SuccessOrExit(error = RemoveNeighbor(*neighbor)); + RemoveNeighbor(*neighbor); exit: return error; } -otError MleRouter::RemoveNeighbor(Neighbor &aNeighbor) +void MleRouter::RemoveNeighbor(Neighbor &aNeighbor) { ThreadNetif &netif = GetNetif(); @@ -3210,8 +3200,6 @@ otError MleRouter::RemoveNeighbor(Neighbor &aNeighbor) aNeighbor.GetLinkInfo().Clear(); aNeighbor.SetState(Neighbor::kStateInvalid); - - return OT_ERROR_NONE; } Neighbor *MleRouter::GetNeighbor(uint16_t aAddress) @@ -3980,7 +3968,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage, // assign short address SetRouterId(routerId); - SuccessOrExit(SetStateRouter(GetRloc16(mRouterId))); + SetStateRouter(GetRloc16(mRouterId)); mRouterTable.Clear(); mRouterTable.ProcessTlv(routerMaskTlv); @@ -4706,13 +4694,11 @@ bool MleRouter::IsSleepyChildSubscribed(const Ip6::Address &aAddress, Child &aCh } #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC -otError MleRouter::HandleTimeSync(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) +void MleRouter::HandleTimeSync(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { LogMleMessage("Receive Time Sync", aMessageInfo.GetPeerAddr()); GetNetif().GetTimeSync().HandleTimeSyncMessage(aMessage); - - return OT_ERROR_NONE; } otError MleRouter::SendTimeSync(void) diff --git a/src/core/thread/mle_router_ftd.hpp b/src/core/thread/mle_router_ftd.hpp index 41bbe4cf6..87d6f95bd 100644 --- a/src/core/thread/mle_router_ftd.hpp +++ b/src/core/thread/mle_router_ftd.hpp @@ -331,10 +331,8 @@ public: * * @param[in] aNeighbor A reference to the neighbor object. * - * @retval OT_ERROR_NONE Successfully removed the neighbor. - * */ - otError RemoveNeighbor(Neighbor &aNeighbor); + void RemoveNeighbor(Neighbor &aNeighbor); /** * This method gets the `ChildTable` object. @@ -695,7 +693,7 @@ private: otError AppendPendingDataset(Message &aMessage); otError GetChildInfo(Child &aChild, otChildInfo &aChildInfo); otError RefreshStoredChildren(void); - otError HandleDetachStart(void); + void HandleDetachStart(void); otError HandleChildStart(AttachMode aMode); otError HandleLinkRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); otError HandleLinkAccept(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo, uint32_t aKeySequence); @@ -716,10 +714,10 @@ private: const Ip6::MessageInfo &aMessageInfo, uint32_t aKeySequence); otError HandleDataRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); - otError HandleNetworkDataUpdateRouter(void); + void HandleNetworkDataUpdateRouter(void); otError HandleDiscoveryRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC - otError HandleTimeSync(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); + void HandleTimeSync(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); #endif otError ProcessRouteTlv(const RouteTlv &aRoute); @@ -734,10 +732,10 @@ private: Neighbor * aNeighbor, const TlvRequestTlv & aTlvRequest, const ChallengeTlv & aChallenge); - otError SendParentResponse(Child *aChild, const ChallengeTlv &aChallenge, bool aRoutersOnlyRequest); + void SendParentResponse(Child *aChild, const ChallengeTlv &aChallenge, bool aRoutersOnlyRequest); otError SendChildIdResponse(Child &aChild); otError SendChildUpdateRequest(Child &aChild); - otError SendChildUpdateResponse(Child * aChild, + void SendChildUpdateResponse(Child * aChild, const Ip6::MessageInfo &aMessageInfo, const uint8_t * aTlvs, uint8_t aTlvsLength, @@ -748,8 +746,8 @@ private: uint16_t aDelay); otError SendDiscoveryResponse(const Ip6::Address &aDestination, uint16_t aPanId); - otError SetStateRouter(uint16_t aRloc16); - otError SetStateLeader(uint16_t aRloc16); + void SetStateRouter(uint16_t aRloc16); + void SetStateLeader(uint16_t aRloc16); void StopLeader(void); void SynchronizeChildNetworkData(void); otError UpdateChildAddresses(const Message &aMessage, uint16_t aOffset, Child &aChild); diff --git a/src/core/thread/mle_router_mtd.hpp b/src/core/thread/mle_router_mtd.hpp index fc53e6057..450bb6ad6 100644 --- a/src/core/thread/mle_router_mtd.hpp +++ b/src/core/thread/mle_router_mtd.hpp @@ -130,7 +130,7 @@ public: bool IsSleepyChildSubscribed(const Ip6::Address &, Child &) { return false; } private: - otError HandleDetachStart(void) { return OT_ERROR_NONE; } + void HandleDetachStart(void) {} otError HandleChildStart(AttachMode) { return OT_ERROR_NONE; } otError HandleLinkRequest(const Message &, const Ip6::MessageInfo &) { return OT_ERROR_DROP; } otError HandleLinkAccept(const Message &, const Ip6::MessageInfo &, uint32_t) { return OT_ERROR_DROP; } @@ -142,7 +142,7 @@ private: otError HandleChildUpdateRequest(const Message &, const Ip6::MessageInfo &, uint32_t) { return OT_ERROR_DROP; } otError HandleChildUpdateResponse(const Message &, const Ip6::MessageInfo &, uint32_t) { return OT_ERROR_DROP; } otError HandleDataRequest(const Message &, const Ip6::MessageInfo &) { return OT_ERROR_DROP; } - otError HandleNetworkDataUpdateRouter(void) { return OT_ERROR_NONE; } + void HandleNetworkDataUpdateRouter(void) {} otError HandleDiscoveryRequest(const Message &, const Ip6::MessageInfo &) { return OT_ERROR_DROP; } void HandlePartitionChange(void) {} void StopAdvertiseTimer(void) {} diff --git a/src/core/thread/network_data.cpp b/src/core/thread/network_data.cpp index 04d964638..9f6fc2846 100644 --- a/src/core/thread/network_data.cpp +++ b/src/core/thread/network_data.cpp @@ -979,20 +979,18 @@ exit: } #endif -otError NetworkData::Insert(uint8_t *aStart, uint8_t aLength) +void NetworkData::Insert(uint8_t *aStart, uint8_t aLength) { assert(aLength + mLength <= sizeof(mTlvs) && mTlvs <= aStart && aStart <= mTlvs + mLength); memmove(aStart + aLength, aStart, mLength - static_cast(aStart - mTlvs)); mLength += aLength; - return OT_ERROR_NONE; } -otError NetworkData::Remove(uint8_t *aStart, uint8_t aLength) +void NetworkData::Remove(uint8_t *aStart, uint8_t aLength) { assert(aLength <= mLength && mTlvs <= aStart && (aStart - mTlvs) + aLength <= mLength); memmove(aStart, aStart + aLength, mLength - (static_cast(aStart - mTlvs) + aLength)); mLength -= aLength; - return OT_ERROR_NONE; } otError NetworkData::SendServerDataNotification(uint16_t aRloc16) diff --git a/src/core/thread/network_data.hpp b/src/core/thread/network_data.hpp index bdd553b90..78ea5590b 100644 --- a/src/core/thread/network_data.hpp +++ b/src/core/thread/network_data.hpp @@ -399,11 +399,8 @@ protected: * @param[in] aStart A pointer to the beginning of the insertion. * @param[in] aLength The number of bytes to insert. * - * @retval OT_ERROR_NONE Successfully inserted bytes. - * @retval OT_ERROR_NO_BUFS Insufficient buffer space to insert bytes. - * */ - otError Insert(uint8_t *aStart, uint8_t aLength); + void Insert(uint8_t *aStart, uint8_t aLength); /** * This method removes bytes from the Network Data. @@ -411,10 +408,8 @@ protected: * @param[in] aStart A pointer to the beginning of the removal. * @param[in] aLength The number of bytes to remove. * - * @retval OT_ERROR_NONE Successfully removed bytes. - * */ - otError Remove(uint8_t *aStart, uint8_t aLength); + void Remove(uint8_t *aStart, uint8_t aLength); /** * This method strips non-stable data from the Thread Network Data. diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index 1d8a389d1..66cd91f7b 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -120,10 +120,9 @@ uint32_t Leader::GetContextIdReuseDelay(void) const return mContextIdReuseDelay; } -otError Leader::SetContextIdReuseDelay(uint32_t aDelay) +void Leader::SetContextIdReuseDelay(uint32_t aDelay) { mContextIdReuseDelay = aDelay; - return OT_ERROR_NONE; } void Leader::RemoveBorderRouter(uint16_t aRloc16, MatchMode aMatchMode) @@ -772,7 +771,7 @@ otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aT // Store old Service IDs for given rloc16, so updates to server will reuse the same Service ID SuccessOrExit(error = GetNetworkData(false, oldTlvs, oldTlvsLength)); - SuccessOrExit(error = RemoveRloc(aRloc16, kMatchModeRloc16)); + RemoveRloc(aRloc16, kMatchModeRloc16); SuccessOrExit(error = AddNetworkData(aTlvs, aTlvsLength, oldTlvs, oldTlvsLength)); mVersion++; @@ -1197,7 +1196,7 @@ exit: return rval; } -otError Leader::FreeContext(uint8_t aContextId) +void Leader::FreeContext(uint8_t aContextId) { otLogInfoNetData("Free Context Id = %d", aContextId); RemoveContext(aContextId); @@ -1205,7 +1204,6 @@ otError Leader::FreeContext(uint8_t aContextId) mVersion++; mStableVersion++; GetNotifier().Signal(OT_CHANGED_THREAD_NETDATA); - return OT_ERROR_NONE; } void Leader::StartContextReuseTimer(uint8_t aContextId) @@ -1241,7 +1239,7 @@ exit: return error; } -otError Leader::RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode) +void Leader::RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode) { NetworkDataTlv *cur = reinterpret_cast(mTlvs); NetworkDataTlv *end; @@ -1304,11 +1302,9 @@ otError Leader::RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode) } otDumpDebgNetData("remove done", mTlvs, mLength); - - return OT_ERROR_NONE; } -otError Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMode) +void Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatchMode) { NetworkDataTlv *cur = prefix.GetSubTlvs(); NetworkDataTlv *end; @@ -1371,12 +1367,10 @@ otError Leader::RemoveRloc(PrefixTlv &prefix, uint16_t aRloc16, MatchMode aMatch StopContextReuseTimer(context->GetContextId()); } } - - return OT_ERROR_NONE; } #if OPENTHREAD_ENABLE_SERVICE -otError Leader::RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode) +void Leader::RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode) { NetworkDataTlv *cur = service.GetSubTlvs(); NetworkDataTlv *end; @@ -1413,12 +1407,10 @@ otError Leader::RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMat cur = cur->GetNext(); } - - return OT_ERROR_NONE; } #endif -otError Leader::RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t aRloc16, MatchMode aMatchMode) +void Leader::RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t aRloc16, MatchMode aMatchMode) { HasRouteEntry *entry = aHasRoute.GetFirstEntry(); @@ -1434,11 +1426,9 @@ otError Leader::RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t entry = entry->GetNext(); } - - return OT_ERROR_NONE; } -otError Leader::RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16, MatchMode aMatchMode) +void Leader::RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16, MatchMode aMatchMode) { BorderRouterEntry *entry = aBorderRouter.GetFirstEntry(); @@ -1454,11 +1444,9 @@ otError Leader::RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, u entry = entry->GetNext(); } - - return OT_ERROR_NONE; } -otError Leader::RemoveContext(uint8_t aContextId) +void Leader::RemoveContext(uint8_t aContextId) { NetworkDataTlv *cur = reinterpret_cast(mTlvs); NetworkDataTlv *end; @@ -1498,11 +1486,9 @@ otError Leader::RemoveContext(uint8_t aContextId) } otDumpDebgNetData("remove done", mTlvs, mLength); - - return OT_ERROR_NONE; } -otError Leader::RemoveContext(PrefixTlv &aPrefix, uint8_t aContextId) +void Leader::RemoveContext(PrefixTlv &aPrefix, uint8_t aContextId) { NetworkDataTlv *cur = aPrefix.GetSubTlvs(); NetworkDataTlv *end; @@ -1542,8 +1528,6 @@ otError Leader::RemoveContext(PrefixTlv &aPrefix, uint8_t aContextId) cur = cur->GetNext(); } - - return OT_ERROR_NONE; } void Leader::UpdateContextsAfterReset(void) diff --git a/src/core/thread/network_data_leader_ftd.hpp b/src/core/thread/network_data_leader_ftd.hpp index bcf0b0d02..3bca1813e 100644 --- a/src/core/thread/network_data_leader_ftd.hpp +++ b/src/core/thread/network_data_leader_ftd.hpp @@ -129,7 +129,7 @@ public: * @param[in] aDelay The CONTEXT_ID_REUSE_DELAY value. * */ - otError SetContextIdReuseDelay(uint32_t aDelay); + void SetContextIdReuseDelay(uint32_t aDelay); /** * This method removes Network Data entries matching with a given RLOC16. @@ -188,23 +188,23 @@ private: otError AddService(ServiceTlv &aTlv, uint8_t *aOldTlvs, uint8_t aOldTlvsLength); #endif - int AllocateContext(void); - otError FreeContext(uint8_t aContextId); - void StartContextReuseTimer(uint8_t aContextId); - void StopContextReuseTimer(uint8_t aContextId); + int AllocateContext(void); + void FreeContext(uint8_t aContextId); + void StartContextReuseTimer(uint8_t aContextId); + void StopContextReuseTimer(uint8_t aContextId); - otError RemoveContext(uint8_t aContextId); - otError RemoveContext(PrefixTlv &aPrefix, uint8_t aContextId); + void RemoveContext(uint8_t aContextId); + void RemoveContext(PrefixTlv &aPrefix, uint8_t aContextId); - otError RemoveCommissioningData(void); + void RemoveCommissioningData(void); - otError RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode); - otError RemoveRloc(PrefixTlv &aPrefix, uint16_t aRloc16, MatchMode aMatchMode); + void RemoveRloc(uint16_t aRloc16, MatchMode aMatchMode); + void RemoveRloc(PrefixTlv &aPrefix, uint16_t aRloc16, MatchMode aMatchMode); #if OPENTHREAD_ENABLE_SERVICE - otError RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode); + void RemoveRloc(ServiceTlv &service, uint16_t aRloc16, MatchMode aMatchMode); #endif - otError RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t aRloc16, MatchMode aMatchMode); - otError RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16, MatchMode aMatchMode); + void RemoveRloc(PrefixTlv &aPrefix, HasRouteTlv &aHasRoute, uint16_t aRloc16, MatchMode aMatchMode); + void RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16, MatchMode aMatchMode); static bool RlocMatch(uint16_t aFirstRloc16, uint16_t aSecondRloc16, MatchMode aMatchMode); diff --git a/src/core/thread/network_data_local.cpp b/src/core/thread/network_data_local.cpp index 61588e389..a6477dd44 100644 --- a/src/core/thread/network_data_local.cpp +++ b/src/core/thread/network_data_local.cpp @@ -241,7 +241,7 @@ exit: } #endif -otError Local::UpdateRloc(void) +void Local::UpdateRloc(void) { for (NetworkDataTlv *cur = reinterpret_cast(mTlvs); cur < reinterpret_cast(mTlvs + mLength); cur = cur->GetNext()) @@ -266,11 +266,9 @@ otError Local::UpdateRloc(void) } ClearResubmitDelayTimer(); - - return OT_ERROR_NONE; } -otError Local::UpdateRloc(PrefixTlv &aPrefix) +void Local::UpdateRloc(PrefixTlv &aPrefix) { for (NetworkDataTlv *cur = aPrefix.GetSubTlvs(); cur < aPrefix.GetNext(); cur = cur->GetNext()) { @@ -289,26 +287,22 @@ otError Local::UpdateRloc(PrefixTlv &aPrefix) break; } } - - return OT_ERROR_NONE; } -otError Local::UpdateRloc(HasRouteTlv &aHasRoute) +void Local::UpdateRloc(HasRouteTlv &aHasRoute) { HasRouteEntry *entry = aHasRoute.GetEntry(0); entry->SetRloc(GetNetif().GetMle().GetRloc16()); - return OT_ERROR_NONE; } -otError Local::UpdateRloc(BorderRouterTlv &aBorderRouter) +void Local::UpdateRloc(BorderRouterTlv &aBorderRouter) { BorderRouterEntry *entry = aBorderRouter.GetEntry(0); entry->SetRloc(GetNetif().GetMle().GetRloc16()); - return OT_ERROR_NONE; } #if OPENTHREAD_ENABLE_SERVICE -otError Local::UpdateRloc(ServiceTlv &aService) +void Local::UpdateRloc(ServiceTlv &aService) { for (NetworkDataTlv *cur = aService.GetSubTlvs(); cur < aService.GetNext(); cur = cur->GetNext()) { @@ -323,14 +317,11 @@ otError Local::UpdateRloc(ServiceTlv &aService) break; } } - - return OT_ERROR_NONE; } -otError Local::UpdateRloc(ServerTlv &aServer) +void Local::UpdateRloc(ServerTlv &aServer) { aServer.SetServer16(GetNetif().GetMle().GetRloc16()); - return OT_ERROR_NONE; } #endif diff --git a/src/core/thread/network_data_local.hpp b/src/core/thread/network_data_local.hpp index b7529ee6b..5a71f7fe4 100644 --- a/src/core/thread/network_data_local.hpp +++ b/src/core/thread/network_data_local.hpp @@ -166,13 +166,13 @@ public: otError SendServerDataNotification(void); private: - otError UpdateRloc(void); - otError UpdateRloc(PrefixTlv &aPrefix); - otError UpdateRloc(HasRouteTlv &aHasRoute); - otError UpdateRloc(BorderRouterTlv &aBorderRouter); + void UpdateRloc(void); + void UpdateRloc(PrefixTlv &aPrefix); + void UpdateRloc(HasRouteTlv &aHasRoute); + void UpdateRloc(BorderRouterTlv &aBorderRouter); #if OPENTHREAD_ENABLE_SERVICE - otError UpdateRloc(ServiceTlv &aService); - otError UpdateRloc(ServerTlv &aService); + void UpdateRloc(ServiceTlv &aService); + void UpdateRloc(ServerTlv &aService); #endif bool IsOnMeshPrefixConsistent(void); diff --git a/src/core/utils/jam_detector.cpp b/src/core/utils/jam_detector.cpp index 3a6e8a8d2..31a9571d6 100644 --- a/src/core/utils/jam_detector.cpp +++ b/src/core/utils/jam_detector.cpp @@ -127,12 +127,10 @@ exit: return; } -otError JamDetector::SetRssiThreshold(int8_t aThreshold) +void JamDetector::SetRssiThreshold(int8_t aThreshold) { mRssiThreshold = aThreshold; otLogInfoUtil("JamDetector - RSSI threshold set to %d", mRssiThreshold); - - return OT_ERROR_NONE; } otError JamDetector::SetWindow(uint8_t aWindow) diff --git a/src/core/utils/jam_detector.hpp b/src/core/utils/jam_detector.hpp index 593651737..6e675c584 100644 --- a/src/core/utils/jam_detector.hpp +++ b/src/core/utils/jam_detector.hpp @@ -107,10 +107,8 @@ public: * * @param[in] aRssiThreshold The RSSI threshold. * - * @retval OT_ERROR_NONE Successfully set the threshold. - * */ - otError SetRssiThreshold(int8_t aThreshold); + void SetRssiThreshold(int8_t aThreshold); /** * Get the Jam Detection RSSI Threshold (in dBm). diff --git a/src/ncp/ncp_buffer.cpp b/src/ncp/ncp_buffer.cpp index 764562019..911c93497 100644 --- a/src/ncp/ncp_buffer.cpp +++ b/src/ncp/ncp_buffer.cpp @@ -327,7 +327,7 @@ bool NcpFrameBuffer::InFrameIsWriting(Priority aPriority) const return (mWriteDirection == static_cast(aPriority)); } -otError NcpFrameBuffer::InFrameBegin(Priority aPriority) +void NcpFrameBuffer::InFrameBegin(Priority aPriority) { // Discard any previous unfinished frame. InFrameDiscard(); @@ -345,8 +345,6 @@ otError NcpFrameBuffer::InFrameBegin(Priority aPriority) // Set up the segment head and tail mWriteSegmentHead = mWriteSegmentTail = mWriteFrameStart[mWriteDirection]; - - return OT_ERROR_NONE; } otError NcpFrameBuffer::InFrameFeedByte(uint8_t aByte) diff --git a/src/ncp/ncp_buffer.hpp b/src/ncp/ncp_buffer.hpp index 8ae19309e..b4aef8dfa 100644 --- a/src/ncp/ncp_buffer.hpp +++ b/src/ncp/ncp_buffer.hpp @@ -161,11 +161,8 @@ public: * * @param[in] aPriority Priority level of the new input frame. * - * @retval OT_ERROR_NONE Successfully started a new frame. - * @retval OT_ERROR_NO_BUFS Insufficient buffer space available to start a new frame. - * */ - otError InFrameBegin(Priority aPriority); + void InFrameBegin(Priority aPriority); /** * This method adds a single byte to current input frame. diff --git a/src/ncp/spinel_encoder.cpp b/src/ncp/spinel_encoder.cpp index 7d5ff90e1..91ab7c3d4 100644 --- a/src/ncp/spinel_encoder.cpp +++ b/src/ncp/spinel_encoder.cpp @@ -40,7 +40,8 @@ namespace Ncp { otError SpinelEncoder::BeginFrame(NcpFrameBuffer::Priority aPriority) { mNumOpenStructs = 0; - return mNcpBuffer.InFrameBegin(aPriority); + mNcpBuffer.InFrameBegin(aPriority); + return OT_ERROR_NONE; } otError SpinelEncoder::BeginFrame(uint8_t aHeader, unsigned int aCommand) diff --git a/tests/unit/test_ncp_buffer.cpp b/tests/unit/test_ncp_buffer.cpp index 28b494362..3ab6e8230 100644 --- a/tests/unit/test_ncp_buffer.cpp +++ b/tests/unit/test_ncp_buffer.cpp @@ -222,7 +222,7 @@ void WriteTestFrame1(NcpFrameBuffer &aNcpBuffer, NcpFrameBuffer::Priority aPrior message->Write(0, sizeof(sMottoText), sMottoText); oldContext = sContext; - SuccessOrQuit(aNcpBuffer.InFrameBegin(aPriority), "InFrameBegin() failed."); + aNcpBuffer.InFrameBegin(aPriority); SuccessOrQuit(aNcpBuffer.InFrameFeedData(sMottoText, sizeof(sMottoText)), "InFrameFeedData() failed."); SuccessOrQuit(aNcpBuffer.InFrameFeedData(sMysteryText, sizeof(sMysteryText)), "InFrameFeedData() failed."); SuccessOrQuit(aNcpBuffer.InFrameFeedMessage(message), "InFrameFeedMessage() failed."); @@ -270,7 +270,7 @@ void WriteTestFrame2(NcpFrameBuffer &aNcpBuffer, NcpFrameBuffer::Priority aPrior SuccessOrQuit(message2->SetLength(sizeof(sHelloText)), "Could not set the length of message."); message2->Write(0, sizeof(sHelloText), sHelloText); - SuccessOrQuit(aNcpBuffer.InFrameBegin(aPriority), "InFrameFeedBegin() failed."); + aNcpBuffer.InFrameBegin(aPriority); SuccessOrQuit(aNcpBuffer.InFrameFeedMessage(message1), "InFrameFeedMessage() failed."); SuccessOrQuit(aNcpBuffer.InFrameFeedData(sOpenThreadText, sizeof(sOpenThreadText)), "InFrameFeedData() failed."); SuccessOrQuit(aNcpBuffer.InFrameFeedMessage(message2), "InFrameFeedMessage() failed."); @@ -311,7 +311,7 @@ void WriteTestFrame3(NcpFrameBuffer &aNcpBuffer, NcpFrameBuffer::Priority aPrior // An empty message with no content. SuccessOrQuit(message1->SetLength(0), "Could not set the length of message."); - SuccessOrQuit(aNcpBuffer.InFrameBegin(aPriority), "InFrameFeedBegin() failed."); + aNcpBuffer.InFrameBegin(aPriority); SuccessOrQuit(aNcpBuffer.InFrameFeedMessage(message1), "InFrameFeedMessage() failed."); SuccessOrQuit(aNcpBuffer.InFrameFeedData(sMysteryText, sizeof(sMysteryText)), "InFrameFeedData() failed."); SuccessOrQuit(aNcpBuffer.InFrameEnd(), "InFrameEnd() failed."); @@ -342,7 +342,7 @@ void WriteTestFrame4(NcpFrameBuffer &aNcpBuffer, NcpFrameBuffer::Priority aPrior { CallbackContext oldContext = sContext; - SuccessOrQuit(aNcpBuffer.InFrameBegin(aPriority), "InFrameFeedBegin() failed."); + aNcpBuffer.InFrameBegin(aPriority); SuccessOrQuit(aNcpBuffer.InFrameFeedData(sOpenThreadText, sizeof(sOpenThreadText)), "InFrameFeedData() failed."); SuccessOrQuit(aNcpBuffer.InFrameEnd(), "InFrameEnd() failed."); @@ -732,7 +732,7 @@ void TestNcpFrameBuffer(void) printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); printf("\n Test 11: Read and remove in middle of an active input frame write"); WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityLow); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh), "InFrameFeedBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh); SuccessOrQuit(ncpBuffer.InFrameFeedData(sOpenThreadText, sizeof(sOpenThreadText)), "InFrameFeedData() failed."); VerifyAndRemoveFrame1(ncpBuffer); VerifyOrQuit(ncpBuffer.IsEmpty() == true, "IsEmpty() failed."); @@ -740,7 +740,7 @@ void TestNcpFrameBuffer(void) VerifyAndRemoveFrame4(ncpBuffer); // Repeat the test reversing priorities WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityHigh); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityLow), "InFrameFeedBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityLow); SuccessOrQuit(ncpBuffer.InFrameFeedData(sOpenThreadText, sizeof(sOpenThreadText)), "InFrameFeedData() failed."); VerifyAndRemoveFrame1(ncpBuffer); VerifyOrQuit(ncpBuffer.IsEmpty() == true, "IsEmpty() failed."); @@ -748,7 +748,7 @@ void TestNcpFrameBuffer(void) VerifyAndRemoveFrame4(ncpBuffer); // Repeat the test with same priorities WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityHigh); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh), "InFrameFeedBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh); SuccessOrQuit(ncpBuffer.InFrameFeedData(sOpenThreadText, sizeof(sOpenThreadText)), "InFrameFeedData() failed."); VerifyAndRemoveFrame1(ncpBuffer); VerifyOrQuit(ncpBuffer.IsEmpty() == true, "IsEmpty() failed."); @@ -759,7 +759,7 @@ void TestNcpFrameBuffer(void) printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); printf("\n Test 12: Check returned error status"); WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityLow); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh), "InFrameFeedBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh); VerifyOrQuit(ncpBuffer.InFrameFeedData(buffer, sizeof(buffer)) == OT_ERROR_NO_BUFS, "Incorrect error status"); VerifyAndRemoveFrame1(ncpBuffer); VerifyOrQuit(ncpBuffer.IsEmpty() == true, "IsEmpty() failed."); @@ -791,7 +791,7 @@ void TestNcpFrameBuffer(void) printf("\n Test 13: Ensure we can utilize the full buffer size when frames removed during write"); WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityHigh); WriteTestFrame2(ncpBuffer, NcpFrameBuffer::kPriorityLow); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh), "InFrameBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityHigh); VerifyAndRemoveFrame1(ncpBuffer); VerifyAndRemoveFrame2(ncpBuffer); SuccessOrQuit(ncpBuffer.InFrameFeedData(buffer, sizeof(buffer) - 4), "InFrameFeedData() failed."); @@ -800,7 +800,7 @@ void TestNcpFrameBuffer(void) // Repeat the test with a low priority buffer write WriteTestFrame1(ncpBuffer, NcpFrameBuffer::kPriorityHigh); WriteTestFrame2(ncpBuffer, NcpFrameBuffer::kPriorityLow); - SuccessOrQuit(ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityLow), "InFrameBegin() failed."); + ncpBuffer.InFrameBegin(NcpFrameBuffer::kPriorityLow); VerifyAndRemoveFrame1(ncpBuffer); VerifyAndRemoveFrame2(ncpBuffer); SuccessOrQuit(ncpBuffer.InFrameFeedData(buffer, sizeof(buffer) - 4), "InFrameFeedData() failed."); @@ -821,7 +821,7 @@ void TestNcpFrameBuffer(void) printf("*"); priority = ((j % 3) == 0) ? NcpFrameBuffer::kPriorityHigh : NcpFrameBuffer::kPriorityLow; index = static_cast(j % sizeof(sHexText)); - SuccessOrQuit(ncpBuffer.InFrameBegin(priority), "InFrameBegin() failed"); + ncpBuffer.InFrameBegin(priority); SuccessOrQuit(ncpBuffer.InFrameFeedData(sHexText, index), "InFrameFeedData() failed."); SuccessOrQuit(ncpBuffer.InFrameGetPosition(pos1), "InFrameGetPosition() failed"); SuccessOrQuit(ncpBuffer.InFrameFeedData(sMysteryText, sizeof(sHexText) - index), "InFrameFeedData() failed."); @@ -867,7 +867,7 @@ void TestNcpFrameBuffer(void) printf("*"); priority = ((j % 3) == 0) ? NcpFrameBuffer::kPriorityHigh : NcpFrameBuffer::kPriorityLow; index = static_cast(j % sizeof(sHexText)); - SuccessOrQuit(ncpBuffer.InFrameBegin(priority), "InFrameBegin() failed"); + ncpBuffer.InFrameBegin(priority); SuccessOrQuit(ncpBuffer.InFrameFeedData(sHexText, index), "InFrameFeedData() failed."); SuccessOrQuit(ncpBuffer.InFrameGetPosition(pos1), "InFrameGetPosition() failed"); SuccessOrQuit(ncpBuffer.InFrameFeedData(sMysteryText, sizeof(sHexText) - index), "InFrameFeedData() failed."); @@ -951,7 +951,7 @@ otError WriteRandomFrame(uint32_t aLength, NcpFrameBuffer &aNcpBuffer, NcpFrameB CallbackContext oldContext = sContext; uint32_t tail = sFrameBufferTailIndex[priority]; - SuccessOrExit(error = aNcpBuffer.InFrameBegin(aPriority)); + aNcpBuffer.InFrameBegin(aPriority); while (aLength--) {