mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 14:47:46 +00:00
[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user