[settings] do not assert when SettingsFd is -1 in Deinit (#7170)

We added a dry run option. So it is possible that the settings fd is
-1 when de-initialization. The assert here makes the program
crash. This commit updates it to a `VerifyOrExit` to avoid crashing.
This commit is contained in:
Li Cao
2021-11-15 18:14:34 -08:00
committed by GitHub
parent 88d946cc08
commit 19cd73d691
+4 -1
View File
@@ -226,8 +226,11 @@ void otPlatSettingsDeinit(otInstance *aInstance)
otPosixSecureSettingsDeinit(aInstance);
#endif
assert(sSettingsFd != -1);
VerifyOrExit(sSettingsFd != -1);
VerifyOrDie(close(sSettingsFd) == 0, OT_EXIT_ERROR_ERRNO);
exit:
return;
}
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)