-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Make FindFabricByIndex
const to avoid unexpected/invalid mutations of FabricTable
#19929
Comments
tcarmelveilleux
added a commit
to tcarmelveilleux/connectedhomeip
that referenced
this issue
Jun 29, 2022
- Only FabricTable APIs are allowed to mutate FabricInfo entries due to the requirements of fail-safe shadow data handling - Previous PRs made sure none of the mutators were used outside of FabricTable, but `FindFabricByIndex` remained a non-const getter due to how much code was using it. Fixes project-chip#19929 This PR: - Renames the mutable `FabricInfo *` getter as `GetMutableFabricByIndex()` and makes it private to FabricTable. - Adds `const` qualifier to every other usage of FindFabricByIndex in the SDK. Testing done: - All unit tests pass - Cert tests still pass - Still compiles
tcarmelveilleux
added a commit
that referenced
this issue
Jun 29, 2022
* Make all public FabricInfo getters const - Only FabricTable APIs are allowed to mutate FabricInfo entries due to the requirements of fail-safe shadow data handling - Previous PRs made sure none of the mutators were used outside of FabricTable, but `FindFabricByIndex` remained a non-const getter due to how much code was using it. Fixes #19929 This PR: - Renames the mutable `FabricInfo *` getter as `GetMutableFabricByIndex()` and makes it private to FabricTable. - Adds `const` qualifier to every other usage of FindFabricByIndex in the SDK. Testing done: - All unit tests pass - Cert tests still pass - Still compiles * Fix CI on Shell * Fix one const in ESP32 ShellCommands.h
woody-apple
pushed a commit
to woody-apple/connectedhomeip
that referenced
this issue
Jun 29, 2022
* Make all public FabricInfo getters const - Only FabricTable APIs are allowed to mutate FabricInfo entries due to the requirements of fail-safe shadow data handling - Previous PRs made sure none of the mutators were used outside of FabricTable, but `FindFabricByIndex` remained a non-const getter due to how much code was using it. Fixes project-chip#19929 This PR: - Renames the mutable `FabricInfo *` getter as `GetMutableFabricByIndex()` and makes it private to FabricTable. - Adds `const` qualifier to every other usage of FindFabricByIndex in the SDK. Testing done: - All unit tests pass - Cert tests still pass - Still compiles * Fix CI on Shell * Fix one const in ESP32 ShellCommands.h
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
It is now forbidden to mutate FabricInfo entries directly without going via FabricTable APIs.
However, it was non-const long enough that many callsites only use const getters, but get a non-const pointer!
We need to fix this
Proposed Solution
const FabricInfo *
and beconst
.The text was updated successfully, but these errors were encountered: