Skip to content

Commit d88aafe

Browse files
committed
Use operator*/-> for optional value access after has_value has been called
1 parent 0302f19 commit d88aafe

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/app/CommandHandler.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ CHIP_ERROR CommandHandler::PrepareInvokeResponseCommand(const ConcreteCommandPat
592592
auto commandPathRegistryEntry = GetCommandPathRegistry().Find(aPrepareParameters.mRequestCommandPath);
593593
VerifyOrReturnValue(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
594594

595-
return PrepareInvokeResponseCommand(commandPathRegistryEntry.value(), aResponseCommandPath,
595+
return PrepareInvokeResponseCommand(*commandPathRegistryEntry, aResponseCommandPath,
596596
aPrepareParameters.mStartOrEndDataStruct);
597597
}
598598

@@ -612,7 +612,7 @@ CHIP_ERROR CommandHandler::PrepareCommand(const ConcreteCommandPath & aResponseC
612612
auto commandPathRegistryEntry = GetCommandPathRegistry().GetFirstEntry();
613613
VerifyOrReturnValue(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
614614

615-
return PrepareInvokeResponseCommand(commandPathRegistryEntry.value(), aResponseCommandPath, aStartDataStruct);
615+
return PrepareInvokeResponseCommand(*commandPathRegistryEntry, aResponseCommandPath, aStartDataStruct);
616616
}
617617

618618
CHIP_ERROR CommandHandler::PrepareInvokeResponseCommand(const CommandPathRegistryEntry & apCommandPathRegistryEntry,
@@ -677,7 +677,7 @@ CHIP_ERROR CommandHandler::FinishCommand(bool aStartDataStruct)
677677

678678
if (mRefForResponse.has_value())
679679
{
680-
ReturnErrorOnFailure(commandData.Ref(mRefForResponse.value()));
680+
ReturnErrorOnFailure(commandData.Ref(*mRefForResponse));
681681
}
682682

683683
ReturnErrorOnFailure(commandData.EndOfCommandDataIB());
@@ -700,7 +700,7 @@ CHIP_ERROR CommandHandler::PrepareStatus(const ConcreteCommandPath & aCommandPat
700700

701701
auto commandPathRegistryEntry = GetCommandPathRegistry().Find(aCommandPath);
702702
VerifyOrReturnError(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
703-
mRefForResponse = commandPathRegistryEntry.value().ref;
703+
mRefForResponse = commandPathRegistryEntry->ref;
704704

705705
MoveToState(State::Preparing);
706706
InvokeResponseIBs::Builder & invokeResponses = mInvokeResponseBuilder.GetInvokeResponses();
@@ -722,7 +722,7 @@ CHIP_ERROR CommandHandler::FinishStatus()
722722
CommandStatusIB::Builder & commandStatus = mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetStatus();
723723
if (mRefForResponse.has_value())
724724
{
725-
ReturnErrorOnFailure(commandStatus.Ref(mRefForResponse.value()));
725+
ReturnErrorOnFailure(commandStatus.Ref(*mRefForResponse));
726726
}
727727

728728
ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetStatus().EndOfCommandStatusIB());

src/app/tests/TestCommandInteraction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void TestCommandInteraction::GenerateInvokeResponse(nlTestSuite * apSuite, void
540540

541541
if (aCommandRef.has_value())
542542
{
543-
NL_TEST_ASSERT(apSuite, commandDataIBBuilder.Ref(aCommandRef.value()) == CHIP_NO_ERROR);
543+
NL_TEST_ASSERT(apSuite, commandDataIBBuilder.Ref(*aCommandRef) == CHIP_NO_ERROR);
544544
}
545545

546546
commandDataIBBuilder.EndOfCommandDataIB();

0 commit comments

Comments
 (0)