Skip to content

Commit 7050f0e

Browse files
[ESP32] Modify Return Error Code for GetLogForIntent() method in DiagnosticLogsProviderDelegate (project-chip#36952)
* fix: remove verifyorreturn statement after collectlog * diagnostic-logs-provider: update EndLogCollection() method documentation - modify the return value logic
1 parent 6a86a58 commit 7050f0e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ CHIP_ERROR LogProvider::GetLogForIntent(IntentEnum intent, MutableByteSpan & out
6262
VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0));
6363

6464
bool unusedOutIsEndOfLog;
65-
err = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog);
66-
VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0));
65+
CHIP_ERROR collectErr = CollectLog(sessionHandle, outBuffer, unusedOutIsEndOfLog);
66+
VerifyOrDo(collectErr == CHIP_NO_ERROR, outBuffer.reduce_size(0));
6767

68-
err = EndLogCollection(sessionHandle, err);
69-
VerifyOrReturnError(CHIP_NO_ERROR == err, err, outBuffer.reduce_size(0));
68+
CHIP_ERROR endErr = EndLogCollection(sessionHandle, collectErr);
7069

71-
return CHIP_NO_ERROR;
70+
return (collectErr != CHIP_NO_ERROR) ? collectErr : endErr;
7271
}
7372

7473
size_t LogProvider::GetSizeForIntent(IntentEnum intent)
@@ -293,7 +292,7 @@ CHIP_ERROR LogProvider::EndLogCollection(LogSessionHandle sessionHandle, CHIP_ER
293292
Platform::MemoryFree(context);
294293
mSessionContextMap.erase(sessionHandle);
295294

296-
return error;
295+
return CHIP_NO_ERROR;
297296
}
298297

299298
CHIP_ERROR LogProvider::CollectLog(LogSessionHandle sessionHandle, MutableByteSpan & outBuffer, bool & outIsEndOfLog)

src/app/clusters/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class DiagnosticLogsProviderDelegate
7878
* @param[in] error A CHIP_ERROR value indicating the reason for ending the log collection.
7979
* It is permissible to pass CHIP_NO_ERROR to indicate normal termination.
8080
* @return CHIP_ERROR_NOT_IMPLEMENTED by default unless overridden.
81+
* CHIP_NO_ERROR on successful termination of the log collection.
82+
* Appropriate CHIP_ERROR code if an error occurs while ending the log collection.
8183
*
8284
*/
8385
virtual CHIP_ERROR EndLogCollection(LogSessionHandle sessionHandle, CHIP_ERROR error)

0 commit comments

Comments
 (0)