Skip to content

Commit

Permalink
Remove unnecessary null-checks for exchange contexts. (#15370)
Browse files Browse the repository at this point in the history
The unit tests for this code no longer call it without an exchange
context, so we can remove the workarounds.

Fixes #8031
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 8, 2023
1 parent d28538c commit 3561096
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange
{
InteractionModelEngine::GetInstance()->GetReportingEngine().OnReportConfirm();
MoveToState(HandlerState::GeneratingReports);
if (mpExchangeCtx)
{
mpExchangeCtx->WillSendMessage();
}
mpExchangeCtx->WillSendMessage();

// Trigger ReportingEngine run for sending next chunk of data.
SuccessOrExit(err = InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun());
}
Expand Down Expand Up @@ -363,12 +361,7 @@ CHIP_ERROR ReadHandler::ProcessReadRequest(System::PacketBufferHandle && aPayloa

ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun());

// mpExchangeCtx can be null here due to
// https://github.com/project-chip/connectedhomeip/issues/8031
if (mpExchangeCtx)
{
mpExchangeCtx->WillSendMessage();
}
mpExchangeCtx->WillSendMessage();

// There must be no code after the WillSendMessage() call that can cause
// this method to return a failure.
Expand Down Expand Up @@ -695,12 +688,9 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP
MoveToState(HandlerState::GeneratingReports);

InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
// mpExchangeCtx can be null here due to
// https://github.com/project-chip/connectedhomeip/issues/8031
if (mpExchangeCtx)
{
mpExchangeCtx->WillSendMessage();
}

mpExchangeCtx->WillSendMessage();

return CHIP_NO_ERROR;
}

Expand Down

0 comments on commit 3561096

Please sign in to comment.