Skip to content

Commit

Permalink
[ESP32] Modify Return Error Code for GetLogForIntent() method in Diag…
Browse files Browse the repository at this point in the history
…nosticLogsProviderDelegate (#36952)

* fix: remove verifyorreturn statement after collectlog

* diagnostic-logs-provider: update EndLogCollection() method documentation
- modify the return value logic
  • Loading branch information
pimpalemahesh authored Jan 7, 2025
1 parent 6a86a58 commit 7050f0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7050f0e

Please sign in to comment.