[settings] change save/delete methods to return void (#11735)

This commit simplifies the `Settings` API by modifying all "Save"
and "Delete" methods to return `void` instead of `Error`.

Settings operations are required for a Thread device to function, so a
failure to save or delete from non-volatile storage should be treated
as a critical error. Previously, the code effectively ignored these
errors using `IgnoreError()`. This change instead treats any such
failure as a critical error, triggering an assert within the
`Settings` module.

The key changes include:
- `Settings::Save<T>()`, `Delete<T>()`, `DeleteAllChildInfo()`, and
  similar methods now return `void`.
- Internal `Settings` methods use `SuccessOrAssert()` to assert on
  errors.
- The responsibility for asserting on `kErrorNotImplemented` is moved
  to the `SettingsDriver` layer.

This update simplifies the caller logic by removing the need for
`IgnoreError()` at many call sites. Consequently, several methods
that primarily wrapped `Settings` calls, such as `Mle::Store()` and
`BorderAgent::SetId()`, have also been updated to return `void`.
This commit is contained in:
Abtin Keshavarzian
2025-07-21 22:46:19 -07:00
committed by GitHub
parent c9ee6d0576
commit f73d64e611
17 changed files with 71 additions and 108 deletions
+3 -3
View File
@@ -140,7 +140,7 @@ Error DuaManager::GenerateDomainUnicastAddressIid(void)
if (dadCounter != mDadCounter)
{
mDadCounter = dadCounter;
IgnoreError(Store());
Store();
}
LogInfo("Generated DUA: %s", mDomainUnicastAddress.GetAddress().ToString().AsCString());
@@ -208,12 +208,12 @@ exit:
return;
}
Error DuaManager::Store(void)
void DuaManager::Store(void)
{
Settings::DadInfo dadInfo;
dadInfo.SetDadCounter(mDadCounter);
return Get<Settings>().Save(dadInfo);
Get<Settings>().Save(dadInfo);
}
void DuaManager::AddDomainUnicastAddress(void)