diff --git a/src/posix/platform/settings.cpp b/src/posix/platform/settings.cpp index 73925fe21500..431b482792e4 100644 --- a/src/posix/platform/settings.cpp +++ b/src/posix/platform/settings.cpp @@ -474,18 +474,16 @@ otError PlatformSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex, } rval = write(swapFd, &key, sizeof(key)); - assert(rval == sizeof(key)); - VerifyOrDie(rval == sizeof(key), OT_EXIT_FAILURE); + VerifyOrExit(rval == sizeof(key), OT_EXIT_FAILURE); rval = write(swapFd, &length, sizeof(length)); - assert(rval == sizeof(length)); - VerifyOrDie(rval == sizeof(length), OT_EXIT_FAILURE); + VerifyOrExit(rval == sizeof(length), OT_EXIT_FAILURE); swapWrite(aInstance, swapFd, length); } exit: - VerifyOrDie(error != OT_ERROR_PARSE, OT_EXIT_FAILURE); + VerifyOrExit(error != OT_ERROR_PARSE, OT_EXIT_FAILURE); if (aSwapFd != nullptr) { @@ -495,9 +493,10 @@ otError PlatformSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex, { swapPersist(aInstance, swapFd); } - else if (error == OT_ERROR_NOT_FOUND) + else if ((error == OT_ERROR_NOT_FOUND) || (error == OT_EXIT_FAILURE)) { swapDiscard(aInstance, swapFd); + DieNow(error); } return error;