mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
Cleanup error code usage. Avoid raising errors when value is unchanged. (#787)
This change is attempting to address two issues:
1. Returning `kThreadError_Busy`, when `kThreadError_Already`,
`kThreadError_InvalidState`, or even the lazy
`kThreadError_Failed` would be more-appropriate/less-misleading.
2. Setters returning an error when the value to be changed is already
set to the requested value.
Number one hurts debuggability. Number two makes the code more fragile.
The cases where both intersect can be maddening.
This change replaces cases inappropriately returning
`kThreadError_Busy` with a better, more specific error code. It also
makes some "setter" functions (Including `otInterfaceUp()` and
`otThreadStart()`) return success if the value is already set.
This commit is contained in:
committed by
Jonathan Hui
parent
2d5c4c58f2
commit
104ca6d10d
@@ -621,7 +621,7 @@ ThreadError Ip6::AddNetif(Netif &aNetif)
|
||||
{
|
||||
if (netif == &aNetif)
|
||||
{
|
||||
ExitNow(error = kThreadError_Busy);
|
||||
ExitNow(error = kThreadError_Already);
|
||||
}
|
||||
}
|
||||
while (netif->mNext);
|
||||
@@ -642,9 +642,9 @@ exit:
|
||||
|
||||
ThreadError Ip6::RemoveNetif(Netif &aNetif)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
ThreadError error = kThreadError_NotFound;
|
||||
|
||||
VerifyOrExit(mNetifListHead != NULL, error = kThreadError_Busy);
|
||||
VerifyOrExit(mNetifListHead != NULL, error = kThreadError_NotFound);
|
||||
|
||||
if (mNetifListHead == &aNetif)
|
||||
{
|
||||
@@ -660,6 +660,7 @@ ThreadError Ip6::RemoveNetif(Netif &aNetif)
|
||||
}
|
||||
|
||||
netif->mNext = aNetif.mNext;
|
||||
error = kThreadError_None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user