Skip to content

Commit 3561096

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Remove unnecessary null-checks for exchange contexts. (#15370)
The unit tests for this code no longer call it without an exchange context, so we can remove the workarounds. Fixes #8031
1 parent d28538c commit 3561096

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/app/ReadHandler.cpp

+6-16
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange
152152
{
153153
InteractionModelEngine::GetInstance()->GetReportingEngine().OnReportConfirm();
154154
MoveToState(HandlerState::GeneratingReports);
155-
if (mpExchangeCtx)
156-
{
157-
mpExchangeCtx->WillSendMessage();
158-
}
155+
mpExchangeCtx->WillSendMessage();
156+
159157
// Trigger ReportingEngine run for sending next chunk of data.
160158
SuccessOrExit(err = InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun());
161159
}
@@ -363,12 +361,7 @@ CHIP_ERROR ReadHandler::ProcessReadRequest(System::PacketBufferHandle && aPayloa
363361

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

366-
// mpExchangeCtx can be null here due to
367-
// https://github.com/project-chip/connectedhomeip/issues/8031
368-
if (mpExchangeCtx)
369-
{
370-
mpExchangeCtx->WillSendMessage();
371-
}
364+
mpExchangeCtx->WillSendMessage();
372365

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

697690
InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun();
698-
// mpExchangeCtx can be null here due to
699-
// https://github.com/project-chip/connectedhomeip/issues/8031
700-
if (mpExchangeCtx)
701-
{
702-
mpExchangeCtx->WillSendMessage();
703-
}
691+
692+
mpExchangeCtx->WillSendMessage();
693+
704694
return CHIP_NO_ERROR;
705695
}
706696

0 commit comments

Comments
 (0)