From 9577fdc474a9355ac8286d1c08041e6451c917bb Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:00:28 +0300 Subject: [PATCH 1/8] False positives duplicateExpression --- src/nfa/limex_exceptional.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nfa/limex_exceptional.h b/src/nfa/limex_exceptional.h index c9de3aed..f472aee4 100644 --- a/src/nfa/limex_exceptional.h +++ b/src/nfa/limex_exceptional.h @@ -302,8 +302,8 @@ int PE_FN(STATE_ARG, ESTATE_ARG, UNUSED u32 diffmask, STATE_T *succ, } #else // A copy of the estate as an array of GPR-sized chunks. - CHUNK_T chunks[sizeof(STATE_T) / sizeof(CHUNK_T)]; - CHUNK_T emask_chunks[sizeof(STATE_T) / sizeof(CHUNK_T)]; + CHUNK_T chunks[sizeof(STATE_T) / sizeof(CHUNK_T)]; // cppcheck-suppress duplicateExpression + CHUNK_T emask_chunks[sizeof(STATE_T) / sizeof(CHUNK_T)]; // cppcheck-suppress duplicateExpression #ifdef ESTATE_ON_STACK memcpy(chunks, &estate, sizeof(STATE_T)); #else @@ -311,7 +311,7 @@ int PE_FN(STATE_ARG, ESTATE_ARG, UNUSED u32 diffmask, STATE_T *succ, #endif memcpy(emask_chunks, &limex->exceptionMask, sizeof(STATE_T)); - u32 base_index[sizeof(STATE_T) / sizeof(CHUNK_T)]; + u32 base_index[sizeof(STATE_T) / sizeof(CHUNK_T)]; // cppcheck-suppress duplicateExpression base_index[0] = 0; for (s32 i = 0; i < (s32)ARRAY_LENGTH(base_index) - 1; i++) { base_index[i + 1] = base_index[i] + POPCOUNT_FN(emask_chunks[i]); From 2dc4da7f2e7f4b72a6eb11b8f1fb38fceffc10a1 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:01:02 +0300 Subject: [PATCH 2/8] False positive knownConditionTrueFalse --- src/hs_valid_platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hs_valid_platform.c b/src/hs_valid_platform.c index 3fa1b08d..00c612bc 100644 --- a/src/hs_valid_platform.c +++ b/src/hs_valid_platform.c @@ -49,6 +49,7 @@ hs_error_t HS_CDECL hs_valid_platform(void) { } #elif !defined(VS_SIMDE_BACKEND) && (defined(ARCH_ARM32) || defined(ARCH_AARCH64)) //check_neon returns true for now + // cppcheck-suppress knownConditionTrueFalse if (check_neon()) { return HS_SUCCESS; } else { From 1d4a2b2b6009b391ecbae5995a087cbe09a77264 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:01:31 +0300 Subject: [PATCH 3/8] Fix variableScope --- src/nfa/gough.c | 4 ++-- src/nfa/mcclellancompile.cpp | 2 +- src/nfa/sheng.c | 2 +- src/rose/rose_build_add_mask.cpp | 3 ++- src/rose/rose_build_bytecode.cpp | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/nfa/gough.c b/src/nfa/gough.c index d0ea0bbd..f0d5bc64 100644 --- a/src/nfa/gough.c +++ b/src/nfa/gough.c @@ -978,7 +978,6 @@ char nfaExecGough16_initCompressedState(const struct NFA *nfa, u64a offset, char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) { const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n); NfaCallback cb = q->cb; - void *ctxt = q->context; u8 s = *(u8 *)q->state; u64a offset = q_cur_offset(q); const struct gough_som_info *som = getSomInfo(q->state); @@ -986,6 +985,7 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) { assert(s); if (s >= m->accept_limit_8) { + void *ctxt = q->context; u32 cached_accept_id = 0; u16 cached_accept_state = 0; u32 cached_accept_som = 0; @@ -1000,7 +1000,6 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) { char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) { const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n); NfaCallback cb = q->cb; - void *ctxt = q->context; u16 s = *(u16 *)q->state; const struct mstate_aux *aux = get_aux(m, s); u64a offset = q_cur_offset(q); @@ -1010,6 +1009,7 @@ char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) { assert(s); if (aux->accept) { + void *ctxt = q->context; u32 cached_accept_id = 0; u16 cached_accept_state = 0; u32 cached_accept_som = 0; diff --git a/src/nfa/mcclellancompile.cpp b/src/nfa/mcclellancompile.cpp index 6ada4e50..bf9b407a 100644 --- a/src/nfa/mcclellancompile.cpp +++ b/src/nfa/mcclellancompile.cpp @@ -1379,7 +1379,6 @@ void generate_symbol_chain(dfa_info &info, vector &chain_tail) { for (size_t j = 0; j < width; j++) { dstate_id_t curr_id = state_chain[j]; - dstate_id_t next_id = state_chain[j + 1]; // The last state of the chain doesn't belong to a wide state. info.extra[curr_id].wideState = true; @@ -1388,6 +1387,7 @@ void generate_symbol_chain(dfa_info &info, vector &chain_tail) { if (j == width - 1) { symbol_chain.emplace_back(chain_tail[i]); } else { + dstate_id_t next_id = state_chain[j + 1]; for (symbol_t sym = 0; sym < info.impl_alpha_size; sym++) { if (rdfa.states[curr_id].next[sym] == next_id) { symbol_chain.emplace_back(sym); diff --git a/src/nfa/sheng.c b/src/nfa/sheng.c index 922e8f80..e6b299d4 100644 --- a/src/nfa/sheng.c +++ b/src/nfa/sheng.c @@ -814,7 +814,6 @@ char nfaExecSheng_testEOD(const struct NFA *nfa, const char *state, char nfaExecSheng_reportCurrent(const struct NFA *n, struct mq *q) { const struct sheng *sh = (const struct sheng *)getImplNfa(n); NfaCallback cb = q->cb; - void *ctxt = q->context; u8 s = *(u8 *)q->state; const struct sstate_aux *aux = get_aux(sh, s); u64a offset = q_cur_offset(q); @@ -823,6 +822,7 @@ char nfaExecSheng_reportCurrent(const struct NFA *n, struct mq *q) { assert(q_cur_type(q) == MQE_START); if (aux->accept) { + void *ctxt = q->context; if (sh->flags & SHENG_FLAG_SINGLE_REPORT) { fireSingleReport(cb, ctxt, sh->report, offset); } else { diff --git a/src/rose/rose_build_add_mask.cpp b/src/rose/rose_build_add_mask.cpp index 05f3a620..5312e6c8 100644 --- a/src/rose/rose_build_add_mask.cpp +++ b/src/rose/rose_build_add_mask.cpp @@ -392,8 +392,9 @@ bool validateTransientMask(const vector &mask, bool anchored, none_of(begin(lits), end(lits), mixed_sensitivity)); // Build the HWLM literal mask. - vector msk, lcmp; + vector msk; if (grey.roseHamsterMasks) { + vector lcmp; buildLiteralMask(mask, msk, lcmp, delay); } diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index b456c0b5..df24a234 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -1901,8 +1901,8 @@ void findExclusiveSuffixes(RoseBuildImpl &tbi, build_context &bc, // We may have already built this NFA. if (contains(suffixes, s)) { - u32 id = suffixes[s]; if (!tbi.isInETable(v)) { + u32 id = suffixes[s]; vertex_map[id].emplace_back(v); } continue; @@ -2233,10 +2233,10 @@ vector buildSuffixEkeyLists(const RoseBuildImpl &build, build_context &bc, for (const auto &e : bc.suffixes) { const suffix_id &s = e.first; - u32 qi = e.second; set ekeys = reportsToEkeys(all_reports(s), build.rm); if (!ekeys.empty()) { + u32 qi = e.second; qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()}; } } @@ -2987,7 +2987,7 @@ void buildFragmentPrograms(const RoseBuildImpl &build, const auto &cfrag = fragments[pfrag.included_frag_id]; /** assert(pfrag.s.length() >= cfrag.s.length() && **/ assert(pfrag.s.length() == cfrag.s.length() && - !pfrag.s.any_nocase() >= !cfrag.s.any_nocase()); + !pfrag.s.any_nocase() != !cfrag.s.any_nocase()); u32 child_offset = cfrag.delay_program_offset; DEBUG_PRINTF("child %u offset %u\n", cfrag.fragment_id, child_offset); From 4a56b9c2e99b427266c2f676ac6ffca514c0a57d Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:04:50 +0300 Subject: [PATCH 4/8] Fix unknownMacro --- src/parser/ucp_table.cpp | 8 -------- src/parser/ucp_table.h | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/parser/ucp_table.cpp b/src/parser/ucp_table.cpp index fc1330fe..77f13009 100644 --- a/src/parser/ucp_table.cpp +++ b/src/parser/ucp_table.cpp @@ -34,14 +34,6 @@ using namespace std; namespace ue2 { -#define UCP_FN(cat) \ -CodePointSet getUcp##cat(void) { \ - CodePointSet rv; \ - for (u32 i = 0; i < ARRAY_LENGTH(ucp_##cat##_def); i += 2) { \ - rv.setRange(ucp_##cat##_def[i], ucp_##cat##_def[i + 1]); \ - } \ - return rv; \ -} struct unicase { unichar base; diff --git a/src/parser/ucp_table.h b/src/parser/ucp_table.h index 269a971c..5f0c9af3 100644 --- a/src/parser/ucp_table.h +++ b/src/parser/ucp_table.h @@ -36,6 +36,15 @@ namespace ue2 { +#define UCP_FN(cat) \ +CodePointSet getUcp##cat(void) { \ + CodePointSet rv; \ + for (u32 i = 0; i < ARRAY_LENGTH(ucp_##cat##_def); i += 2) { \ + rv.setRange(ucp_##cat##_def[i], ucp_##cat##_def[i + 1]); \ + } \ + return rv; \ +} + class CodePointSet; void make_caseless(CodePointSet *cps); bool flip_case(unichar *c); From 0cf72ef474f0d22f47ee162dba78084434c116e3 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:05:22 +0300 Subject: [PATCH 5/8] Fix missingOverride --- util/ng_corpus_generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ng_corpus_generator.cpp b/util/ng_corpus_generator.cpp index 68aa5583..c18f2398 100644 --- a/util/ng_corpus_generator.cpp +++ b/util/ng_corpus_generator.cpp @@ -221,7 +221,7 @@ class CorpusGeneratorImpl : public CorpusGenerator { public: CorpusGeneratorImpl(const NGHolder &graph_in, const ExpressionInfo &expr_in, CorpusProperties &props); - ~CorpusGeneratorImpl() = default; + virtual ~CorpusGeneratorImpl() = default; void generateCorpus(vector &data) override; From 6d6d4e10131582548662ca7ee82b42ccbf57c3c7 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:05:50 +0300 Subject: [PATCH 6/8] Fix unreadVariable warning --- src/fdr/fdr_confirm_compile.cpp | 3 --- src/nfa/dfa_min.cpp | 1 + src/nfa/goughcompile.cpp | 6 +++--- src/nfa/mcsheng_compile.cpp | 11 ++++++++--- src/nfa/nfa_api_queue.h | 4 ++++ src/nfa/shengcompile.cpp | 2 +- src/nfagraph/ng_repeat.cpp | 4 +--- src/nfagraph/ng_som.cpp | 2 +- src/rose/match.c | 3 ++- src/rose/rose_build_add.cpp | 4 ++-- src/rose/rose_build_long_lit.cpp | 7 ++----- src/rose/rose_build_misc.cpp | 1 - src/stream_compress_impl.h | 1 + unit/internal/state_compress.cpp | 8 ++++---- 14 files changed, 30 insertions(+), 27 deletions(-) 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 } } } From 8260d7c906d16388d549aa81b42e48e5ccaf3d60 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:11:07 +0300 Subject: [PATCH 7/8] another duplicateExpression false positive --- src/util/multibit_build.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/multibit_build.cpp b/src/util/multibit_build.cpp index 442c528f..bccff22f 100644 --- a/src/util/multibit_build.cpp +++ b/src/util/multibit_build.cpp @@ -256,7 +256,7 @@ void mmbBuildInitRangePlan(u32 total_bits, u32 begin, u32 end, /* handle the multilevel case */ s32 ks = mmbit_keyshift(total_bits); u32 level = 0; - assert(sizeof(MMB_TYPE) == sizeof(u64a)); + assert(sizeof(MMB_TYPE) == sizeof(u64a)); // cppcheck-suppress duplicateExpression if (begin == end) { add_scatter(&out->p_u64a, 0, 0); From 59a098504ea609b93290fe3666be01eecf1c6987 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 15 May 2024 17:18:53 +0300 Subject: [PATCH 8/8] remove unused variables --- unit/internal/multi_bit_compress.cpp | 3 --- util/cross_compile.cpp | 1 - 2 files changed, 4 deletions(-) diff --git a/unit/internal/multi_bit_compress.cpp b/unit/internal/multi_bit_compress.cpp index dd5b7b7a..5c65d0a9 100644 --- a/unit/internal/multi_bit_compress.cpp +++ b/unit/internal/multi_bit_compress.cpp @@ -401,7 +401,6 @@ TEST_P(MultiBitCompTest, CompCompressDecompressDense) { TEST(MultiBitComp, CompIntegration1) { // 256 + 1 --> smallest 2-level mmbit - //u32 total_size = mmbit_size(257); mmbit_holder ba(257); //-------------------- 1 -----------------------// @@ -516,7 +515,6 @@ TEST(MultiBitComp, CompIntegration1) { TEST(MultiBitComp, CompIntegration2) { // 64^2 + 1 --> smallest 3-level mmbit - //u32 total_size = mmbit_size(4097); mmbit_holder ba(4097); //-------------------- 1 -----------------------// @@ -645,7 +643,6 @@ TEST(MultiBitComp, CompIntegration2) { TEST(MultiBitComp, CompIntegration3) { // 64^3 + 1 --> smallest 4-level mmbit - //u32 total_size = mmbit_size(262145); mmbit_holder ba(262145); //-------------------- 1 -----------------------// diff --git a/util/cross_compile.cpp b/util/cross_compile.cpp index 8ce1e2f0..8c0f9880 100644 --- a/util/cross_compile.cpp +++ b/util/cross_compile.cpp @@ -55,7 +55,6 @@ unique_ptr xcompileReadMode(const char *s) { assert(!err); string str(s); - //string mode = str.substr(0, str.find(":")); string opt = str.substr(str.find(":")+1, str.npos); bool found_mode = false;