Skip to content

Commit

Permalink
[mle] simplify condition in Mle::BecomeDetached() (openthread#10796)
Browse files Browse the repository at this point in the history
This commit updates the skip condition in `BecomeDetached()` to use
positive boolean checks for improved readability. This condition
applies when the device is already detached and is about to start an
attach attempt.
  • Loading branch information
abtink authored Oct 8, 2024
1 parent be74a3c commit c027237
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,12 @@ Error Mle::BecomeDetached(void)

VerifyOrExit(!IsDisabled(), error = kErrorInvalidState);

// In case role is already detached and attach state is `kAttachStateStart`
// (i.e., waiting to start an attach attempt), there is no need to make any
// changes.

VerifyOrExit(!IsDetached() || mAttachState != kAttachStateStart);
if (IsDetached() && (mAttachState == kAttachStateStart))
{
// Already detached and waiting to start an attach attempt, so
// there is not need to make any changes.
ExitNow();
}

// Not in reattach stage after reset
if (mReattachState == kReattachStop)
Expand Down

0 comments on commit c027237

Please sign in to comment.