From c0272376762409805634d6363fd4c643115c7c93 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 8 Oct 2024 14:37:30 -0700 Subject: [PATCH] [mle] simplify condition in `Mle::BecomeDetached()` (#10796) 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. --- src/core/thread/mle.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index f1bf2454e..655246eb7 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -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)