Skip to content

Commit 1979551

Browse files
committed
- avoid using memcpy and use CopyCharSpanToMutableCharSpan instead
- do not emit TimeZoneStatus event during init - use raw list instead of getter
1 parent 7b4e84f commit 1979551

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
@@ -545,10 +545,11 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
545545
{
546546
const TimeSyncDataProvider::TimeZoneStore & tzStore = GetTimeZone()[0];
547547
lastTz.offset = tzStore.timeZone.offset;
548-
if (tzStore.timeZone.name.HasValue() && sizeof(name) >= sizeof(tzStore.name))
548+
chip::MutableCharSpan tempSpan(name, sizeof(name));
549+
if (tzStore.timeZone.name.HasValue() &&
550+
CHIP_NO_ERROR == CopyCharSpanToMutableCharSpan(tzStore.timeZone.name.Value(), tempSpan))
549551
{
550-
lastTz.name.SetValue(CharSpan(name));
551-
memcpy(name, tzStore.name, sizeof(tzStore.name));
552+
lastTz.name.SetValue(CharSpan(tempSpan.data(), tempSpan.size()));
552553
}
553554
}
554555

@@ -649,7 +650,6 @@ CHIP_ERROR TimeSynchronizationServer::ClearTimeZone()
649650
{
650651
InitTimeZone();
651652
ReturnErrorOnFailure(mTimeSyncDataProvider.StoreTimeZone(GetTimeZone()));
652-
emitTimeZoneStatusEvent(GetDelegate()->GetEndpoint());
653653
return CHIP_NO_ERROR;
654654
}
655655

@@ -693,7 +693,7 @@ CHIP_ERROR TimeSynchronizationServer::SetDSTOffset(const DataModel::DecodableLis
693693

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

0 commit comments

Comments
 (0)