From 332471ad8a1ab314fc37a63758e7d4b920755c12 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 25 Jan 2022 10:37:41 -0800 Subject: [PATCH 1/2] Fix reading attribute activeLocale failure --- .../localization-configuration-server.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp index 86fe44249614f6..66ab74724603c9 100644 --- a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp +++ b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp @@ -39,6 +39,8 @@ using namespace chip::app::Clusters::LocalizationConfiguration::Attributes; namespace { +constexpr size_t kMaxActiveLocaleLength = 35; + class LocalizationConfigurationAttrAccess : public AttributeAccessInterface { public: @@ -150,7 +152,9 @@ void emberAfLocalizationConfigurationClusterServerInitCallback(EndpointId endpoi { DeviceLayer::AttributeList supportedLocales; CharSpan validLocale; - MutableCharSpan activeLocale; + + char outBuffer[kMaxActiveLocaleLength] = ""; + MutableCharSpan activeLocale(outBuffer, kMaxActiveLocaleLength); EmberAfStatus status = ActiveLocale::Get(endpoint, activeLocale); VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Failed to read ActiveLocale with error: 0x%02x", status)); From 8c053c088f65c367f8ac36f124cf94534946638c Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 25 Jan 2022 10:57:11 -0800 Subject: [PATCH 2/2] Update src/app/clusters/localization-configuration-server/localization-configuration-server.cpp Co-authored-by: Boris Zbarsky --- .../localization-configuration-server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp index 66ab74724603c9..257676cea7d6bc 100644 --- a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp +++ b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp @@ -153,8 +153,8 @@ void emberAfLocalizationConfigurationClusterServerInitCallback(EndpointId endpoi DeviceLayer::AttributeList supportedLocales; CharSpan validLocale; - char outBuffer[kMaxActiveLocaleLength] = ""; - MutableCharSpan activeLocale(outBuffer, kMaxActiveLocaleLength); + char outBuffer[kMaxActiveLocaleLength]; + MutableCharSpan activeLocale(outBuffer); EmberAfStatus status = ActiveLocale::Get(endpoint, activeLocale); VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Failed to read ActiveLocale with error: 0x%02x", status));