From 1423784d223fb0577ad824cbcd6fa03f3b070069 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 6 Mar 2023 21:56:19 +0000 Subject: [PATCH] Restyled by clang-format --- src/app/clusters/scenes/BUILD.gn | 32 +++++++++++++++++++ .../scenes/ExtensionFieldSetsImpl.cpp | 2 +- src/app/server/BUILD.gn | 7 +--- src/app/server/Server.h | 2 +- src/app/tests/TestSceneTable.cpp | 11 ++++--- src/lib/core/CHIPConfig.h | 2 +- 6 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 src/app/clusters/scenes/BUILD.gn diff --git a/src/app/clusters/scenes/BUILD.gn b/src/app/clusters/scenes/BUILD.gn new file mode 100644 index 00000000000000..8149460972a9e2 --- /dev/null +++ b/src/app/clusters/scenes/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build_overrides/chip.gni") + +static_library("scenes") { + output_name = "libCHIPScenes" + + sources = [ + "ExtensionFieldSets.h", + "ExtensionFieldSetsImpl.cpp", + "ExtensionFieldSetsImpl.h", + "SceneTable.h", + "SceneTableImpl.cpp", + "SceneTableImpl.h", + ] + + cflags = [ + "-Wconversion", + "-Wshadow", + ] +} diff --git a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp index c4e32832cb85bc..89d33026e9212a 100644 --- a/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp +++ b/src/app/clusters/scenes/ExtensionFieldSetsImpl.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include "ExtensionFieldSetsImpl.h" namespace chip { namespace scenes { diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index c76b20ab650b9d..507f4b2882d570 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -27,12 +27,6 @@ static_library("server") { output_name = "libCHIPAppServer" sources = [ - "../clusters/scenes/ExtensionFieldSets.h", - "../clusters/scenes/ExtensionFieldSetsImpl.cpp", - "../clusters/scenes/ExtensionFieldSetsImpl.h", - "../clusters/scenes/SceneTable.h", - "../clusters/scenes/SceneTableImpl.cpp", - "../clusters/scenes/SceneTableImpl.h", "AclStorage.cpp", "AclStorage.h", "CommissioningModeProvider.h", @@ -56,6 +50,7 @@ static_library("server") { public_deps = [ "${chip_root}/src/app", + "${chip_root}/src/app/clusters/scenes", "${chip_root}/src/lib/address_resolve", "${chip_root}/src/lib/dnssd", "${chip_root}/src/messaging", diff --git a/src/app/server/Server.h b/src/app/server/Server.h index a8a1d6064ddba8..e841faf3bc70b8 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -578,7 +578,7 @@ class Server app::SubscriptionResumptionStorage * mSubscriptionResumptionStorage; Credentials::CertificateValidityPolicy * mCertificateValidityPolicy; Credentials::GroupDataProvider * mGroupsProvider; - scenes::SceneTable * mSceneTable; + scenes::SceneTable * mSceneTable = nullptr; Crypto::SessionKeystore * mSessionKeystore; app::DefaultAttributePersistenceProvider mAttributePersister; GroupDataProviderListener mListener; diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index 248d2e9c7772c6..f577bf3c4c1f18 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -183,11 +183,13 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl { case ON_OFF_CID: err = CHIP_NO_ERROR; + // Warning: OO_buffer needs to be populated before calling this function memcpy(serialisedBytes.data(), OO_buffer, scenes::kMaxFieldsPerCluster); serialisedBytes.reduce_size(15); // Used memory for OnOff TLV break; case LV_CTR_CID: err = CHIP_NO_ERROR; + // Warning: LC_buffer needs to be populated before calling this function memcpy(serialisedBytes.data(), LC_buffer, scenes::kMaxFieldsPerCluster); serialisedBytes.reduce_size(27); // Used memory for Level Control TLV break; @@ -201,11 +203,13 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl { case ON_OFF_CID: err = CHIP_NO_ERROR; + // Warning: OO_buffer needs to be populated before calling this function memcpy(serialisedBytes.data(), OO_buffer, scenes::kMaxFieldsPerCluster); serialisedBytes.reduce_size(15); // Used memory for OnOff TLV break; case CC_CTR_CID: err = CHIP_NO_ERROR; + // Warning: CC_buffer needs to be populated before calling this function memcpy(serialisedBytes.data(), CC_buffer, scenes::kMaxFieldsPerCluster); serialisedBytes.reduce_size(99); // Used memory for Color Control TLV break; @@ -272,7 +276,7 @@ class TestSceneHandler : public scenes::DefaultSceneHandlerImpl } } - return CHIP_NO_ERROR; + return err; } }; @@ -295,11 +299,10 @@ void TestHandlerRegistration(nlTestSuite * aSuite, void * aContext) { NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == i); NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->RegisterHandler(&tmpHandler[i])); - printf("Handler : %d | Address : %p \n", i, &tmpHandler[i]); } NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == scenes::kMaxSceneHandlers); - // Removal at begining + // Removal at beginning NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->UnregisterHandler(&tmpHandler[0])); NL_TEST_ASSERT(aSuite, sceneTable->mNumHandlers == static_cast(scenes::kMaxSceneHandlers - 1)); // Confirm array was compressed and last position is now null @@ -669,7 +672,7 @@ void TestRemoveScenes(nlTestSuite * aSuite, void * aContext) NL_TEST_ASSERT(aSuite, scene == scene10); iterator->Release(); - // Adde scene in middle, a spot should have been freed + // Add scene in middle, a spot should have been freed NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == sceneTable->SetSceneTableEntry(kFabric1, scene9)); iterator = sceneTable->IterateSceneEntry(kFabric1); NL_TEST_ASSERT(aSuite, iterator->Count() == 8); diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index e549e67924207d..35fd670fa1c687 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1379,7 +1379,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_SCENES_TABLE_UNUSED_ENDPOINT_ID 0x00 #endif /** - * @brief The maximum number of scenes according to spec + * @brief The minimum number of scenes to support according to spec */ #ifndef CHIP_CONFIG_SCENES_MAX_NUMBER #define CHIP_CONFIG_SCENES_MAX_NUMBER 16