Skip to content

[mle] remove kReattachStart from ReattachState enum - #11609

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:mle/del-reattach-start-enum
Jun 23, 2025
Merged

[mle] remove kReattachStart from ReattachState enum#11609
jwhui merged 1 commit into
openthread:mainfrom
abtink:mle/del-reattach-start-enum

Conversation

@abtink

@abtink abtink commented Jun 18, 2025

Copy link
Copy Markdown
Member

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @abtink, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the reattachment state management within the MLE (Mesh Link Establishment) component. By removing a transitory state (kReattachStart) and determining the reattachment path earlier in the Start() method, I've simplified the overall logic and reduced unnecessary state transitions, leading to cleaner and more efficient code.

Highlights

  • Enum Simplification: I've removed the kReattachStart member from the ReattachState enumeration in mle.hpp. This state was previously a transitory one used during the reattachment process.
  • Direct State Determination: In Mle::Start() within mle.cpp, the mReattachState is now directly determined as either kReattachActive or kReattachStop based on the success of restoring an active dataset. This eliminates the need for the intermediate kReattachStart state.
  • Code Cleanup: The conditional logic in Mle::Attach() that previously handled the kReattachStart state transition has been removed. Additionally, I've updated the ReattachStateToString() function and its associated enum validation to reflect the removal of kReattachStart.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively simplifies the ReattachState enum by removing the transitory kReattachStart state. Moving the logic to determine the subsequent state (kReattachActive or kReattachStop) into Mle::Start() is a good simplification and makes the state transition clearer.

The changes in mle.cpp and mle.hpp consistently reflect this removal, including updates to the string representation and enum validation logic.

I've made one suggestion regarding the formatting of the ternary operator in Mle::Start() for potentially improved readability, but the current implementation is functionally correct.

Comment thread src/core/thread/mle.cpp
@size-report

size-report Bot commented Jun 18, 2025

Copy link
Copy Markdown

Size Report of OpenThread

Merging #11609 into main(f90d50b).

name branch text data bss total
ot-cli-ftd main 477888 860 66428 545176
#11609 477872 860 66428 545160
+/- -16 0 0 -16
ot-ncp-ftd main 443436 764 61648 505848
#11609 443420 764 61648 505832
+/- -16 0 0 -16
libopenthread-ftd.a main 244898 95 40206 285199
#11609 244870 95 40206 285171
+/- -28 0 0 -28
libopenthread-cli-ftd.a main 60743 0 8083 68826
#11609 60743 0 8083 68826
+/- 0 0 0 0
libopenthread-ncp-ftd.a main 32931 0 5924 38855
#11609 32931 0 5924 38855
+/- 0 0 0 0
ot-cli-mtd main 370920 764 50908 422592
#11609 370888 764 50908 422560
+/- -32 0 0 -32
ot-ncp-mtd main 351852 764 46152 398768
#11609 351820 764 46152 398736
+/- -32 0 0 -32
libopenthread-mtd.a main 163545 0 24710 188255
#11609 163509 0 24710 188219
+/- -36 0 0 -36
libopenthread-cli-mtd.a main 41134 0 8059 49193
#11609 41134 0 8059 49193
+/- 0 0 0 0
libopenthread-ncp-mtd.a main 25581 0 5924 31505
#11609 25581 0 5924 31505
+/- 0 0 0 0
ot-cli-ftd-br main 574952 868 133924 709744
#11609 574920 868 133924 709712
+/- -32 0 0 -32
libopenthread-ftd-br.a main 345845 100 107670 453615
#11609 345817 100 107670 453587
+/- -28 0 0 -28
libopenthread-cli-ftd-br.a main 75862 0 8115 83977
#11609 75862 0 8115 83977
+/- 0 0 0 0
ot-rcp main 63184 568 20804 84556
#11609 63184 568 20804 84556
+/- 0 0 0 0
libopenthread-rcp.a main 9932 0 5060 14992
#11609 9932 0 5060 14992
+/- 0 0 0 0
libopenthread-radio.a main 19269 0 238 19507
#11609 19269 0 238 19507
+/- 0 0 0 0

@codecov

codecov Bot commented Jun 18, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.83%. Comparing base (f90d50b) to head (806a759).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11609      +/-   ##
==========================================
- Coverage   74.36%   73.83%   -0.53%     
==========================================
  Files         640      638       -2     
  Lines       97100   102484    +5384     
==========================================
+ Hits        72204    75666    +3462     
- Misses      24896    26818    +1922     
Files with missing lines Coverage Δ
src/core/thread/mle.cpp 87.57% <100.00%> (+0.34%) ⬆️
src/core/thread/mle.hpp 93.79% <ø> (+3.10%) ⬆️

... and 154 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jwhui
jwhui requested a review from Copilot June 18, 2025 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the reattachment state management by removing the unnecessary kReattachStart state from the ReattachState enum.

  • Removed kReattachStart from the ReattachState enum in mle.hpp.
  • Updated state assignment in Mle::Start() to directly set the state based on the result of the ActiveDataset restore.
  • Removed the redundant kReattachStart check and its associated logic in Mle::Attach() and updated ReattachStateToString accordingly.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/core/thread/mle.hpp Removed kReattachStart from the ReattachState enum.
src/core/thread/mle.cpp Updated state handling in Start(), removed the redundant block in Attach(), and updated the string conversion.
Comments suppressed due to low confidence (2)

src/core/thread/mle.cpp:4215

  • [nitpick] Consider providing a more descriptive string for the kReattachStop state if it is used in logging or user messages, unless the empty string is intentional for this state.
        "",                                 // (0) kReattachStop

src/core/thread/mle.cpp:631

  • [nitpick] The removal of the kReattachStart check in Attach() simplifies the reattachment flow; please ensure that no side-effects from this state transition were relied upon elsewhere.
    {

@abtink
abtink marked this pull request as ready for review June 20, 2025 19:25
Comment thread src/core/thread/mle.cpp Outdated
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.
@abtink
abtink force-pushed the mle/del-reattach-start-enum branch from 56d815e to 806a759 Compare June 23, 2025 02:54
@jwhui
jwhui merged commit 984b3cb into openthread:main Jun 23, 2025
110 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants