-
Notifications
You must be signed in to change notification settings - Fork 1.4k
samples: matter: Allow using enums as keys in the finite map #25477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
samples: matter: Allow using enums as keys in the finite map #25477
Conversation
If the T1 type was an enum type, then the kInvalidKey gets 0 value instead of type::max(). To fix it, conditionally get the underlying type of T1 if it is an enum, and return T1 if not. Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
There was a problem hiding this comment.
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 fixes an issue where enum types used as keys in FiniteMap would incorrectly get kInvalidKey set to 0 instead of the maximum value of the enum's underlying type. The fix introduces a KeyTypeHelper template struct to conditionally extract the underlying type for enums while preserving the original type for non-enum types.
- Adds
KeyTypeHelpertemplate struct to handle type extraction for both enum and non-enum key types - Updates
kInvalidKeyinitialization to use the underlying type's maximum value for enums
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2c3bf89 to
9a3bb49
Compare
CI InformationTo view the history of this post, click the 'edited' button above Inputs:Sources:sdk-nrf: PR head: 9a3bb49ceb8504083f7c607908ca8047a85089ab more detailssdk-nrf:
Github labels
List of changed files detected by CI (1)Outputs:ToolchainVersion: df3cc9d822 Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
Memory footprint analysis revealed the following potential issuessample.matter.template.debug[nrf5340dk/nrf5340/cpuapp]: RAM size increased by 2048[B] in comparison to the main[3524638] branch. - link (cc: @kkasperczyk-no @ArekBalysNordic @markaj-nordic) Note: This message is automatically posted and updated by the CI (latest/sdk-nrf/PR-25477/1) |
If the T1 type was an enum type, then the kInvalidKey gets 0 value instead of type::max().
To fix it, conditionally get the underlying type of T1 if it is an enum, and return T1 if not.