Skip to content

Commit 3fc8487

Browse files
committedMay 2, 2024
- avoid using memcpy and use CopyCharSpanToMutableCharSpan instead
- do not emit TimeZoneStatus event during init - use raw list instead of getter
1 parent 853e6f2 commit 3fc8487

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/app/clusters/time-synchronization-server/time-synchronization-server.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,11 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
549549
{
550550
const TimeSyncDataProvider::TimeZoneStore & tzStore = GetTimeZone()[0];
551551
lastTz.offset = tzStore.timeZone.offset;
552-
if (tzStore.timeZone.name.HasValue() && sizeof(name) >= sizeof(tzStore.name))
552+
chip::MutableCharSpan tempSpan(name, sizeof(name));
553+
if (tzStore.timeZone.name.HasValue() &&
554+
CHIP_NO_ERROR == CopyCharSpanToMutableCharSpan(tzStore.timeZone.name.Value(), tempSpan))
553555
{
554-
lastTz.name.SetValue(CharSpan(name));
555-
memcpy(name, tzStore.name, sizeof(tzStore.name));
556+
lastTz.name.SetValue(CharSpan(tempSpan.data(), tempSpan.size()));
556557
}
557558
}
558559

@@ -653,7 +654,6 @@ CHIP_ERROR TimeSynchronizationServer::ClearTimeZone()
653654
{
654655
InitTimeZone();
655656
ReturnErrorOnFailure(mTimeSyncDataProvider.StoreTimeZone(GetTimeZone()));
656-
emitTimeZoneStatusEvent(GetDelegate()->GetEndpoint());
657657
return CHIP_NO_ERROR;
658658
}
659659

@@ -697,7 +697,7 @@ CHIP_ERROR TimeSynchronizationServer::SetDSTOffset(const DataModel::DecodableLis
697697

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

0 commit comments

Comments
 (0)