From 6de1f2aa8f7945c9e2527eaacc3b4a3518a3d84c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 25 Jun 2021 02:00:49 -0400 Subject: [PATCH] Regenerate generated files --- .../gen/attribute-size.cpp | 18 +++++++--- .../tv-app/tv-common/gen/attribute-size.cpp | 9 +++-- .../data_model/gen/CHIPClientCallbacks.cpp | 34 +++++++++---------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/gen/attribute-size.cpp b/examples/all-clusters-app/all-clusters-common/gen/attribute-size.cpp index cff2cebbffe20e..96172ed05f4f66 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/attribute-size.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/attribute-size.cpp @@ -138,7 +138,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo { case 0x0000: // accepts header list { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, index - 1); + entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); if (entryOffset == 0) { ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); @@ -155,7 +155,12 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo return 0; } - entryLength = acceptsHeaderListSpan->size(); + if (!CanCastTo(acceptsHeaderListSpan->size())) + { + ChipLogError(Zcl, "Span size %zu is too large", acceptsHeaderListSpan->size()); + return 0; + } + entryLength = static_cast(acceptsHeaderListSpan->size()); break; } case 0x0001: // supported streaming types @@ -548,7 +553,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo } case 0x001B: // list_octet_string { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, index - 1); + entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); if (entryOffset == 0) { ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); @@ -565,7 +570,12 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo return 0; } - entryLength = listOctetStringSpan->size(); + if (!CanCastTo(listOctetStringSpan->size())) + { + ChipLogError(Zcl, "Span size %zu is too large", listOctetStringSpan->size()); + return 0; + } + entryLength = static_cast(listOctetStringSpan->size()); break; } case 0x001C: // list_struct_octet_string diff --git a/examples/tv-app/tv-common/gen/attribute-size.cpp b/examples/tv-app/tv-common/gen/attribute-size.cpp index 1a8c6cc4d78fd3..d2cd645eb78ab6 100644 --- a/examples/tv-app/tv-common/gen/attribute-size.cpp +++ b/examples/tv-app/tv-common/gen/attribute-size.cpp @@ -138,7 +138,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo { case 0x0000: // accepts header list { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, index - 1); + entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); if (entryOffset == 0) { ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); @@ -155,7 +155,12 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo return 0; } - entryLength = acceptsHeaderListSpan->size(); + if (!CanCastTo(acceptsHeaderListSpan->size())) + { + ChipLogError(Zcl, "Span size %zu is too large", acceptsHeaderListSpan->size()); + return 0; + } + entryLength = static_cast(acceptsHeaderListSpan->size()); break; } case 0x0001: // supported streaming types diff --git a/src/controller/data_model/gen/CHIPClientCallbacks.cpp b/src/controller/data_model/gen/CHIPClientCallbacks.cpp index 49752b1f185c40..4ad1aaaca4b3a2 100644 --- a/src/controller/data_model/gen/CHIPClientCallbacks.cpp +++ b/src/controller/data_model/gen/CHIPClientCallbacks.cpp @@ -455,7 +455,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].outputType = emberAfGetInt8u(message, 0, 1); message += 1; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -476,7 +476,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag { CHECK_STATUS(ReadByteSpan(message, messageLen, &data[i])); uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); - messageLen -= entryLength; + messageLen = static_cast(messageLen - entryLength); message += entryLength; } @@ -581,10 +581,10 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag for (size_t i = 0; i < count; i++) { CHECK_STATUS(ReadByteSpan(message, 18, &data[i].label)); - messageLen -= 18; + messageLen = static_cast(messageLen - 18); message += 18; CHECK_STATUS(ReadByteSpan(message, 18, &data[i].value)); - messageLen -= 18; + messageLen = static_cast(messageLen - 18); message += 18; } @@ -604,7 +604,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag for (size_t i = 0; i < count; i++) { CHECK_STATUS(ReadByteSpan(message, 34, &data[i].Name)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; CHECK_MESSAGE_LENGTH(1); data[i].FabricConnected = emberAfGetInt8u(message, 0, 1); @@ -667,7 +667,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].GroupKeyIndex = emberAfGetInt16u(message, 0, 2); message += 2; CHECK_STATUS(ReadByteSpan(message, 18, &data[i].GroupKeyRoot)); - messageLen -= 18; + messageLen = static_cast(messageLen - 18); message += 18; CHECK_MESSAGE_LENGTH(8); data[i].GroupKeyEpochStartTime = emberAfGetInt64u(message, 0, 8); @@ -699,10 +699,10 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].inputType = emberAfGetInt8u(message, 0, 1); message += 1; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].description)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -731,7 +731,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].NodeId = emberAfGetInt64u(message, 0, 8); message += 8; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].Label)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -758,13 +758,13 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].minorNumber = emberAfGetInt16u(message, 0, 2); message += 2; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].callSign)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].affiliateCallSign)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -787,7 +787,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].identifier = emberAfGetInt8u(message, 0, 1); message += 1; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -824,7 +824,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag { CHECK_STATUS(ReadByteSpan(message, messageLen, &data[i])); uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); - messageLen -= entryLength; + messageLen = static_cast(messageLen - entryLength); message += entryLength; } @@ -842,7 +842,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].fabricIndex = emberAfGetInt64u(message, 0, 8); message += 8; CHECK_STATUS(ReadByteSpan(message, 34, &data[i].operationalCert)); - messageLen -= 34; + messageLen = static_cast(messageLen - 34); message += 34; } @@ -881,10 +881,10 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag data[i].LQI = emberAfGetInt8u(message, 0, 1); message += 1; CHECK_MESSAGE_LENGTH(1); - data[i].AverageRssi = emberAfGetInt8u(message, 0, 1); + data[i].AverageRssi = emberAfGetInt8s(message, 0, 1); message += 1; CHECK_MESSAGE_LENGTH(1); - data[i].LastRssi = emberAfGetInt8u(message, 0, 1); + data[i].LastRssi = emberAfGetInt8s(message, 0, 1); message += 1; CHECK_MESSAGE_LENGTH(1); data[i].FrameErrorRate = emberAfGetInt8u(message, 0, 1);