mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
Fix clang-tidy modernize-loop-convert findings
This commit is contained in:
parent
49b803c0a8
commit
f3588657bf
56 changed files with 452 additions and 542 deletions
|
@ -106,8 +106,8 @@ RuleHdrTest::RuleHdrTest(RuleHdrTest& h) {
|
|||
|
||||
prefix_vals = h.prefix_vals;
|
||||
|
||||
for ( int j = 0; j < Rule::TYPES; ++j ) {
|
||||
for ( PatternSet* orig_set : h.psets[j] ) {
|
||||
for ( const auto& pset : h.psets ) {
|
||||
for ( PatternSet* orig_set : pset ) {
|
||||
PatternSet* copied_set = new PatternSet;
|
||||
copied_set->re = nullptr;
|
||||
copied_set->ids = orig_set->ids;
|
||||
|
@ -133,8 +133,8 @@ RuleHdrTest::~RuleHdrTest() {
|
|||
delete val;
|
||||
delete vals;
|
||||
|
||||
for ( int i = 0; i < Rule::TYPES; ++i ) {
|
||||
for ( auto pset : psets[i] ) {
|
||||
for ( auto& pset_list : psets ) {
|
||||
for ( auto& pset : pset_list ) {
|
||||
delete pset->re;
|
||||
delete pset;
|
||||
}
|
||||
|
@ -515,10 +515,10 @@ static inline bool match_or(const maskedvalue_list& mvals, uint32_t v, FuncT com
|
|||
// Evaluate a prefix list (matches if at least one value matches).
|
||||
template<typename FuncT>
|
||||
static inline bool match_or(const vector<IPPrefix>& prefixes, const IPAddr& a, FuncT comp) {
|
||||
for ( size_t i = 0; i < prefixes.size(); ++i ) {
|
||||
for ( const auto& pfx : prefixes ) {
|
||||
IPAddr masked(a);
|
||||
masked.Mask(prefixes[i].LengthIPv6());
|
||||
if ( comp(masked, prefixes[i].Prefix()) )
|
||||
masked.Mask(pfx.LengthIPv6());
|
||||
if ( comp(masked, pfx.Prefix()) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -538,10 +538,10 @@ static inline bool match_not_and(const maskedvalue_list& mvals, uint32_t v, Func
|
|||
// Evaluate a prefix list (doesn't match if any value matches).
|
||||
template<typename FuncT>
|
||||
static inline bool match_not_and(const vector<IPPrefix>& prefixes, const IPAddr& a, FuncT comp) {
|
||||
for ( size_t i = 0; i < prefixes.size(); ++i ) {
|
||||
for ( const auto& pfx : prefixes ) {
|
||||
IPAddr masked(a);
|
||||
masked.Mask(prefixes[i].LengthIPv6());
|
||||
if ( comp(masked, prefixes[i].Prefix()) )
|
||||
masked.Mask(pfx.LengthIPv6());
|
||||
if ( comp(masked, pfx.Prefix()) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1083,12 +1083,12 @@ void RuleMatcher::GetStats(Stats* stats, RuleHdrTest* hdr_test) const {
|
|||
|
||||
DFA_State_Cache::Stats cstats;
|
||||
|
||||
for ( int i = 0; i < Rule::TYPES; ++i ) {
|
||||
for ( const auto& set : hdr_test->psets[i] ) {
|
||||
assert(set->re);
|
||||
for ( const auto& pset_list : hdr_test->psets ) {
|
||||
for ( const auto& pset : pset_list ) {
|
||||
assert(pset->re);
|
||||
|
||||
++stats->matchers;
|
||||
set->re->DFA()->Cache()->GetStats(&cstats);
|
||||
pset->re->DFA()->Cache()->GetStats(&cstats);
|
||||
|
||||
stats->dfa_states += cstats.dfa_states;
|
||||
stats->computed += cstats.computed;
|
||||
|
@ -1183,7 +1183,9 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to, vector<IPPrefi
|
|||
v->AsSubNet().Prefix().GetBytes(&n);
|
||||
v->AsSubNetVal()->Mask().CopyIPv6(m);
|
||||
|
||||
for ( unsigned int i = 0; i < 4; ++i )
|
||||
// Intentionally leaving this as a normal loop because it's more descriptive.
|
||||
// NOLINTNEXTLINE(modernize-loop-convert)
|
||||
for ( unsigned int i = 0; i < 4; i++ )
|
||||
m[i] = ntohl(m[i]);
|
||||
|
||||
bool is_v4_mask = m[0] == 0xffffffff && m[1] == m[0] && m[2] == m[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue