Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nivi-apple committed Jul 26, 2024
1 parent 362ca12 commit cb96615
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 4 additions & 12 deletions examples/thermostat/linux/thermostat-delegate-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ CHIP_ERROR ThermostatDelegate::GetActivePresetHandle(MutableByteSpan & activePre
{
if (mActivePresetHandleDataSize > 0)
{
ByteSpan presetHandleSpan(mActivePresetHandleData, mActivePresetHandleDataSize);
CopySpanToMutableSpan(presetHandleSpan, activePresetHandle);
CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle);
}
else
{
Expand All @@ -156,8 +155,8 @@ CHIP_ERROR ThermostatDelegate::SetActivePresetHandle(const DataModel::Nullable<B
if (newActivePresetHandleSize > kPresetHandleSize)
{
ChipLogError(NotSpecified,
"Failed to set ActivePresetHandle. newActivePresetHandle size %ld is larger than preset handle size %ld",
newActivePresetHandleSize, kPresetHandleSize);
"Failed to set ActivePresetHandle. newActivePresetHandle size %u is larger than preset handle size %u",
static_cast<uint8_t>(newActivePresetHandleSize), static_cast<uint8_t>(kPresetHandleSize));
return CHIP_ERROR_NO_MEMORY;
}
memcpy(mActivePresetHandleData, newActivePresetHandle.Value().data(), newActivePresetHandleSize);
Expand All @@ -183,14 +182,7 @@ CHIP_ERROR ThermostatDelegate::AppendToPendingPresetList(const PresetStruct::Typ
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetName(preset.name);
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetCoolingSetpoint(preset.coolingSetpoint);
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetHeatingSetpoint(preset.heatingSetpoint);
if (!preset.builtIn.IsNull())
{
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetBuiltIn(preset.builtIn);
}
else
{
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetBuiltIn(NullOptional);
}
mPendingPresets[mNextFreeIndexInPendingPresetsList].SetBuiltIn(preset.builtIn);
mNextFreeIndexInPendingPresetsList++;
return CHIP_NO_ERROR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ CHIP_ERROR PresetStructWithOwnedMembers::SetPresetHandle(const Nullable<ByteSpan
size_t newPresetHandleSize = newPresetHandle.Value().size();
if (newPresetHandleSize > kPresetHandleSize)
{
ChipLogError(Zcl, "Failed to set Preset handle. New preset handle size (%ld) > allowed preset handle size (%ld)",
newPresetHandleSize, kPresetNameSize);
ChipLogError(Zcl, "Failed to set Preset handle. New preset handle size (%u) > allowed preset handle size (%u)",
static_cast<uint8_t>(newPresetHandleSize), static_cast<uint8_t>(kPresetNameSize));
return CHIP_ERROR_NO_MEMORY;
}
MutableByteSpan targetSpan(presetHandleData);
Expand All @@ -85,8 +85,8 @@ CHIP_ERROR PresetStructWithOwnedMembers::SetName(const Optional<DataModel::Nulla
size_t newNameSize = newName.Value().Value().size();
if (newNameSize > kPresetNameSize)
{
ChipLogError(Zcl, "Failed to set Preset name. New name size (%ld) > allowed preset name size (%ld)", newNameSize,
kPresetNameSize);
ChipLogError(Zcl, "Failed to set Preset name. New name size (%u) > allowed preset name size (%u)", static_cast<uint8_t>(newNameSize),
static_cast<uint8_t>(kPresetNameSize));
return CHIP_ERROR_NO_MEMORY;
}
MutableCharSpan targetSpan(presetNameData);
Expand Down

0 comments on commit cb96615

Please sign in to comment.