From 7050f0ef2d25c9e7b7f5ff257be5cbcab81df8c0 Mon Sep 17 00:00:00 2001 From: Mahesh <92411857+pimpalemahesh@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:37:52 +0530 Subject: [PATCH] [ESP32] Modify Return Error Code for GetLogForIntent() method in DiagnosticLogsProviderDelegate (#36952) * fix: remove verifyorreturn statement after collectlog * diagnostic-logs-provider: update EndLogCollection() method documentation - modify the return value logic --- .../main/diagnostic-logs-provider-delegate-impl.cpp | 11 +++++------ .../DiagnosticLogsProviderDelegate.h | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp index 705c2f653c9d8f..3160bf71e12574 100644 --- a/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp +++ b/examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp @@ -62,13 +62,12 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); bool unusedOutIsEndOfLog; - err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); - VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + CHIP_ERROR collectErr = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog); + VerifyOrDo(collectErr == CHIP_NO_ERROR, outBuffer.reduce_size(0)); - err = EndLogCollection(sessionHandle, err); - VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0)); + CHIP_ERROR endErr = EndLogCollection(sessionHandle, collectErr); - return CHIP_NO_ERROR; + return (collectErr != CHIP_NO_ERROR) ? collectErr : endErr; } size_t LogProvider::GetSizeForIntent(IntentEnum intent) @@ -293,7 +292,7 @@ CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ER Platform::MemoryFree(context); mSessionContextMap.erase(sessionHandle); - return error; + return CHIP_NO_ERROR; } CHIP_ERROR LogProvider::CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog) diff --git a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h index f3076eb63be810..289c524a9574f3 100644 --- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h +++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h @@ -78,6 +78,8 @@ class DiagnosticLogsProviderDelegate * @param[in] error A CHIP_ERROR value indicating the reason for ending the log collection. * It is permissible to pass CHIP_NO_ERROR to indicate normal termination. * @return CHIP_ERROR_NOT_IMPLEMENTED by default unless overridden. + * CHIP_NO_ERROR on successful termination of the log collection. + * Appropriate CHIP_ERROR code if an error occurs while ending the log collection. * */ virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error)