Skip to content

Commit e74b31c

Browse files
Address PR Comments
1 parent 465f21f commit e74b31c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/app/util/attribute-storage.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,8 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
293293
}
294294
}
295295

296-
for (uint8_t i = 0; ep && (i < ep->clusterCount); i++)
296+
for (uint8_t i = 0; i < ep->clusterCount; i++)
297297
{
298-
if (!ep->cluster)
299-
{
300-
continue;
301-
}
302-
303298
const EmberAfCluster * cluster = &(ep->cluster[i]);
304299
if (!cluster->attributes)
305300
{
@@ -309,11 +304,14 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
309304
for (uint16_t j = 0; j < cluster->attributeCount; j++)
310305
{
311306
const EmberAfAttributeMetadata * attr = &(cluster->attributes[j]);
312-
if (emberAfAttributeSize(attr) > chip::app::Compatibility::Internal::gEmberAttributeIOBufferSpan.size())
307+
uint16_t attrSize = emberAfAttributeSize(attr);
308+
size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan.size();
309+
if (attrSize > bufferSize)
313310
{
314-
ChipLogError(DataManagement,
315-
"Attribute %u (id=" ChipLogFormatMEI ") of Cluster %u (id=" ChipLogFormatMEI ") too large", j,
316-
ChipLogValueMEI(attr->attributeId), i, ChipLogValueMEI(cluster->clusterId));
311+
ChipLogError(
312+
DataManagement,
313+
"Attribute size %u exceeds max size %lu, (attrId=" ChipLogFormatMEI ", clusterId=" ChipLogFormatMEI ")",
314+
attrSize, (unsigned long) bufferSize, ChipLogValueMEI(attr->attributeId), ChipLogValueMEI(cluster->clusterId));
317315
return CHIP_ERROR_NO_MEMORY;
318316
}
319317
}

src/controller/tests/TestServerCommandDispatch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ TEST_F(TestServerCommandDispatch, TestNoHandler)
215215
EXPECT_EQ(GetExchangeManager().GetNumActiveExchanges(), 0u);
216216
}
217217

218-
static const int kDescriptorAttributeArraySize = 254;
218+
static const int kDescriptorAttributeArraySize = 8;
219219

220220
// Declare Descriptor cluster attributes
221221
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs)

0 commit comments

Comments
 (0)