Skip to content

Commit

Permalink
Switch to using returns and wrap other case in else.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarkowsky committed Mar 21, 2024
1 parent 86efbbc commit 4d22616
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Source/santad/DataLayer/SNTRuleTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,29 +493,29 @@ - (BOOL)addedRulesShouldFlushDecisionCache:(NSArray *)rules {
for (SNTRule *rule in rules) {
// If the rule is a block rule, silent block rule, or a compiler rule check if it already
// exists in the database.
//
//
// If it does not then flush the cache. To ensure that the new rule is honored.
if ((rule.state != SNTRuleStateAllow)) {
if ([db longForQuery:
@"SELECT COUNT(*) FROM rules WHERE identifier=? AND type=? AND state=? LIMIT 1",
rule.identifier, @(rule.type), @(rule.state)] == 0) {
flushDecisionCache = YES;
break;
return;
}
}

// At this point we know the rule is an allowlist rule. Check if it's
// overriding a compiler rule.
} else {
// At this point we know the rule is an allowlist rule. Check if it's
// overriding a compiler rule.

// Skip certificate and TeamID rules as they cannot be compiler rules.
if (rule.type == SNTRuleTypeCertificate || rule.type == SNTRuleTypeTeamID) continue;
// Skip certificate and TeamID rules as they cannot be compiler rules.
if (rule.type == SNTRuleTypeCertificate || rule.type == SNTRuleTypeTeamID) continue;

if ([db longForQuery:@"SELECT COUNT(*) FROM rules WHERE identifier=? AND type IN (?, ?, ?)"
@" AND state=? LIMIT 1",
rule.identifier, @(SNTRuleTypeCDHash), @(SNTRuleTypeBinary),
@(SNTRuleTypeSigningID), @(SNTRuleStateAllowCompiler)] > 0) {
flushDecisionCache = YES;
break;
if ([db longForQuery:@"SELECT COUNT(*) FROM rules WHERE identifier=? AND type IN (?, ?, ?)"
@" AND state=? LIMIT 1",
rule.identifier, @(SNTRuleTypeCDHash), @(SNTRuleTypeBinary),
@(SNTRuleTypeSigningID), @(SNTRuleStateAllowCompiler)] > 0) {
flushDecisionCache = YES;
return;
}
}
}
}];
Expand Down

0 comments on commit 4d22616

Please sign in to comment.