Skip to content

Commit 068f9e4

Browse files
Address PR Comments
1 parent bc2ae2f commit 068f9e4

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/app/util/attribute-storage.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,8 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
292292
}
293293
}
294294

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

src/controller/tests/TestServerCommandDispatch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ TEST_F(TestServerCommandDispatch, TestNoHandler)
197197
EXPECT_EQ(GetExchangeManager().GetNumActiveExchanges(), 0u);
198198
}
199199

200-
static const int kDescriptorAttributeArraySize = 254;
200+
static const int kDescriptorAttributeArraySize = 8;
201201

202202
// Declare Descriptor cluster attributes
203203
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs)

0 commit comments

Comments
 (0)