From 13133647fdabd0e86b0973d4273085c381e1a46f Mon Sep 17 00:00:00 2001 From: milanr-q <114670456+milanr-q@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:22:50 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20wrong=20error=20code=20returned=20in=20Bi?= =?UTF-8?q?ndingManager::NotifyBoundClusterCh=E2=80=A6=20(#24209)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix wrong error code returned in BindingManager::NotifyBoundClusterChanged * Review remarks addressed * Error description changed --- src/app/clusters/bindings/BindingManager.cpp | 2 +- src/lib/core/CHIPError.cpp | 3 +++ src/lib/core/CHIPError.h | 8 ++++++++ src/lib/core/tests/TestCHIPErrorStr.cpp | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/bindings/BindingManager.cpp b/src/app/clusters/bindings/BindingManager.cpp index ad13376a0dfe42..97a08ac5ab52d2 100644 --- a/src/app/clusters/bindings/BindingManager.cpp +++ b/src/app/clusters/bindings/BindingManager.cpp @@ -169,7 +169,7 @@ void BindingManager::FabricRemoved(FabricIndex fabricIndex) CHIP_ERROR BindingManager::NotifyBoundClusterChanged(EndpointId endpoint, ClusterId cluster, void * context) { VerifyOrReturnError(mInitParams.mFabricTable != nullptr, CHIP_ERROR_INCORRECT_STATE); - VerifyOrReturnError(mBoundDeviceChangedHandler, CHIP_NO_ERROR); + VerifyOrReturnError(mBoundDeviceChangedHandler != nullptr, CHIP_ERROR_HANDLER_NOT_SET); CHIP_ERROR error = CHIP_NO_ERROR; auto * bindingContext = mPendingNotificationMap.NewPendingNotificationContext(context); diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index 1dc00abcbcf0c8..2e35a3c9628e1b 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -731,6 +731,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_MISSING_URI_SEPARATOR.AsInteger(): desc = "The URI separator is missing"; break; + case CHIP_ERROR_HANDLER_NOT_SET.AsInteger(): + desc = "Callback function or callable object is not set"; + break; } #endif // !CHIP_CONFIG_SHORT_ERROR_STR diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index 5a170519126f2f..0483c4d76abaed 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -2427,6 +2427,14 @@ using CHIP_ERROR = ::chip::ChipError; */ #define CHIP_ERROR_MISSING_URI_SEPARATOR CHIP_CORE_ERROR(0xe0) +/** + * @def CHIP_ERROR_HANDLER_NOT_SET + * + * @brief + * Callback function or callable object is not set + */ +#define CHIP_ERROR_HANDLER_NOT_SET CHIP_CORE_ERROR(0xe1) + // clang-format on // !!!!! IMPORTANT !!!!! If you add new CHIP errors, please update the translation diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index 1ea3c8834897e5..901dbf4e404a73 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -266,6 +266,7 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_BUSY, CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_REPORT_IB, CHIP_ERROR_IM_MALFORMED_EVENT_STATUS_IB, + CHIP_ERROR_HANDLER_NOT_SET, }; // clang-format on