diff --git a/src/fdr/fdr_confirm_compile.cpp b/src/fdr/fdr_confirm_compile.cpp index 7f4ad7ec..625d1b14 100644 --- a/src/fdr/fdr_confirm_compile.cpp +++ b/src/fdr/fdr_confirm_compile.cpp @@ -294,9 +294,6 @@ setupFullConfs(const vector &lits, const EngineDescription &eng, const map> &bucketToLits, bool make_small) { - unique_ptr teddyDescr = - getTeddyDescription(eng.getID()); - BC2CONF bc2Conf; u32 totalConfirmSize = 0; for (BucketIndex b = 0; b < eng.getNumBuckets(); b++) { diff --git a/src/nfa/dfa_min.cpp b/src/nfa/dfa_min.cpp index 757fffbe..c44f81ea 100644 --- a/src/nfa/dfa_min.cpp +++ b/src/nfa/dfa_min.cpp @@ -304,6 +304,7 @@ void minimize_hopcroft(raw_dfa &rdfa, const Grey &grey) { DEBUG_PRINTF("dfa is empty\n"); } + // cppcheck-suppress unreadVariable UNUSED const size_t states_before = rdfa.states.size(); HopcroftInfo info(rdfa); diff --git a/src/nfa/goughcompile.cpp b/src/nfa/goughcompile.cpp index 17193d25..a8ae96cb 100644 --- a/src/nfa/goughcompile.cpp +++ b/src/nfa/goughcompile.cpp @@ -802,7 +802,7 @@ private: static void prep_joins_for_generation(const GoughGraph &g, GoughVertex v, - map *edge_info) { + map &edge_info) { DEBUG_PRINTF("writing out joins for %u\n", g[v].state_id); for (const auto &var : g[v].vars) { u32 dest_slot = var->slot; @@ -813,7 +813,7 @@ void prep_joins_for_generation(const GoughGraph &g, GoughVertex v, } for (const GoughEdge &incoming_edge : var_edges.second) { - (*edge_info)[incoming_edge].insert(input, dest_slot); + edge_info[incoming_edge].insert(input, dest_slot); DEBUG_PRINTF("need %u<-%u\n", dest_slot, input); } } @@ -911,7 +911,7 @@ void build_blocks(const GoughGraph &g, } map eji; - prep_joins_for_generation(g, t, &eji); + prep_joins_for_generation(g, t, eji); for (auto &m : eji) { vector &block = (*blocks)[gough_edge_id(g, m.first)]; diff --git a/src/nfa/mcsheng_compile.cpp b/src/nfa/mcsheng_compile.cpp index 9b5d8f59..0d3ed834 100644 --- a/src/nfa/mcsheng_compile.cpp +++ b/src/nfa/mcsheng_compile.cpp @@ -1018,12 +1018,16 @@ bytecode_ptr mcshengCompile16(dfa_info &info, dstate_id_t sheng_end, // Sherman optimization if (info.impl_alpha_size > 16) { +#ifdef DEBUG u16 total_daddy = 0; +#endif // DEBUG for (u32 i = 0; i < info.size(); i++) { find_better_daddy(info, i, is_cyclic_near(info.raw, info.raw.start_anchored), grey); +#ifdef DEBUG total_daddy += info.extra[i].daddytaken; +#endif // DEBUG } DEBUG_PRINTF("daddy %hu/%zu states=%zu alpha=%hu\n", total_daddy, @@ -1172,12 +1176,16 @@ bytecode_ptr mcsheng64Compile16(dfa_info&info, dstate_id_t sheng_end, // Sherman optimization if (info.impl_alpha_size > 16) { +#ifdef DEBUG u16 total_daddy = 0; +#endif // DEBUG for (u32 i = 0; i < info.size(); i++) { find_better_daddy(info, i, is_cyclic_near(info.raw, info.raw.start_anchored), grey); +#ifdef DEBUG total_daddy += info.extra[i].daddytaken; +#endif // DEBUG } DEBUG_PRINTF("daddy %hu/%zu states=%zu alpha=%hu\n", total_daddy, @@ -1430,11 +1438,9 @@ bytecode_ptr mcshengCompile(raw_dfa &raw, const CompileContext &cc, map accel_escape_info = info.strat.getAccelInfo(cc.grey); - auto old_states = info.states; dstate_id_t sheng_end = find_sheng_states(info, accel_escape_info, MAX_SHENG_STATES); if (sheng_end <= DEAD_STATE + 1) { - info.states = old_states; return bytecode_ptr(nullptr); } @@ -1447,7 +1453,6 @@ bytecode_ptr mcshengCompile(raw_dfa &raw, const CompileContext &cc, } if (!nfa) { - info.states = old_states; return nfa; } diff --git a/src/nfa/nfa_api_queue.h b/src/nfa/nfa_api_queue.h index 16a4c011..3f8bca2c 100644 --- a/src/nfa/nfa_api_queue.h +++ b/src/nfa/nfa_api_queue.h @@ -251,6 +251,10 @@ void q_skip_forward_to(struct mq *q, s64a min_loc) { // Dump the contents of the given queue. static never_inline UNUSED void debugQueue(const struct mq *q) { + if (q == nullptr) { + DEBUG_PRINTF("q=NULL!\n"); + return; + } DEBUG_PRINTF("q=%p, nfa=%p\n", q, q->nfa); DEBUG_PRINTF("q offset=%llu, buf={%p, len=%zu}, history={%p, len=%zu}\n", q->offset, q->buffer, q->length, q->history, q->hlength); diff --git a/src/nfa/shengcompile.cpp b/src/nfa/shengcompile.cpp index c8a6daca..9d83a587 100644 --- a/src/nfa/shengcompile.cpp +++ b/src/nfa/shengcompile.cpp @@ -800,7 +800,7 @@ bytecode_ptr sheng64Compile(raw_dfa &raw, const CompileContext &cc, old_states = info.states; auto nfa = shengCompile_int(raw, cc, accel_states, strat, info); if (!nfa) { - info.states = old_states; + info.states = old_states; // cppcheck-suppress unreadVariable } return nfa; } diff --git a/src/nfagraph/ng_repeat.cpp b/src/nfagraph/ng_repeat.cpp index 8f62ffbb..921cf77c 100644 --- a/src/nfagraph/ng_repeat.cpp +++ b/src/nfagraph/ng_repeat.cpp @@ -854,9 +854,7 @@ void replaceSubgraphWithLazySpecial(NGHolder &g, ReachSubgraph &rsi, assert(rsi.repeatMax >= rsi.repeatMin); DEBUG_PRINTF("entry\n"); - - const unordered_set involved(rsi.vertices.begin(), - rsi.vertices.end()); + vector g_succs; getSuccessors(g, rsi, &g_succs); diff --git a/src/nfagraph/ng_som.cpp b/src/nfagraph/ng_som.cpp index 518b6ebc..9197ce44 100644 --- a/src/nfagraph/ng_som.cpp +++ b/src/nfagraph/ng_som.cpp @@ -3125,7 +3125,7 @@ sombe_rv doSomWithHaig(NG &ng, NGHolder &g, const ExpressionInfo &expr, // try a redundancy pass. if (addSomRedundancy(g, depths)) { - depths = getDistancesFromSOM(g); + depths = getDistancesFromSOM(g); // cppcheck-suppress unreadVariable } auto regions = assignRegions(g); diff --git a/src/rose/match.c b/src/rose/match.c index 643b1d9f..fa57f948 100644 --- a/src/rose/match.c +++ b/src/rose/match.c @@ -267,7 +267,8 @@ hwlmcb_rv_t playDelaySlot(const struct RoseEngine *t, const u32 *programs = getByOffset(t, t->delayProgramOffset); for (u32 it = fatbit_iterate(vicSlot, delay_count, MMB_INVALID); - it != MMB_INVALID; it = fatbit_iterate(vicSlot, delay_count, it)) { + it != MMB_INVALID; it = fatbit_iterate(vicSlot, delay_count, it)) { + // cppcheck-suppress unreadVariable UNUSED rose_group old_groups = tctxt->groups; DEBUG_PRINTF("DELAYED MATCH id=%u offset=%llu\n", it, offset); diff --git a/src/rose/rose_build_add.cpp b/src/rose/rose_build_add.cpp index 2f4e08a4..56a9faf5 100644 --- a/src/rose/rose_build_add.cpp +++ b/src/rose/rose_build_add.cpp @@ -1039,9 +1039,9 @@ bool canImplementGraph(NGHolder &h, bool prefilter, const ReportManager &rm, if (prefilter && cc.grey.prefilterReductions) { // If we're prefiltering, we can have another go with a reduced graph. - UNUSED size_t numBefore = num_vertices(h); + UNUSED size_t numBefore = num_vertices(h); // cppcheck-suppress unreadVariable prefilterReductions(h, cc); - UNUSED size_t numAfter = num_vertices(h); + UNUSED size_t numAfter = num_vertices(h); // cppcheck-suppress unreadVariable DEBUG_PRINTF("reduced from %zu to %zu vertices\n", numBefore, numAfter); if (isImplementableNFA(h, &rm, cc)) { diff --git a/src/rose/rose_build_long_lit.cpp b/src/rose/rose_build_long_lit.cpp index 45a2eb27..943c5b29 100644 --- a/src/rose/rose_build_long_lit.cpp +++ b/src/rose/rose_build_long_lit.cpp @@ -98,8 +98,7 @@ void addToBloomFilter(vector &bloom, const u8 *substr, bool nocase) { const auto hash_functions = { bloomHash_1, bloomHash_2, bloomHash_3 }; for (const auto &hash_func : hash_functions) { - u32 hash = hash_func(substr, nocase); - u32 key = hash & key_mask; + u32 key = hash_func(substr, nocase) & key_mask; DEBUG_PRINTF("set key %u (of %zu)\n", key, bloom.size() * 8); bloom[key / 8] |= 1U << (key % 8); } @@ -193,11 +192,9 @@ vector buildHashTable( } for (const auto &m : hashToLitOffPairs) { - u32 hash = m.first; + u32 bucket = m.first % numEntries; const LitOffsetVector &d = m.second; - u32 bucket = hash % numEntries; - // Placement via linear probing. for (const auto &lit_offset : d) { while (tab[bucket].str_offset != 0) { diff --git a/src/rose/rose_build_misc.cpp b/src/rose/rose_build_misc.cpp index d0c63027..887d8a8d 100644 --- a/src/rose/rose_build_misc.cpp +++ b/src/rose/rose_build_misc.cpp @@ -861,7 +861,6 @@ u32 roseQuality(const RoseResources &res, const RoseEngine *t) { } if (eod_prefix) { - always_run++; DEBUG_PRINTF("eod prefixes are slow"); return 0; } diff --git a/src/stream_compress_impl.h b/src/stream_compress_impl.h index f02543ef..a4c3e466 100644 --- a/src/stream_compress_impl.h +++ b/src/stream_compress_impl.h @@ -142,6 +142,7 @@ size_t JOIN(sc_, FN_SUFFIX)(const struct RoseEngine *rose, COPY(stream_body + so->groups, so->groups_size); /* copy the real bits of history */ + // cppcheck-suppress unreadVariable UNUSED u32 hend = so->history + rose->historyRequired; COPY(stream_body + hend - history, history); diff --git a/unit/internal/state_compress.cpp b/unit/internal/state_compress.cpp index d1442b4f..58e540a8 100644 --- a/unit/internal/state_compress.cpp +++ b/unit/internal/state_compress.cpp @@ -180,7 +180,7 @@ TEST(state_compress, m128_2) { loadcompressed128(&val_out, &buf, &mask, 0); EXPECT_TRUE(!diff128(and128(val, mask), val_out)); - mask_raw[j] = 0x7f; + mask_raw[j] = 0x7f; // cppcheck-suppress unreadVariable } } } @@ -258,7 +258,7 @@ TEST(state_compress, m256_2) { loadcompressed256(&val_out, &buf, &mask, 0); EXPECT_TRUE(!diff256(and256(val, mask), val_out)); - mask_raw[j] = 0x7f; + mask_raw[j] = 0x7f; // cppcheck-suppress unreadVariable } } } @@ -338,7 +338,7 @@ TEST(state_compress, m384_2) { loadcompressed384(&val_out, &buf, &mask, 0); EXPECT_TRUE(!diff384(and384(val, mask), val_out)); - mask_raw[j] = 0x7f; + mask_raw[j] = 0x7f; // cppcheck-suppress unreadVariable } } } @@ -419,7 +419,7 @@ TEST(state_compress, m512_2) { loadcompressed512(&val_out, &buf, &mask, 0); EXPECT_TRUE(!diff512(and512(val, mask), val_out)); - mask_raw[j] = 0x7f; + mask_raw[j] = 0x7f; // cppcheck-suppress unreadVariable } } }