[mle] remove kReattachStart from ReattachState enum (#11609)

This commit simplifies the code by removing the `kReattachStart` state
from the `ReattachState` enumeration. This enum is used after MLE
`Start()` to track whether to attempt to attach using a persisted
Active or Pending Dataset.

Previously, `kReattachStart` was a transitory state set in `Start()`
and then changed in the `Attach()` method to either `kReattachActive`
 or `kReattachStop`, based on whether the device had a saved Active
 Dataset.

This change simplifies the code by determining the state directly in
`Mle::Start()`, which allows for the removal of the now unnecessary
`kReattachStart` case.
This commit is contained in:
Abtin Keshavarzian
2025-06-23 07:50:14 -07:00
committed by GitHub
parent c221dae3e4
commit 984b3cb1c8
2 changed files with 4 additions and 18 deletions
+4 -17
View File
@@ -231,7 +231,8 @@ Error Mle::Start(StartMode aMode)
if (aMode == kNormalAttach)
{
mReattachState = kReattachStart;
mReattachState =
(Get<MeshCoP::ActiveDatasetManager>().Restore() == kErrorNone) ? kReattachActive : kReattachStop;
}
if ((aMode == kAnnounceAttach) || (GetRloc16() == kInvalidRloc16))
@@ -631,18 +632,6 @@ void Mle::Attach(AttachMode aMode)
mAttachCounter = 0;
}
if (mReattachState == kReattachStart)
{
if (Get<MeshCoP::ActiveDatasetManager>().Restore() == kErrorNone)
{
mReattachState = kReattachActive;
}
else
{
mReattachState = kReattachStop;
}
}
mParentCandidate.Clear();
SetAttachState(kAttachStateStart);
mAttachMode = aMode;
@@ -4224,16 +4213,14 @@ const char *Mle::ReattachStateToString(ReattachState aState)
{
static const char *const kReattachStateStrings[] = {
"", // (0) kReattachStop
"reattaching", // (1) kReattachStart
"reattaching with Active Dataset", // (2) kReattachActive
"reattaching with Pending Dataset", // (3) kReattachPending
"reattaching with Active Dataset", // (1) kReattachActive
"reattaching with Pending Dataset", // (2) kReattachPending
};
struct EnumCheck
{
InitEnumValidatorCounter();
ValidateNextEnum(kReattachStop);
ValidateNextEnum(kReattachStart);
ValidateNextEnum(kReattachActive);
ValidateNextEnum(kReattachPending);
};
-1
View File
@@ -1328,7 +1328,6 @@ private:
enum ReattachState : uint8_t
{
kReattachStop, // Reattach process is disabled or finished
kReattachStart, // Start reattach process
kReattachActive, // Reattach using stored Active Dataset
kReattachPending, // Reattach using stored Pending Dataset
};