Skip to content

Commit

Permalink
Remove unnecessary null-checks for exchange contexts.
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 project-chip#8031
  • Loading branch information
bzbarsky-apple committed Feb 19, 2022
1 parent 3f68c3c commit b028193
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 b028193

Please sign in to comment.