diff --git a/src/core/backbone_router/local.cpp b/src/core/backbone_router/local.cpp index e8bf10470..1863a885e 100644 --- a/src/core/backbone_router/local.cpp +++ b/src/core/backbone_router/local.cpp @@ -228,7 +228,7 @@ void Local::SetState(BackboneRouterState aState) } else if (aState == OT_BACKBONE_ROUTER_STATE_DISABLED) { - IgnoreError(Get().UnsubscribeMulticast(mAllNetworkBackboneRouters)); + Get().UnsubscribeMulticast(mAllNetworkBackboneRouters); } if (mState == OT_BACKBONE_ROUTER_STATE_PRIMARY) @@ -351,7 +351,7 @@ void Local::ApplyMeshLocalPrefix(void) { VerifyOrExit(IsEnabled(), OT_NOOP); - IgnoreError(Get().UnsubscribeMulticast(mAllNetworkBackboneRouters)); + Get().UnsubscribeMulticast(mAllNetworkBackboneRouters); mAllNetworkBackboneRouters.GetAddress().SetMulticastNetworkPrefix(Get().GetMeshLocalPrefix()); Get().SubscribeMulticast(mAllNetworkBackboneRouters); @@ -370,13 +370,13 @@ void Local::UpdateAllDomainBackboneRouters(Leader::DomainPrefixState aState) { if (!IsEnabled()) { - IgnoreError(Get().UnsubscribeMulticast(mAllDomainBackboneRouters)); + Get().UnsubscribeMulticast(mAllDomainBackboneRouters); ExitNow(); } if (aState == Leader::kDomainPrefixRemoved || aState == Leader::kDomainPrefixRefreshed) { - IgnoreError(Get().UnsubscribeMulticast(mAllDomainBackboneRouters)); + Get().UnsubscribeMulticast(mAllDomainBackboneRouters); } if (aState == Leader::kDomainPrefixAdded || aState == Leader::kDomainPrefixRefreshed) diff --git a/src/core/net/netif.cpp b/src/core/net/netif.cpp index bf9ea49ca..ad3fe6676 100644 --- a/src/core/net/netif.cpp +++ b/src/core/net/netif.cpp @@ -316,11 +316,9 @@ exit: return; } -otError Netif::UnsubscribeMulticast(const NetifMulticastAddress &aAddress) +void Netif::UnsubscribeMulticast(const NetifMulticastAddress &aAddress) { - otError error; - - SuccessOrExit(error = mMulticastAddresses.Remove(aAddress)); + SuccessOrExit(mMulticastAddresses.Remove(aAddress)); Get().Signal(OT_CHANGED_IP6_MULTICAST_UNSUBSCRIBED); @@ -328,7 +326,7 @@ otError Netif::UnsubscribeMulticast(const NetifMulticastAddress &aAddress) mAddressCallback(&aAddress.mAddress, kMulticastPrefixLength, /* IsAdded */ false, mAddressCallbackContext); exit: - return error; + return; } otError Netif::GetNextExternalMulticast(uint8_t &aIterator, Address &aAddress) const diff --git a/src/core/net/netif.hpp b/src/core/net/netif.hpp index ae3fd90e2..7d690a032 100644 --- a/src/core/net/netif.hpp +++ b/src/core/net/netif.hpp @@ -317,11 +317,8 @@ public: * * @param[in] aAddress A reference to the multicast address. * - * @retval OT_ERROR_NONE Successfully unsubscribed @p aAddress. - * @retval OT_ERROR_NOT_FOUND The multicast address was not found. - * */ - otError UnsubscribeMulticast(const NetifMulticastAddress &aAddress); + void UnsubscribeMulticast(const NetifMulticastAddress &aAddress); /** * This method provides the next external multicast address that the network interface subscribed. diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 581d06c5b..939833a15 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -301,8 +301,8 @@ void Mle::Stop(bool aClearNetworkDatasets) Get().Stop(); SetStateDetached(); - IgnoreError(Get().UnsubscribeMulticast(mRealmLocalAllThreadNodes)); - IgnoreError(Get().UnsubscribeMulticast(mLinkLocalAllThreadNodes)); + Get().UnsubscribeMulticast(mRealmLocalAllThreadNodes); + Get().UnsubscribeMulticast(mLinkLocalAllThreadNodes); Get().RemoveUnicastAddress(mMeshLocal16); Get().RemoveUnicastAddress(mMeshLocal64); @@ -914,8 +914,8 @@ void Mle::SetMeshLocalPrefix(const MeshLocalPrefix &aMeshLocalPrefix) // We must remove the old addresses before adding the new ones. Get().RemoveUnicastAddress(mMeshLocal64); Get().RemoveUnicastAddress(mMeshLocal16); - IgnoreError(Get().UnsubscribeMulticast(mLinkLocalAllThreadNodes)); - IgnoreError(Get().UnsubscribeMulticast(mRealmLocalAllThreadNodes)); + Get().UnsubscribeMulticast(mLinkLocalAllThreadNodes); + Get().UnsubscribeMulticast(mRealmLocalAllThreadNodes); } mMeshLocal64.GetAddress().SetPrefix(aMeshLocalPrefix); diff --git a/tests/unit/test_netif.cpp b/tests/unit/test_netif.cpp index dbfcc869f..28891f545 100644 --- a/tests/unit/test_netif.cpp +++ b/tests/unit/test_netif.cpp @@ -185,11 +185,11 @@ void TestNetifMulticastAddresses(void) netif.UnsubscribeAllExternalMulticastAddresses(); VerifyMulticastAddressList(netif, &addresses[2], 4); - SuccessOrQuit(netif.UnsubscribeMulticast(netifAddress), "UnsubscribeMulticast() failed"); + netif.UnsubscribeMulticast(netifAddress); VerifyMulticastAddressList(netif, &addresses[2], 3); - VerifyOrQuit(netif.UnsubscribeMulticast(netifAddress) == OT_ERROR_NOT_FOUND, - "UnsubscribeMulticast() did not fail when address was not subscribed"); + netif.UnsubscribeMulticast(netifAddress); + VerifyMulticastAddressList(netif, &addresses[2], 3); SuccessOrQuit(netif.UnsubscribeAllNodesMulticast(), "UnsubscribeAllNodesMulticast() failed"); VerifyMulticastAddressList(netif, NULL, 0);