[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
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 705c2f6..3160bf7 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 @@
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 @@
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 f3076eb..289c524 100644
--- a/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h
+++ b/src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h
@@ -78,6 +78,8 @@
* @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)