[mle] add AppendSourceAddressAndLeaderDataTlvs() helper - #12867
Conversation
This commit introduces `TxMessage::AppendSourceAddressAndLeaderDataTlvs()` to consolidate the appending of `Source Address` and `Leader Data` TLVs. This combination is frequently used together across various MLE messages to provide the sender's identity and leader data. Centralizing this into a single helper method improves code consistency. Additionally, the `TxMessage` methods in `mle.hpp` and `mle.cpp` are organized into "Appending single TLV" and "Appending multiple TLVs" sections for better clarity and maintainability. Existing multi-TLV methods like `AppendLinkAndMleFrameCounterTlvs()` and `AppendActiveAndPendingTimestampTlvs()` are moved to the new section.
Summary of ChangesHello, 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 improves code consistency and maintainability within the MLE message handling logic. By centralizing the common pattern of appending Source Address and Leader Data TLVs into a single helper method, the codebase becomes cleaner and less prone to errors. Additionally, the reorganization of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Library files
|
There was a problem hiding this comment.
Code Review
This pull request refactors the MLE message construction by introducing helper methods to append multiple related TLVs, such as source address and leader data, link and MLE frame counters, and active and pending timestamps. This reduces code duplication across various message-sending functions. The review feedback highlights the need to ensure robustness by calling a length-checking function after processing each TLV in these new helper methods, as per project guidelines.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12867 +/- ##
==========================================
- Coverage 75.00% 73.32% -1.68%
==========================================
Files 696 696
Lines 95432 98534 +3102
==========================================
+ Hits 71576 72249 +673
- Misses 23856 26285 +2429
🚀 New features to boost your workflow:
|
This commit introduces
TxMessage::AppendSourceAddressAndLeaderDataTlvs()to consolidate the appending ofSource AddressandLeader DataTLVs.This combination is frequently used together across various MLE messages to provide the sender's identity and leader data. Centralizing this into a single helper method improves code consistency.
Additionally, the
TxMessagemethods inmle.hppandmle.cppare organized into "Appending single TLV" and "Appending multiple TLVs" sections for better clarity and maintainability. Existing multi-TLV methods likeAppendLinkAndMleFrameCounterTlvs()andAppendActiveAndPendingTimestampTlvs()are moved to the new section.