Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
mkardous-silabs and bzbarsky-apple authored Apr 26, 2024
1 parent 1a5ede8 commit 1d70aaf
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/tests/TestICDManager.cpp
Original file line number Diff line number Diff line change
@@ -771,7 +771,7 @@ class TestICDManager
// Set starting value for test
ICDConfigurationData::GetInstance().GetICDCounter().SetValue(startValue);

// Trigger ICD kInvalidateHalfCounterValues event
// Trigger ICD kInvalidateAllCounterValues event
ctx->mICDManager.HandleEventTrigger(static_cast<uint64_t>(ICDTestEventTriggerEvent::kInvalidateAllCounterValues));

// Validate counter has the expected value
8 changes: 4 additions & 4 deletions src/protocols/secure_channel/CheckInCounter.cpp
Original file line number Diff line number Diff line change
@@ -28,16 +28,16 @@ namespace SecureChannel {

CHIP_ERROR CheckInCounter::InvalidateHalfCheckInCouterValues()
{
// Increases the current counter value by half of its maximum range and update underlying counter storage.
// CheckInCounter is allowed to rollover.
// Increases the current counter value by half of its maximum range and updates underlying counter storage.
// CheckInCounter is allowed to roll over.
ReturnErrorOnFailure(AdvanceBy((UINT32_MAX / 2)));
return CHIP_NO_ERROR;
}

CHIP_ERROR CheckInCounter::InvalidateAllCheckInCounterValues()
{
// Increase current counter value by its maximum value to mimick N -> UINT32_MAX -> N-1 to invalidate all Check-In counter
// values. CheckInCounter is allowed to rollover.
// Increase current counter value by its maximum value to mimic N -> UINT32_MAX -> N-1 to invalidate all Check-In counter
// values. CheckInCounter is allowed to roll over.
ReturnErrorOnFailure(AdvanceBy(UINT32_MAX));
return CHIP_NO_ERROR;
}
6 changes: 3 additions & 3 deletions src/protocols/secure_channel/CheckInCounter.h
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ class CheckInCounter : public PersistedCounter<uint32_t>
inline uint32_t GetNextCheckInCounterValue() { return (mCounterValue + 1); };

/**
* @brief Doubles the current Check-In counter value to invalidate at least half of the values.
* @brief Advances the current Check-In counter value to invalidate half of the values.
* Function adds UINT32_MAX / 2 to the current counter value. Next time a Check-In message is sent, 1 is added to the
* current value.
*
@@ -56,8 +56,8 @@ class CheckInCounter : public PersistedCounter<uint32_t>
CHIP_ERROR InvalidateHalfCheckInCouterValues();

/**
* @brief Invalidates all the Check-In counter values. After function call, new Check-In counter value will be equal to current
* value minus 1 (with rollover) to mimick N -> UINT32_MAX -> N-1. Next time a Check-In message is sent, 1 is added to
* @brief Invalidates all the Check-In counter values. After this function is called, the new Check-In counter value will be equal to current
* value minus 1 (with rollover) to mimic N -> UINT32_MAX -> N-1. Next time a Check-In message is sent, 1 is added to
* the current value which will be an invalid counter value.
*
* @return CHIP_ERROR Any error returned by a write to persisted storage.
2 changes: 1 addition & 1 deletion src/protocols/secure_channel/tests/TestCheckInCounter.cpp
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ enum class CheckInCounterOperations : uint8_t
};

/**
* @brief Helpter function that validates CheckInCounter value after an operation for configurable input values
* @brief Helper function that validates CheckInCounter value after an operation for configurable input values
*
* @param startValue Starting value of the Check-In counter
* @param expectedValue Expected value after the InvalidateHalfCheckInCouterValues call

0 comments on commit 1d70aaf

Please sign in to comment.