From 37356675fa400c0b6d1c5cb892c8e633ce2f0709 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Mon, 20 Mar 2023 11:13:35 -0400 Subject: [PATCH] Refactor of variable, members and functions according to suggestions --- .../scenes/ExtensionFieldSetsImpl.cpp | 28 ++++++------- .../clusters/scenes/ExtensionFieldSetsImpl.h | 9 ++--- src/app/clusters/scenes/SceneTable.h | 39 ++++++++----------- src/app/clusters/scenes/SceneTableImpl.cpp | 34 +++++++--------- src/app/tests/TestSceneTable.cpp | 23 ++++++----- src/app/util/mock/attribute-storage.cpp | 28 ++++++------- 6 files changed, 73 insertions(+), 88 deletions(-) diff --git a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp index 1bd09ea64eea62..95900c167dc424 100644 --- a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp +++ b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp @@ -32,9 +32,9 @@ CHIP_ERROR ExtensionFieldSetsImpl::Serialize(TLV::TLVWriter & writer) const { for (uint8_t i = 0; i < mFieldSetsCount; i++) { - if (!mEFS[i].IsEmpty()) + if (!mFieldSets[i].IsEmpty()) { - ReturnErrorOnFailure(mEFS[i].Serialize(writer)); + ReturnErrorOnFailure(mFieldSets[i].Serialize(writer)); } } } @@ -55,7 +55,7 @@ CHIP_ERROR ExtensionFieldSetsImpl::Deserialize(TLV::TLVReader & reader) { for (uint8_t i = 0; i < mFieldSetsCount; i++) { - ReturnErrorOnFailure(mEFS[i].Deserialize(reader)); + ReturnErrorOnFailure(mFieldSets[i].Deserialize(reader)); } } @@ -68,7 +68,7 @@ void ExtensionFieldSetsImpl::Clear() { for (uint8_t i = 0; i < mFieldSetsCount; i++) { - mEFS[i].Clear(); + mFieldSets[i].Clear(); } } mFieldSetsCount = 0; @@ -85,24 +85,24 @@ CHIP_ERROR ExtensionFieldSetsImpl::InsertFieldSet(const ExtensionFieldSet & fiel VerifyOrReturnError(fieldSet.mID != kInvalidClusterId, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(!fieldSet.IsEmpty(), CHIP_ERROR_INVALID_ARGUMENT); - for (uint8_t i = 0; i < kMaxClusterPerScenes; i++) + for (uint8_t i = 0; i < kMaxClustersPerScene; i++) { - if (mEFS[i].mID == fieldSet.mID) + if (mFieldSets[i].mID == fieldSet.mID) { - mEFS[i] = fieldSet; + mFieldSets[i] = fieldSet; return CHIP_NO_ERROR; } - if (mEFS[i].IsEmpty() && firstEmptyPosition == kInvalidPosition) + if (mFieldSets[i].IsEmpty() && firstEmptyPosition == kInvalidPosition) { firstEmptyPosition = i; } } // if found, replace at found position, otherwise insert at first free position, otherwise return error - if (firstEmptyPosition < kMaxClusterPerScenes) + if (firstEmptyPosition < kMaxClustersPerScene) { - mEFS[firstEmptyPosition] = fieldSet; + mFieldSets[firstEmptyPosition] = fieldSet; mFieldSetsCount++; return CHIP_NO_ERROR; } @@ -114,7 +114,7 @@ CHIP_ERROR ExtensionFieldSetsImpl::GetFieldSetAtPosition(ExtensionFieldSet & fie { VerifyOrReturnError(position < mFieldSetsCount, CHIP_ERROR_BUFFER_TOO_SMALL); - fieldSet = mEFS[position]; + fieldSet = mFieldSets[position]; return CHIP_NO_ERROR; } @@ -124,18 +124,18 @@ CHIP_ERROR ExtensionFieldSetsImpl::RemoveFieldAtPosition(uint8_t position) VerifyOrReturnValue(position < mFieldSetsCount, CHIP_NO_ERROR); uint8_t nextPos = static_cast(position + 1); - uint8_t moveNum = static_cast(kMaxClusterPerScenes - nextPos); + uint8_t moveNum = static_cast(kMaxClustersPerScene - nextPos); // TODO: Implement general array management methods // Compress array after removal, if the removed position is not the last if (moveNum) { - memmove(&mEFS[position], &mEFS[nextPos], sizeof(ExtensionFieldSet) * moveNum); + memmove(&mFieldSets[position], &mFieldSets[nextPos], sizeof(ExtensionFieldSet) * moveNum); } mFieldSetsCount--; // Clear last occupied position - mEFS[mFieldSetsCount].Clear(); // + mFieldSets[mFieldSetsCount].Clear(); // return CHIP_NO_ERROR; } diff --git a/src/app/clusters/scenes/ExtensionFieldSetsImpl.h b/src/app/clusters/scenes/ExtensionFieldSetsImpl.h index 7a5996502a0d28..9c544b4893fbe5 100644 --- a/src/app/clusters/scenes/ExtensionFieldSetsImpl.h +++ b/src/app/clusters/scenes/ExtensionFieldSetsImpl.h @@ -117,8 +117,7 @@ struct ExtensionFieldSet bool operator==(const ExtensionFieldSet & other) const { - return (mID == other.mID && mUsedBytes == other.mUsedBytes && - !memcmp(mBytesBuffer, other.mBytesBuffer, mUsedBytes)); + return (mID == other.mID && mUsedBytes == other.mUsedBytes && !memcmp(mBytesBuffer, other.mBytesBuffer, mUsedBytes)); } }; @@ -144,7 +143,7 @@ class ExtensionFieldSetsImpl : public ExtensionFieldSets { for (uint8_t i = 0; i < mFieldSetsCount; i++) { - if (!(this->mEFS[i] == other.mEFS[i])) + if (!(this->mFieldSets[i] == other.mFieldSets[i])) { return false; } @@ -156,7 +155,7 @@ class ExtensionFieldSetsImpl : public ExtensionFieldSets { for (uint8_t i = 0; i < other.mFieldSetsCount; i++) { - this->mEFS[i] = other.mEFS[i]; + this->mFieldSets[i] = other.mFieldSets[i]; } mFieldSetsCount = other.mFieldSetsCount; @@ -164,7 +163,7 @@ class ExtensionFieldSetsImpl : public ExtensionFieldSets } protected: - ExtensionFieldSet mFieldSets[kMaxClusterPerScenes]; + ExtensionFieldSet mFieldSets[kMaxClustersPerScene]; uint8_t mFieldSetsCount = 0; }; } // namespace scenes diff --git a/src/app/clusters/scenes/SceneTable.h b/src/app/clusters/scenes/SceneTable.h index cf7e4fcf4caa2c..e0c25bcf0ee60c 100644 --- a/src/app/clusters/scenes/SceneTable.h +++ b/src/app/clusters/scenes/SceneTable.h @@ -33,16 +33,15 @@ typedef uint8_t SceneIndex; typedef uint32_t TransitionTimeMs; typedef uint32_t SceneTransitionTime; -constexpr GroupId kGlobalGroupSceneId = 0x0000; -constexpr SceneIndex kUndefinedSceneIndex = 0xff; -constexpr SceneId kUndefinedSceneId = 0xff; +constexpr GroupId kGlobalGroupSceneId = 0x0000; +constexpr SceneIndex kUndefinedSceneIndex = 0xff; +constexpr SceneId kUndefinedSceneId = 0xff; static constexpr uint8_t kMaxScenesPerFabric = CHIP_CONFIG_SCENES_MAX_PER_FABRIC; static constexpr size_t kIteratorsMax = CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS; static constexpr size_t kSceneNameMaxLength = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH; - -/// @brief SceneHandlers are meant as interface between various clusters and the Scene table. +/// @brief SceneHandlers are meant as interface between various clusters and the Scene table. /// When a scene command involving extension field sets is received, the Scene Table will go through /// the list of handlers to either retrieve, populate or apply those extension field sets. /// @@ -51,7 +50,7 @@ static constexpr size_t kSceneNameMaxLength = CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM /// /// A SceneHandler can handle a single pair, or many such pairs. /// -/// @note If more than one handler claims to handl a specific pair, only one of +/// @note If more than one handler claims to handl a specific pair, only one of /// those handlers will get called when executing actions related to extension field sets on the scene /// table. It is not defined which handler will be selected. @@ -66,20 +65,20 @@ class SceneHandler : public IntrusiveListNodeBase<> /// @param endpoint target endpoint /// @param clusterBuffer Buffer to hold the supported cluster IDs, cannot hold more than /// CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE. The function shall use the reduce_size() method in the event it is supporting - /// less than CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE clusters. virtual void GetSupportedClusters(EndpointId endpoint, Span & clusterBuffer) = 0; /// @brief Returns whether or not a cluster for scenes is supported on an endpoint - + /// /// @param endpoint Target Endpoint ID /// @param cluster Target Cluster ID /// @return true if supported, false if not supported virtual bool SupportsCluster(EndpointId endpoint, ClusterId cluster) = 0; - /// @brief Called when handling AddScene. Allows the handler to filter through the clusters in the command to serialize only the supported ones. - + /// @brief Called when handling AddScene. Allows the handler to filter through the clusters in the command to serialize only + /// the supported ones. + /// /// @param endpoint[in] Endpoint ID /// @param extensionFieldSet[in] ExtensionFieldSets provided by the AddScene Command, pre initialized /// @param cluster[out] Cluster in the Extension field set, filled by the function @@ -92,8 +91,7 @@ class SceneHandler : public IntrusiveListNodeBase<> /// @brief Called when handling StoreScene, and only if the handler supports the given endpoint and cluster. /// /// The implementation must write the actual scene data to store to serializedBytes as described below. - - + /// /// @param endpoint[in] Target Endpoint /// @param cluster[in] Target Cluster /// @param serializedBytes[out] Output buffer, data needs to be writen in there and size adjusted to the size of the data @@ -103,11 +101,11 @@ class SceneHandler : public IntrusiveListNodeBase<> virtual CHIP_ERROR SerializeSave(EndpointId endpoint, ClusterId cluster, MutableByteSpan & serializedBytes) = 0; /// @brief Deserialize an ExtensionFieldSet into a cluster object (e.g. when handling ViewScene). - + /// /// @param endpoint[in] Endpoint ID /// @param cluster[in] Cluster ID to save /// @param serializedBytes[in] ExtensionFieldSet stored in NVM - + /// /// @param extensionFieldSet[out] ExtensionFieldSet in command format /// @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise virtual CHIP_ERROR Deserialize(EndpointId endpoint, ClusterId cluster, const ByteSpan & serializedBytes, @@ -115,11 +113,11 @@ class SceneHandler : public IntrusiveListNodeBase<> app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & extensionFieldSet) = 0; /// @brief Restore a stored scene for the given cluster instance, over timeMs milliseconds (e.g. when handling RecallScene) - + /// /// @param endpoint[in] Endpoint ID /// @param cluster[in] Cluster ID /// @param serializedBytes[in] ExtensionFieldSet stored in NVM - + /// /// @param timeMs[in] Transition time in ms to apply the scene /// @return CHIP_NO_ERROR if successful, CHIP_ERROR value otherwise virtual CHIP_ERROR ApplyScene(EndpointId endpoint, ClusterId cluster, const ByteSpan & serializedBytes, @@ -154,7 +152,6 @@ class SceneTable bool operator==(const SceneStorageId & other) { return (mEndpointId == other.mEndpointId && mGroupId == other.mGroupId && mSceneId == other.mSceneId); - } }; @@ -168,7 +165,7 @@ class SceneTable /// mSceneTransitionTimeSeconds in enhanced scene commands struct SceneData { - char mName[kSceneNameMax] = { 0 }; + char mName[kSceneNameMaxLength] = { 0 }; size_t mNameLength = 0; SceneTransitionTime mSceneTransitionTimeMs = 0; EFStype mExtensionFieldSets; @@ -176,7 +173,6 @@ class SceneTable SceneData(const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0) : mSceneTransitionTimeMs(time) { SetName(sceneName); - } SceneData(EFStype fields, const CharSpan & sceneName = CharSpan(), SceneTransitionTime time = 0) : mSceneTransitionTimeMs(time) @@ -202,7 +198,7 @@ class SceneTable } else { - size_t maxChars = std::min(sceneName.size(), kSceneNameMax); + size_t maxChars = std::min(sceneName.size(), kSceneNameMaxLength); memcpy(mName, sceneName.data(), maxChars); mNameLength = maxChars; } @@ -247,14 +243,12 @@ class SceneTable bool operator==(const SceneTableEntry & other) { return (mStorageId == other.mStorageId && mStorageData == other.mStorageData); - } void operator=(const SceneTableEntry & other) { mStorageId = other.mStorageId; mStorageData = other.mStorageData; - } }; @@ -296,7 +290,6 @@ class SceneTable // Handlers virtual bool HandlerListEmpty() { return mHandlerList.Empty(); } - // SceneHandler * mHandlers[kMaxSceneHandlers] = { nullptr }; IntrusiveList mHandlerList; }; diff --git a/src/app/clusters/scenes/SceneTableImpl.cpp b/src/app/clusters/scenes/SceneTableImpl.cpp index 9a7a69c8492f3a..835c3a9fcc06f3 100644 --- a/src/app/clusters/scenes/SceneTableImpl.cpp +++ b/src/app/clusters/scenes/SceneTableImpl.cpp @@ -90,7 +90,7 @@ struct SceneTableData : public SceneTableEntry, PersistentData { FabricIndex fabric_index = kUndefinedFabricIndex; uint8_t scene_count = 0; - SceneStorageId scene_map[kMaxScenePerFabric]; + SceneStorageId scene_map[kMaxScenesPerFabric]; FabricSceneData() = default; FabricSceneData(FabricIndex fabric) : fabric_index(fabric) {} @@ -156,7 +156,7 @@ struct FabricSceneData : public PersistentData void Clear() override { scene_count = 0; - for (uint8_t i = 0; i < kMaxScenePerFabric; i++) + for (uint8_t i = 0; i < kMaxScenesPerFabric; i++) { scene_map[i].Clear(); } @@ -169,7 +169,7 @@ struct FabricSceneData : public PersistentData ReturnErrorOnFailure(writer.Put(TLV::ContextTag(TagSceneImpl::kSceneCount), scene_count)); // Storing the scene map - for (uint8_t i = 0; i < kMaxScenePerFabric; i++) + for (uint8_t i = 0; i < kMaxScenesPerFabric; i++) { ReturnErrorOnFailure(writer.Put(TLV::ContextTag(TagScene::kEndpointID), (scene_map[i].mEndpointId))); ReturnErrorOnFailure(writer.Put(TLV::ContextTag(TagScene::kGroupID), (scene_map[i].mGroupId))); @@ -215,7 +215,7 @@ struct FabricSceneData : public PersistentData SceneIndex firstFreeIdx = kUndefinedSceneIndex; // storage index if scene not found uint8_t index = 0; - while (index < kMaxScenePerFabric) + while (index < kMaxScenesPerFabric) { if (scene_map[index] == target_scene) { @@ -229,7 +229,7 @@ struct FabricSceneData : public PersistentData index++; } - if (firstFreeIdx < kMaxScenePerFabric) + if (firstFreeIdx < kMaxScenesPerFabric) { idx = firstFreeIdx; return CHIP_ERROR_NOT_FOUND; @@ -379,9 +379,7 @@ CHIP_ERROR DefaultSceneTableImpl::RemoveSceneTableEntryAtPosition(FabricIndex fa /// @param handler Cluster specific handler for extension field sets interaction void DefaultSceneTableImpl::RegisterHandler(SceneHandler * handler) { - mHandlerList.PushFront(handler); - mNumHandlers++; } void DefaultSceneTableImpl::UnregisterHandler(SceneHandler * handler) @@ -389,7 +387,6 @@ void DefaultSceneTableImpl::UnregisterHandler(SceneHandler * handler) // Verify list is populated and handler is not null VerifyOrReturn(!HandlerListEmpty() && !(handler == nullptr)); mHandlerList.Remove(handler); - mNumHandlers--; } void DefaultSceneTableImpl::UnregisterAllHandlers() @@ -399,7 +396,6 @@ void DefaultSceneTableImpl::UnregisterAllHandlers() IntrusiveList::Iterator foo = mHandlerList.begin(); SceneHandler * handle = &(*foo); mHandlerList.Remove(handle); - mNumHandlers--; } } @@ -408,13 +404,12 @@ void DefaultSceneTableImpl::UnregisterAllHandlers() /// @param scene Scene in which the EFS gets populated CHIP_ERROR DefaultSceneTableImpl::SceneSaveEFS(SceneTableEntry & scene) { - if (!HandlerListEmpty()) { uint8_t clusterCount = 0; - clusterId cArray[kMaxClusterPerScenes]; + clusterId cArray[kMaxClustersPerScene]; Span cSpan(cArray); - clusterCount = GetClustersFromEndpoint(scene.mStorageId.mEndpointId, cArray, kMaxClusterPerScenes); + clusterCount = GetClustersFromEndpoint(scene.mStorageId.mEndpointId, cArray, kMaxClustersPerScene); cSpan.reduce_size(clusterCount); for (clusterId cluster : cSpan) { @@ -426,12 +421,11 @@ CHIP_ERROR DefaultSceneTableImpl::SceneSaveEFS(SceneTableEntry & scene) { if (handler.SupportsCluster(scene.mStorageId.mEndpointId, cluster)) { - ReturnErrorOnFailure(iter->SerializeSave(scene.mStorageId.mEndpointId, EFS.mID, EFSSpan)); + ReturnErrorOnFailure(handler.SerializeSave(scene.mStorageId.mEndpointId, EFS.mID, EFSSpan)); EFS.mUsedBytes = static_cast(EFSSpan.size()); ReturnErrorOnFailure(scene.mStorageData.mExtensionFieldSets.InsertFieldSet(EFS)); break; } - iter++; } } } @@ -461,11 +455,11 @@ CHIP_ERROR DefaultSceneTableImpl::SceneApplyEFS(const SceneTableEntry & scene) if (!EFS.IsEmpty()) { IntrusiveList::Iterator iter = mHandlerList.begin(); - while (iter != mHandlerList.end()) + for (auto & handler : mHandlerList) { - if (iter->SupportsCluster(scene.mStorageId.mEndpointId, cluster)) + if (handler.SupportsCluster(scene.mStorageId.mEndpointId, cluster)) { - ReturnErrorOnFailure(iter->ApplyScene(scene.mStorageId.mEndpointId, cluster, EFSSpan, time)); + ReturnErrorOnFailure(handler.ApplyScene(scene.mStorageId.mEndpointId, cluster, EFSSpan, time)); break; } } @@ -483,7 +477,7 @@ CHIP_ERROR DefaultSceneTableImpl::RemoveFabric(FabricIndex fabric_index) CHIP_ERROR err = fabric.Load(mStorage); VerifyOrReturnError(CHIP_NO_ERROR == err || CHIP_ERROR_NOT_FOUND == err, err); - while (idx < kMaxScenePerFabric) + while (idx < kMaxScenesPerFabric) { err = RemoveSceneTableEntryAtPosition(fabric_index, idx); VerifyOrReturnError(CHIP_NO_ERROR == err || CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err, err); @@ -529,7 +523,7 @@ bool DefaultSceneTableImpl::SceneEntryIteratorImpl::Next(SceneTableEntry & outpu VerifyOrReturnError(fabric.Load(mProvider.mStorage) == CHIP_NO_ERROR, false); // looks for next available scene - while (mSceneIndex < kMaxScenePerFabric) + while (mSceneIndex < kMaxScenesPerFabric) { if (fabric.scene_map[mSceneIndex].mEndpointId != kInvalidEndpointId) { diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index 27abf69b7659b6..6bcc8f496bf67f 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -399,41 +399,40 @@ void ResetSceneTable(SceneTable * sceneTable) void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext) { SceneTable * sceneTable = &sSceneTable; - TestSceneHandler tmpHandler[scenes::kMaxClusterPerScenes]; + TestSceneHandler tmpHandler[scenes::kMaxClustersPerScene]; - for (uint8_t i = 0; i < scenes::kMaxClusterPerScenes; i++) + for (uint8_t i = 0; i < scenes::kMaxClustersPerScene; i++) { - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == i); sceneTable->RegisterHandler(&tmpHandler[i]); } // Hanlder order in table : [H0, H1, H2] - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == scenes::kMaxClusterPerScenes); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Removal at beginning sceneTable->UnregisterHandler(&tmpHandler[0]); - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxClusterPerScenes - 1)); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Re-insert sceneTable->RegisterHandler(&tmpHandler[0]); - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxClusterPerScenes)); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Hanlder order in table : [H0, H1, H2] // Removal at the middle sceneTable->UnregisterHandler(&tmpHandler[2]); - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxClusterPerScenes - 1)); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Re-insert sceneTable->RegisterHandler(&tmpHandler[2]); - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxClusterPerScenes)); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Hanlder order in table : [H1, H0, H2] // Removal at the end sceneTable->UnregisterHandler(&tmpHandler[2]); - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxClusterPerScenes - 1)); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Emptying Handler array sceneTable->UnregisterAllHandlers(); // Verify the handler num has been updated properly - NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == 0); + NL_TEST_ASSERT(aSuite, sceneTable->HandlerListEmpty()); } void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) @@ -535,7 +534,7 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) // Test Registering SceneHandler sceneTable->RegisterHandler(&sHandler); - NL_TEST_ASSERT(aSuite, sceneTable->GetHandlerNum() == 1); + NL_TEST_ASSERT(aSuite, !sceneTable->HandlerListEmpty()); // Setup the On Off Extension field set in the expected state from a command reader.Init(OO_list); @@ -853,7 +852,7 @@ void TestRemoveScenes(nlTestSuite * aSuite, void * aContext) // Remove at empty position, shouldn't trigger error NL_TEST_ASSERT(aSuite, - CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntryAtPosition(kFabric1, chip::scenes::kMaxScenePerFabric - 1)); + CHIP_NO_ERROR == sceneTable->RemoveSceneTableEntryAtPosition(kFabric1, chip::scenes::kMaxScenesPerFabric - 1)); iterator = sceneTable->IterateSceneEntries(kFabric1); NL_TEST_ASSERT(aSuite, iterator->Count() == 0); diff --git a/src/app/util/mock/attribute-storage.cpp b/src/app/util/mock/attribute-storage.cpp index a1bef6d8cea299..cd7f7c15888629 100644 --- a/src/app/util/mock/attribute-storage.cpp +++ b/src/app/util/mock/attribute-storage.cpp @@ -61,11 +61,11 @@ EndpointId endpoints[] = { kMockEndpoint1, kMockEndpoint2, kMockEndpoint3 }; uint16_t clusterIndex[] = { 0, 2, 5 }; uint8_t clusterCount[] = { 2, 3, 4 }; ClusterId clusters[] = { MockClusterId(1), MockClusterId(2), MockClusterId(1), MockClusterId(2), MockClusterId(3), - MockClusterId(1), MockClusterId(2), MockClusterId(3), MockClusterId(4) }; + MockClusterId(1), MockClusterId(2), MockClusterId(3), MockClusterId(4) }; uint16_t attributeIndex[] = { 0, 2, 5, 7, 11, 16, 19, 25, 27 }; uint16_t attributeCount[] = { 2, 3, 2, 4, 5, 3, 6, 2, 2 }; AttributeId attributes[] = { - // clang-format off + // clang-format off Clusters::Globals::Attributes::ClusterRevision::Id, Clusters::Globals::Attributes::FeatureMap::Id, Clusters::Globals::Attributes::ClusterRevision::Id, Clusters::Globals::Attributes::FeatureMap::Id, MockAttributeId(1), Clusters::Globals::Attributes::ClusterRevision::Id, Clusters::Globals::Attributes::FeatureMap::Id, @@ -84,14 +84,14 @@ bool mockAttribute1 = true; int16_t mockAttribute2 = 42; uint64_t mockAttribute3 = 0xdeadbeef0000cafe; uint8_t mockAttribute4[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, }; } // namespace @@ -191,15 +191,15 @@ uint8_t emberAfGetClustersFromEndpoint(EndpointId endpoint, ClusterId * clusterL uint8_t cluster_count = emberAfClusterCount(endpoint, server); uint8_t i; - if (cluster_Count > listLen) + if (cluster_count > listLen) { - cluster_Count = listLen; + cluster_count = listLen; } - for (i = 0; i < cluster_Count; i++) + for (i = 0; i < cluster_count; i++) { clusterList[i] = emberAfGetNthClusterId(endpoint, i, server).Value(); } - return cluster_Count; + return cluster_count; } chip::Optional emberAfGetServerAttributeIdByIndex(chip::EndpointId endpoint, chip::ClusterId cluster,