Skip to content

Commit

Permalink
- avoid using memcpy and use CopyCharSpanToMutableCharSpan instead
Browse files Browse the repository at this point in the history
- do not emit TimeZoneStatus event during init
- use raw list instead of getter
  • Loading branch information
fessehaeve committed May 14, 2024
1 parent 1fb67da commit 1212136
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,11 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
{
const TimeSyncDataProvider::TimeZoneStore & tzStore = GetTimeZone()[0];
lastTz.offset = tzStore.timeZone.offset;
if (tzStore.timeZone.name.HasValue() && sizeof(name) >= sizeof(tzStore.name))
chip::MutableCharSpan tempSpan(name, sizeof(name));
if (tzStore.timeZone.name.HasValue() &&
CHIP_NO_ERROR == CopyCharSpanToMutableCharSpan(tzStore.timeZone.name.Value(), tempSpan))
{
lastTz.name.SetValue(CharSpan(name));
memcpy(name, tzStore.name, sizeof(tzStore.name));
lastTz.name.SetValue(CharSpan(tempSpan.data(), tempSpan.size()));
}
}

Expand Down Expand Up @@ -653,7 +654,6 @@ CHIP_ERROR TimeSynchronizationServer::ClearTimeZone()
{
InitTimeZone();
ReturnErrorOnFailure(mTimeSyncDataProvider.StoreTimeZone(GetTimeZone()));
emitTimeZoneStatusEvent(GetDelegate()->GetEndpoint());
return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -697,7 +697,7 @@ CHIP_ERROR TimeSynchronizationServer::SetDSTOffset(const DataModel::DecodableLis

for (i = 0; i < mDstOffsetObj.validSize; i++)
{
const auto & dstItem = GetDSTOffset()[i];
const auto & dstItem = mDstOffsetObj.dstOffsetList[i];
// list should be sorted by validStarting
// validUntil shall be larger than validStarting
if (!dstItem.validUntil.IsNull() && dstItem.validStarting >= dstItem.validUntil.Value())
Expand Down

0 comments on commit 1212136

Please sign in to comment.