Skip to content

Commit

Permalink
Clean up conditionnal checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Mar 17, 2024
1 parent 94cd275 commit 4214049
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,30 +335,20 @@ bool InteractionModelEngine::SubjectHasActiveSubscription(FabricIndex aFabricInd
{
bool isActive = false;
mReadHandlers.ForEachActiveObject([aFabricIndex, subjectID, &isActive](ReadHandler * handler) {
if (!handler->IsType(ReadHandler::InteractionType::Subscribe))
{
return Loop::Continue;
}
VerifyOrReturnValue(handler->IsType(ReadHandler::InteractionType::Subscribe), Loop::Continue);

Access::SubjectDescriptor subject = handler->GetSubjectDescriptor();
if (subject.fabricIndex != aFabricIndex)
{
return Loop::Continue;
}
VerifyOrReturnValue(subject.fabricIndex == aFabricIndex, Loop::Continue);

if (subject.authMode == Access::AuthMode::kCase)
{
if (subject.cats.CheckSubjectAgainstCATs(subjectID) || subjectID == subject.subject)
{
isActive = handler->IsActiveSubscription();

// Exit loop only if isActive is set to true
// Otherwise keep looking for another subscription that could
// match the subject
if (isActive)
{
return Loop::Break;
}
// Exit loop only if isActive is set to true.
// Otherwise keep looking for another subscription that could match the subject.
VerifyOrReturnValue(!isActive, Loop::Break);
}
}

Expand Down

0 comments on commit 4214049

Please sign in to comment.