From 3e0a65593555d911e491bf6abea8274e3995f319 Mon Sep 17 00:00:00 2001 From: Cliff Chung <116232729+cliffamzn@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:06:50 -0700 Subject: [PATCH] Apply @bzbarsky-apple's suggestions from code review Co-authored-by: Boris Zbarsky --- .../resource-monitoring-cluster-objects.h | 8 +++++++- .../resource-monitoring-server.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h b/src/app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h index 0ae47e9e6ef8a2..c66125f5ba3543 100644 --- a/src/app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h +++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h @@ -148,7 +148,13 @@ enum class Fields : uint8_t kProductIdentifierValue = 1, }; -class GenericType : protected app::Clusters::HepaFilterMonitoring::Structs::ReplacementProductStruct::Type +// A struct used during reads of the ReplacementProductList to store a single list instance we request +// from the application. +// +// Inherit from an auto-generated struct to pick up the implementation bits, but make +// it private inheritance so people can't accidentally use this struct where the other +// is expected. +class GenericType : private HepaFilterMonitoring::Structs::ReplacementProductStruct::Type { private: ResourceMonitoring::ProductIdentifierTypeEnum productIdentifierType; diff --git a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp index f5f3fa3992c7d2..2634f6e26af11f 100644 --- a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp +++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp @@ -253,7 +253,7 @@ CHIP_ERROR Instance::ReadReplacableProductList(AttributeValueEncoder & aEncoder) CHIP_ERROR err = CHIP_NO_ERROR; if (HasFeature(ResourceMonitoring::Feature::kReplacementProductList)) { - ReplacementProductListManager * productListManagerInstance = Instance::GetReplacementProductListManagerInstance(); + ReplacementProductListManager * productListManagerInstance = GetReplacementProductListManagerInstance(); if (nullptr == productListManagerInstance) { aEncoder.EncodeEmptyList(); @@ -262,7 +262,7 @@ CHIP_ERROR Instance::ReadReplacableProductList(AttributeValueEncoder & aEncoder) productListManagerInstance->Reset(); - err = aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR { + err = aEncoder.EncodeList([productListManagerInstance](const auto & encoder) -> CHIP_ERROR { Attributes::GenericReplacementProductStruct::GenericType replacementProductStruct; CHIP_ERROR iteratorError = CHIP_NO_ERROR; while (CHIP_NO_ERROR == iteratorError)