diff --git a/benchmarks/benchmarks.cpp b/benchmarks/benchmarks.cpp index e48652e9..3c1a0bab 100644 --- a/benchmarks/benchmarks.cpp +++ b/benchmarks/benchmarks.cpp @@ -63,12 +63,10 @@ static void run_benchmarks(int size, int loops, int max_matches, InitFunc &&init, BenchFunc &&func) { init(bench); double total_sec = 0.0; - u64a total_size = 0; - double bw = 0.0; - double avg_bw = 0.0; double max_bw = 0.0; double avg_time = 0.0; if (max_matches) { + double avg_bw = 0.0; int pos = 0; for (int j = 0; j < max_matches - 1; j++) { bench.buf[pos] = 'b'; @@ -90,7 +88,7 @@ static void run_benchmarks(int size, int loops, int max_matches, total_sec += dt; /*convert microseconds to seconds*/ /*calculate bandwidth*/ - bw = (actual_size / dt) * 1000000.0 / 1048576.0; + double bw = (actual_size / dt) * 1000000.0 / 1048576.0; /*std::cout << "act_size = " << act_size << std::endl; std::cout << "dt = " << dt << std::endl; std::cout << "bw = " << bw << std::endl;*/ @@ -107,6 +105,7 @@ static void run_benchmarks(int size, int loops, int max_matches, printf("%-18s, %-12d, %-10d, %-6d, %-10.3f, %-9.3f, %-8.3f, %-7.3f\n", bench.label, max_matches, size ,loops, total_sec, avg_time, max_bw, avg_bw); } else { + u64a total_size = 0; auto start = std::chrono::steady_clock::now(); for (int i = 0; i < loops; i++) { const u8 *res = func(bench); diff --git a/examples/patbench.cc b/examples/patbench.cc index 1f965f13..b1ec2766 100644 --- a/examples/patbench.cc +++ b/examples/patbench.cc @@ -605,8 +605,9 @@ double eval_set(Benchmark &bench, Sigdata &sigs, unsigned int mode, scan_time = measure_stream_time(bench, repeatCount); } size_t bytes = bench.bytes(); - size_t matches = bench.matches(); + if (diagnose) { + size_t matches = bench.matches(); std::ios::fmtflags f(cout.flags()); cout << "Scan time " << std::fixed << std::setprecision(3) << scan_time << " sec, Scanned " << bytes * repeatCount << " bytes, Throughput " diff --git a/src/crc32.c b/src/crc32.c index 19c7b7fa..ca5b5fed 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -542,14 +542,13 @@ u32 crc32c_sb8_64_bit(u32 running_crc, const unsigned char* p_buf, // Main aligned loop, processes eight bytes at a time. - u32 term1, term2; for (size_t li = 0; li < running_length/8; li++) { u32 block = *(const u32 *)p_buf; crc ^= block; p_buf += 4; - term1 = crc_tableil8_o88[crc & 0x000000FF] ^ + u32 term1 = crc_tableil8_o88[crc & 0x000000FF] ^ crc_tableil8_o80[(crc >> 8) & 0x000000FF]; - term2 = crc >> 16; + u32 term2 = crc >> 16; crc = term1 ^ crc_tableil8_o72[term2 & 0x000000FF] ^ crc_tableil8_o64[(term2 >> 8) & 0x000000FF]; diff --git a/src/nfa/castle.c b/src/nfa/castle.c index 4c103636..355d7951 100644 --- a/src/nfa/castle.c +++ b/src/nfa/castle.c @@ -489,7 +489,6 @@ char castleMatchLoop(const struct Castle *c, const u64a begin, const u64a end, // full_state (scratch). u64a offset = end; // min offset of next match - u32 activeIdx = 0; mmbit_clear(matching, c->numRepeats); if (c->exclusive) { u8 *active = (u8 *)stream_state; @@ -497,7 +496,7 @@ char castleMatchLoop(const struct Castle *c, const u64a begin, const u64a end, for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID); i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) { u8 *cur = active + i * c->activeIdxSize; - activeIdx = partial_load_u32(cur, c->activeIdxSize); + u32 activeIdx = partial_load_u32(cur, c->activeIdxSize); u64a match = subCastleNextMatch(c, full_state, stream_state, loc, activeIdx); set_matching(c, match, groups, matching, c->numGroups, i, diff --git a/src/nfa/repeatcompile.cpp b/src/nfa/repeatcompile.cpp index 60b51352..d9544675 100644 --- a/src/nfa/repeatcompile.cpp +++ b/src/nfa/repeatcompile.cpp @@ -94,9 +94,6 @@ u32 repeatRecurTable(struct RepeatStateInfo *info, const depth &repeatMax, static u32 findOptimalPatchSize(struct RepeatStateInfo *info, const depth &repeatMax, const u32 minPeriod, u32 rv) { - u32 cnt = 0; - u32 patch_bits = 0; - u32 total_size = 0; u32 min = ~0U; u32 patch_len = 0; @@ -105,11 +102,11 @@ u32 findOptimalPatchSize(struct RepeatStateInfo *info, const depth &repeatMax, } for (u32 i = minPeriod; i <= rv; i++) { - cnt = ((u32)repeatMax + (i - 1)) / i + 1; + u32 cnt = ((u32)repeatMax + (i - 1)) / i + 1; // no bit packing version - patch_bits = calcPackedBits(info->table[i]); - total_size = (patch_bits + 7U) / 8U * cnt; + u32 patch_bits = calcPackedBits(info->table[i]); + u32 total_size = (patch_bits + 7U) / 8U * cnt; if (total_size < min) { patch_len = i; diff --git a/src/nfagraph/ng_haig.cpp b/src/nfagraph/ng_haig.cpp index bf951a0b..ede0f79b 100644 --- a/src/nfagraph/ng_haig.cpp +++ b/src/nfagraph/ng_haig.cpp @@ -513,12 +513,12 @@ static bool doHaig(const NGHolder &g, som_type som, const vector> &triggers, bool unordered_som, raw_som_dfa *rdfa) { - u32 state_limit = HAIG_FINAL_DFA_STATE_LIMIT; /* haig never backs down from - a fight */ using StateSet = typename Auto::StateSet; vector nfa_state_map; Auto n(g, som, triggers, unordered_som); try { + u32 state_limit = HAIG_FINAL_DFA_STATE_LIMIT; /* haig never backs down from + a fight */ if (!determinise(n, rdfa->states, state_limit, &nfa_state_map)) { DEBUG_PRINTF("state limit exceeded\n"); return false; diff --git a/src/nfagraph/ng_redundancy.cpp b/src/nfagraph/ng_redundancy.cpp index a499a40d..baabf285 100644 --- a/src/nfagraph/ng_redundancy.cpp +++ b/src/nfagraph/ng_redundancy.cpp @@ -636,12 +636,12 @@ bool reversePathReachSubset(const NFAEdge &e, const NFAVertex &dom, NFAVertex start = source(e, g); using RevGraph = boost::reverse_graph; - map vertexColor; // Walk the graph backwards from v, examining each node. We fail (return // false) if we encounter a node with reach NOT a subset of domReach, and // we stop searching at dom. try { + map vertexColor; depth_first_visit(RevGraph(g), start, ReachSubsetVisitor(domReach), make_assoc_property_map(vertexColor), @@ -664,12 +664,12 @@ bool forwardPathReachSubset(const NFAEdge &e, const NFAVertex &dom, } NFAVertex start = target(e, g); - map vertexColor; // Walk the graph forward from v, examining each node. We fail (return // false) if we encounter a node with reach NOT a subset of domReach, and // we stop searching at dom. try { + map vertexColor; depth_first_visit(g, start, ReachSubsetVisitor(domReach), make_assoc_property_map(vertexColor), VertexIs(dom)); diff --git a/src/nfagraph/ng_violet.cpp b/src/nfagraph/ng_violet.cpp index 02461e98..b39cfba2 100644 --- a/src/nfagraph/ng_violet.cpp +++ b/src/nfagraph/ng_violet.cpp @@ -348,10 +348,9 @@ void getSimpleRoseLiterals(const NGHolder &g, bool seeking_anchored, map scores; map> lit_info; - set s; for (auto v : a_dom) { - s = getLiteralSet(g, v, true); /* RHS will take responsibility for any + set s = getLiteralSet(g, v, true); /* RHS will take responsibility for any revisits to the target vertex */ if (s.empty()) { @@ -2868,7 +2867,6 @@ static bool splitForImplementability(RoseInGraph &vg, NGHolder &h, const vector &edges, const CompileContext &cc) { - vector> succ_lits; DEBUG_PRINTF("trying to split %s with %zu vertices on %zu edges\n", to_string(h.kind).c_str(), num_vertices(h), edges.size()); @@ -2877,6 +2875,7 @@ bool splitForImplementability(RoseInGraph &vg, NGHolder &h, } if (!generates_callbacks(h)) { + vector> succ_lits; for (const auto &e : edges) { const auto &lit = vg[target(e, vg)].s; u32 delay = vg[e].graph_lag; @@ -2889,8 +2888,8 @@ bool splitForImplementability(RoseInGraph &vg, NGHolder &h, } unique_ptr split; - bool last_chance = true; if (h.kind == NFA_PREFIX) { + bool last_chance = true; auto depths = calcDepths(h); split = findBestPrefixSplit(h, depths, vg, edges, last_chance, cc); diff --git a/src/parser/ComponentAlternation.cpp b/src/parser/ComponentAlternation.cpp index e38c9ce7..c4bad672 100644 --- a/src/parser/ComponentAlternation.cpp +++ b/src/parser/ComponentAlternation.cpp @@ -109,20 +109,20 @@ void ComponentAlternation::append(unique_ptr component) { vector ComponentAlternation::first() const { // firsts come from all our subcomponents in position order. This will // maintain left-to-right priority order. - vector firsts, subfirsts; + vector firsts; for (const auto &c : children) { - subfirsts = c->first(); + vector subfirsts = c->first(); firsts.insert(firsts.end(), subfirsts.begin(), subfirsts.end()); } return firsts; } vector ComponentAlternation::last() const { - vector lasts, sublasts; + vector lasts; for (const auto &c : children) { - sublasts = c->last(); + vector sublasts = c->last(); lasts.insert(lasts.end(), sublasts.begin(), sublasts.end()); } return lasts; diff --git a/src/parser/ComponentSequence.cpp b/src/parser/ComponentSequence.cpp index 2b78177b..f5200206 100644 --- a/src/parser/ComponentSequence.cpp +++ b/src/parser/ComponentSequence.cpp @@ -157,10 +157,10 @@ void ComponentSequence::finalize() { } vector ComponentSequence::first() const { - vector firsts, subfirsts; + vector firsts; for (const auto &c : children) { - subfirsts = c->first(); + vector subfirsts = c->first(); replaceEpsilons(firsts, subfirsts); if (!c->empty()) { break; @@ -229,12 +229,12 @@ void applyEpsilonVisits(vector &lasts, } vector ComponentSequence::last() const { - vector lasts, sublasts; + vector lasts; vector visits(1); auto i = children.rbegin(), e = children.rend(); for (; i != e; ++i) { - sublasts = (*i)->last(); + vector sublasts = (*i)->last(); applyEpsilonVisits(sublasts, visits); lasts.insert(lasts.end(), sublasts.begin(), sublasts.end()); if ((*i)->empty()) { diff --git a/src/parser/logical_combination.cpp b/src/parser/logical_combination.cpp index a37f4e5f..bbe41b83 100644 --- a/src/parser/logical_combination.cpp +++ b/src/parser/logical_combination.cpp @@ -260,14 +260,14 @@ void ParsedLogical::parseLogicalCombination(unsigned id, const char *logical, u32 ekey, u64a min_offset, u64a max_offset) { u32 ckey = getCombKey(id); - vector op_stack; vector subid_stack; u32 lkey_start = INVALID_LKEY; // logical operation's lkey - u32 paren = 0; // parentheses u32 digit = (u32)-1; // digit start offset, invalid offset is -1 u32 subid = (u32)-1; u32 i; try { + vector op_stack; + u32 paren = 0; // parentheses for (i = 0; logical[i]; i++) { if (isdigit(logical[i])) { if (digit == (u32)-1) { // new digit start diff --git a/src/rose/rose_build_add_mask.cpp b/src/rose/rose_build_add_mask.cpp index c3736f62..7e0e00b0 100644 --- a/src/rose/rose_build_add_mask.cpp +++ b/src/rose/rose_build_add_mask.cpp @@ -393,8 +393,9 @@ bool validateTransientMask(const vector &mask, bool anchored, none_of(begin(lits), end(lits), mixed_sensitivity)); // Build the HWLM literal mask. - vector msk, cmp; + vector msk; if (grey.roseHamsterMasks) { + vector cmp; buildLiteralMask(mask, msk, cmp, delay); } diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 2df3b3a3..639edddc 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -2251,10 +2251,9 @@ vector buildSuffixEkeyLists(const RoseBuildImpl &build, build_context &bc, /* for each outfix also build elists */ for (const auto &outfix : build.outfixes) { - u32 qi = outfix.get_queue(); set ekeys = reportsToEkeys(all_reports(outfix), build.rm); - if (!ekeys.empty()) { + u32 qi = outfix.get_queue(); qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()}; } } diff --git a/src/rose/rose_build_misc.cpp b/src/rose/rose_build_misc.cpp index d3ff236d..de0ae706 100644 --- a/src/rose/rose_build_misc.cpp +++ b/src/rose/rose_build_misc.cpp @@ -1004,9 +1004,9 @@ bool hasOrphanedTops(const RoseBuildImpl &build) { for (auto v : vertices_range(g)) { if (g[v].left) { - set &tops = leftfixes[g[v].left]; if (!build.isRootSuccessor(v)) { // Tops for infixes come from the in-edges. + set &tops = leftfixes[g[v].left]; for (const auto &e : in_edges_range(v, g)) { tops.insert(g[e].rose_top); } diff --git a/src/util/arch/common/bitutils.h b/src/util/arch/common/bitutils.h index e5ab0d05..897c9197 100644 --- a/src/util/arch/common/bitutils.h +++ b/src/util/arch/common/bitutils.h @@ -155,13 +155,13 @@ u32 compress32_impl_c(u32 x, u32 m) { return 0; } - u32 mk, mp, mv, t; + u32 mk, mv; x &= m; // clear irrelevant bits mk = ~m << 1; // we will count 0's to right for (u32 i = 0; i < 5; i++) { - mp = mk ^ (mk << 1); + u32 mp = mk ^ (mk << 1); mp ^= mp << 2; mp ^= mp << 4; mp ^= mp << 8; @@ -169,7 +169,7 @@ u32 compress32_impl_c(u32 x, u32 m) { mv = mp & m; // bits to move m = (m ^ mv) | (mv >> (1 << i)); // compress m - t = x & mv; + u32 t = x & mv; x = (x ^ t) | (t >> (1 << i)); // compress x mk = mk & ~mp; } @@ -239,14 +239,14 @@ u32 expand32_impl_c(u32 x, u32 m) { return 0; } - u32 m0, mk, mp, mv, t; + u32 m0, mk, mv; u32 array[5]; m0 = m; // save original mask mk = ~m << 1; // we will count 0's to right for (int i = 0; i < 5; i++) { - mp = mk ^ (mk << 1); // parallel suffix + u32 mp = mk ^ (mk << 1); // parallel suffix mp = mp ^ (mp << 2); mp = mp ^ (mp << 4); mp = mp ^ (mp << 8); @@ -259,7 +259,7 @@ u32 expand32_impl_c(u32 x, u32 m) { for (int i = 4; i >= 0; i--) { mv = array[i]; - t = x << (1 << i); + u32 t = x << (1 << i); x = (x & ~mv) | (t & mv); } @@ -409,7 +409,7 @@ u64a pdep64_impl_c(u64a x, u64a _m) { u64a result = 0x0UL; const u64a mask = 0x8000000000000000UL; u64a m = _m; - u64a c, t; + u64a p; /* The pop-count of the mask gives the number of the bits from @@ -421,8 +421,8 @@ u64a pdep64_impl_c(u64a x, u64a _m) { each mask bit as it is processed. */ while (m != 0) { - c = __builtin_clzl (m); - t = x << (p - c); + u64a c = __builtin_clzl (m); + u64a t = x << (p - c); m ^= (mask >> c); result |= (t & (mask >> c)); p++; diff --git a/src/util/dump_charclass.cpp b/src/util/dump_charclass.cpp index df308dec..2243fcbd 100644 --- a/src/util/dump_charclass.cpp +++ b/src/util/dump_charclass.cpp @@ -178,9 +178,9 @@ size_t describeClassInt(ostream &os, const CharReach &incr, size_t maxLength, // Render charclass as a series of ranges size_t c_start = cr.find_first(); - size_t c = c_start, c_last = 0; + size_t c = c_start; while (c != CharReach::npos) { - c_last = c; + size_t c_last = c; c = cr.find_next(c); if (c != c_last + 1 || c_last == 0xff) { describeRange(os, c_start, c_last, out_type); diff --git a/tools/hsbench/engine_chimera.h b/tools/hsbench/engine_chimera.h index 187dec8c..52ec1179 100644 --- a/tools/hsbench/engine_chimera.h +++ b/tools/hsbench/engine_chimera.h @@ -66,32 +66,32 @@ public: explicit EngineChimera(ch_database_t *db, CompileCHStats cs); ~EngineChimera(); - std::unique_ptr makeContext() const; + std::unique_ptr makeContext() const override; void scan(const char *data, unsigned int len, unsigned int id, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; void scan_vectored(const char *const *data, const unsigned int *len, unsigned int count, unsigned int streamId, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; std::unique_ptr streamOpen(EngineContext &ectx, - unsigned id) const; + unsigned id) const override; void streamClose(std::unique_ptr stream, - ResultEntry &result) const; + ResultEntry &result) const override; void streamCompressExpand(EngineStream &stream, - std::vector &temp) const; + std::vector &temp) const override; void streamScan(EngineStream &stream, const char *data, unsigned int len, - unsigned int id, ResultEntry &result) const; + unsigned int id, ResultEntry &result) const override; - void printStats() const; + void printStats() const override; - void printCsvStats() const; + void printCsvStats() const override; - void sqlStats(SqlDB &db) const; + void sqlStats(SqlDB &db) const override; private: ch_database_t *db; diff --git a/tools/hsbench/engine_hyperscan.h b/tools/hsbench/engine_hyperscan.h index afbdf098..ccbc2fa8 100644 --- a/tools/hsbench/engine_hyperscan.h +++ b/tools/hsbench/engine_hyperscan.h @@ -75,32 +75,32 @@ public: explicit EngineHyperscan(hs_database_t *db, CompileHSStats cs); ~EngineHyperscan(); - std::unique_ptr makeContext() const; + std::unique_ptr makeContext() const override; void scan(const char *data, unsigned int len, unsigned int id, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; void scan_vectored(const char *const *data, const unsigned int *len, unsigned int count, unsigned int streamId, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; std::unique_ptr streamOpen(EngineContext &ectx, - unsigned id) const; + unsigned id) const override; void streamClose(std::unique_ptr stream, - ResultEntry &result) const; + ResultEntry &result) const override; void streamCompressExpand(EngineStream &stream, - std::vector &temp) const; + std::vector &temp) const override; void streamScan(EngineStream &stream, const char *data, unsigned int len, - unsigned int id, ResultEntry &result) const; + unsigned int id, ResultEntry &result) const override; - void printStats() const; + void printStats() const override; - void printCsvStats() const; + void printCsvStats() const override; - void sqlStats(SqlDB &db) const; + void sqlStats(SqlDB &db) const override; private: hs_database_t *db; diff --git a/tools/hsbench/engine_pcre.h b/tools/hsbench/engine_pcre.h index 9569bef4..7ae9147f 100644 --- a/tools/hsbench/engine_pcre.h +++ b/tools/hsbench/engine_pcre.h @@ -74,32 +74,32 @@ public: CompilePCREStats cs, int capture_cnt_in); ~EnginePCRE(); - std::unique_ptr makeContext() const; + std::unique_ptr makeContext() const override; void scan(const char *data, unsigned int len, unsigned int id, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; void scan_vectored(const char *const *data, const unsigned int *len, unsigned int count, unsigned int streamId, - ResultEntry &result, EngineContext &ectx) const; + ResultEntry &result, EngineContext &ectx) const override; std::unique_ptr streamOpen(EngineContext &ectx, - unsigned id) const; + unsigned id) const override; void streamClose(std::unique_ptr stream, - ResultEntry &result) const; + ResultEntry &result) const override; void streamCompressExpand(EngineStream &stream, - std::vector &temp) const; + std::vector &temp) const override; void streamScan(EngineStream &stream, const char *data, unsigned int len, - unsigned int id, ResultEntry &result) const; + unsigned int id, ResultEntry &result) const override; - void printStats() const; + void printStats() const override; - void printCsvStats() const; + void printCsvStats() const override; - void sqlStats(SqlDB &db) const; + void sqlStats(SqlDB &db) const override; private: std::vector> dbs; diff --git a/unit/internal/fdr_flood.cpp b/unit/internal/fdr_flood.cpp index 81afbeaa..77d3ff47 100644 --- a/unit/internal/fdr_flood.cpp +++ b/unit/internal/fdr_flood.cpp @@ -488,7 +488,6 @@ TEST_P(FDRFloodp, StreamingMask) { Grey()); CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint); - hwlm_error_t fdrStatus; const u32 cnt4 = dataSize - 4 + 1; for (u32 streamChunk = 1; streamChunk <= 16; streamChunk *= 2) { @@ -496,7 +495,7 @@ TEST_P(FDRFloodp, StreamingMask) { const u8 *d = data.data(); // reference past the end of fake history to allow headroom const u8 *fhist = fake_history.data() + fake_history_size; - fdrStatus = fdrExecStreaming(fdr.get(), fhist, 0, d, streamChunk, 0, + hwlm_error_t fdrStatus = fdrExecStreaming(fdr.get(), fhist, 0, d, streamChunk, 0, countCallback, &scratch, HWLM_ALL_GROUPS); ASSERT_EQ(0, fdrStatus); diff --git a/unit/internal/repeat.cpp b/unit/internal/repeat.cpp index 5665a0c3..41a54c5f 100644 --- a/unit/internal/repeat.cpp +++ b/unit/internal/repeat.cpp @@ -277,10 +277,9 @@ TEST_P(RepeatTest, FillRing) { } // We should be able to see matches for all of these (beyond the last top offset). - enum TriggerResult rv; for (u64a i = offset + info.repeatMax; i <= offset + info.repeatMax + info.repeatMin; i++) { - rv = processTugTrigger(&info, ctrl, state, i); + enum TriggerResult rv = processTugTrigger(&info, ctrl, state, i); if (rv == TRIGGER_SUCCESS_CACHE) { rv = TRIGGER_SUCCESS; } @@ -998,16 +997,14 @@ TEST_P(SparseOptimalTest, FillTops) { repeatStore(info, ctrl, state, offset, 0); ASSERT_EQ(offset, repeatLastTop(info, ctrl, state)); - u64a offset2; for (u32 i = min_period; i < patch_count * patch_size; i += min_period) { - offset2 = offset + i; + u64a offset2 = offset + i; repeatStore(info, ctrl, state, offset2, 1); ASSERT_EQ(offset2, repeatLastTop(info, ctrl, state)); } - u64a exit2; for (u32 i = 0; i < patch_count * patch_size; i += min_period) { - exit2 = exit + i; + u64a exit2 = exit + i; for (u32 j = exit2 + info->repeatMin; j <= offset + info->repeatMax; j++) { ASSERT_EQ(REPEAT_MATCH, repeatHasMatch(info, ctrl, state, j)); diff --git a/unit/internal/rose_mask.cpp b/unit/internal/rose_mask.cpp index e6be00f3..ed1af956 100644 --- a/unit/internal/rose_mask.cpp +++ b/unit/internal/rose_mask.cpp @@ -87,12 +87,11 @@ static int initLegalValidMasks(u64a validMasks[]) { */ static int initLegalNegMasks(u64a negMasks[]) { u64a data = 0; - u64a offset; int num = 0; while (data != ONES64) { negMasks[num] = data; num++; - offset = (data | (data +1)) ^ data; + u64a offset = (data | (data +1)) ^ data; data += 0xfeULL * offset + 1; } negMasks[num] = data; diff --git a/unit/internal/rose_mask_32.cpp b/unit/internal/rose_mask_32.cpp index 732f51a0..bb444ead 100644 --- a/unit/internal/rose_mask_32.cpp +++ b/unit/internal/rose_mask_32.cpp @@ -194,10 +194,9 @@ TEST(ValidateMask32, testMask32_3) { u32 valid_mask = ONES32 << (left + right) >> left; for (int i = 0; i < test_len; i++) { const auto &t = testBasic[i]; - int bool_result; for (int j = 0; j < 5000; j++) { u32 neg_mask = neg_mask_rand.Generate(1u << 31); - bool_result = (neg_mask & valid_mask) == + int bool_result = (neg_mask & valid_mask) == (t.neg_mask & valid_mask); EXPECT_EQ(bool_result, validateMask32(t.data.a256, valid_mask, diff --git a/util/ng_corpus_generator.cpp b/util/ng_corpus_generator.cpp index 6c3f613d..68aa5583 100644 --- a/util/ng_corpus_generator.cpp +++ b/util/ng_corpus_generator.cpp @@ -223,7 +223,7 @@ public: CorpusProperties &props); ~CorpusGeneratorImpl() = default; - void generateCorpus(vector &data); + void generateCorpus(vector &data) override; private: unsigned char getRandomChar(); @@ -419,7 +419,7 @@ public: CorpusProperties &props); ~CorpusGeneratorUtf8() = default; - void generateCorpus(vector &data); + void generateCorpus(vector &data) override; private: unichar getRandomChar();