Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmelveilleux committed Jun 28, 2022
1 parent 5994347 commit 3608fda
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app/FailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void FailSafeContext::ScheduleFailSafeCleanup(FabricIndex fabricIndex, bool addN
PlatformMgr().ScheduleWork(HandleDisarmFailSafe, reinterpret_cast<intptr_t>(this));
}

CHIP_ERROR FailSafeContext::ArmFailSafe(FabricIndex accessingFabricIndex, uint16_t expiryLengthSeconds)
CHIP_ERROR FailSafeContext::ArmFailSafe(FabricIndex accessingFabricIndex, System::Clock::Seconds16 expiryLengthSeconds)
{
CHIP_ERROR err = CHIP_NO_ERROR;
bool cancelTimersIfError = false;
Expand Down
3 changes: 2 additions & 1 deletion src/app/FailSafeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <system/SystemClock.h>

namespace chip {
namespace app {
Expand All @@ -41,7 +42,7 @@ class FailSafeContext
* when the fail-safe timer is currently armed, the currently-running fail-safe timer will
* first be cancelled, then the fail-safe timer will be re-armed.
*/
CHIP_ERROR ArmFailSafe(FabricIndex accessingFabricIndex, uint16_t expiryLengthSeconds);
CHIP_ERROR ArmFailSafe(FabricIndex accessingFabricIndex, System::Clock::Seconds16 expiryLengthSeconds);

/**
* @brief Cleanly disarm failsafe timer, such as on CommissioningComplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ bool emberAfGeneralCommissioningClusterArmFailSafeCallback(app::CommandHandler *
}
else
{
CheckSuccess(failSafeContext.ArmFailSafe(accessingFabricIndex, commandData.expiryLengthSeconds), Failure);
CheckSuccess(
failSafeContext.ArmFailSafe(accessingFabricIndex, System::Clock::Seconds16(commandData.expiryLengthSeconds)),
Failure);
Breadcrumb::Set(commandPath.mEndpointId, commandData.breadcrumb);
response.errorCode = CommissioningError::kOk;
commandObj->AddResponse(commandPath, response);
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void CommissioningWindowManager::OnSessionEstablished(const SessionHandle & sess
}
else
{
err = failSafeContext.ArmFailSafe(kUndefinedFabricId, 60);
err = failSafeContext.ArmFailSafe(kUndefinedFabricId, System::Clock::Seconds16(60));
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Error arming failsafe on PASE session establishment completion");
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestFailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void TestFailSafeContext_ArmFailSafe(nlTestSuite * inSuite, void * inCont

chip::app::FailSafeContext failSafeContext;

err = failSafeContext.ArmFailSafe(kTestAccessingFabricIndex1, 1);
err = failSafeContext.ArmFailSafe(kTestAccessingFabricIndex1, System::Clock::Seconds16(1));
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, failSafeContext.IsFailSafeArmed() == true);
NL_TEST_ASSERT(inSuite, failSafeContext.GetFabricIndex() == kTestAccessingFabricIndex1);
Expand All @@ -77,7 +77,7 @@ static void TestFailSafeContext_NocCommandInvoked(nlTestSuite * inSuite, void *

chip::app::FailSafeContext failSafeContext;

err = failSafeContext.ArmFailSafe(kTestAccessingFabricIndex1, 1);
err = failSafeContext.ArmFailSafe(kTestAccessingFabricIndex1, System::Clock::Seconds16(1));
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(inSuite, failSafeContext.GetFabricIndex() == kTestAccessingFabricIndex1);

Expand Down
2 changes: 1 addition & 1 deletion src/credentials/FabricTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ CHIP_ERROR FabricTable::CommitPendingFabricData()
{
if (mStateFlags.Has(StateFlags::kAbortCommitForTest))
{
// Clear state so that shutdown doesn't attemp clean-up
// Clear state so that shutdown doesn't attempt clean-up
mStateFlags.ClearAll();
mFabricIndexWithPendingState = kUndefinedFabricIndex;
mPendingFabric.Reset();
Expand Down
7 changes: 4 additions & 3 deletions src/credentials/tests/TestFabricTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1885,8 +1885,9 @@ void TestCommitMarker(nlTestSuite * inSuite, void * inContext)
fabricTable.SetForceAbortCommitForTest(true);
NL_TEST_ASSERT(inSuite, fabricTable.CommitPendingFabricData() == CHIP_ERROR_INTERNAL);

// Check that there are more keys now, partially committed.
NL_TEST_ASSERT(inSuite, storage.GetNumKeys() > numStorageKeysAfterFirstAdd);
// Check that there are more keys now, partially committed: at least a Commit Marker (+1)
// and some more keys from the aborted process.
NL_TEST_ASSERT(inSuite, storage.GetNumKeys() > (numStorageKeysAfterFirstAdd + 1));
}
}

Expand Down Expand Up @@ -1919,7 +1920,7 @@ void TestCommitMarker(nlTestSuite * inSuite, void * inContext)
// Make sure that all other pending storage got deleted
NL_TEST_ASSERT(inSuite, storage.GetNumKeys() == numStorageKeysAfterFirstAdd);

// Verify we canm only see 1 fabric with the iterator
// Verify we can only see 1 fabric with the iterator
{
size_t numFabricsIterated = 0;
bool saw1 = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,9 @@ CHIP_ERROR GenericThreadDriver::RevertConfiguration()
// If no backup could be found, it means that the network configuration has not been modified
// since the fail-safe was armed, so return with no error.
ReturnErrorCodeIf(error == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND, CHIP_NO_ERROR);
ReturnErrorOnFailure(error);

if (error == CHIP_NO_ERROR)
{
ChipLogError(NetworkProvisioning, "Found Thread configuration backup: reverting configuration");
}
else
{
ReturnErrorOnFailure(error);
}
ChipLogError(NetworkProvisioning, "Found Thread configuration backup: reverting configuration");

// Not all KVS implementations support zero-length values, so handle a special value representing an empty dataset.
ByteSpan dataset(datasetBytes, datasetLength);
Expand Down

0 comments on commit 3608fda

Please sign in to comment.