diff --git a/examples/simplegrep.c b/examples/simplegrep.c index b4b287e8..cceaa109 100644 --- a/examples/simplegrep.c +++ b/examples/simplegrep.c @@ -67,7 +67,7 @@ * to pass in the pattern that was being searched for so we can print it out. */ static int eventHandler(unsigned int id, unsigned long long from, - unsigned long long to, unsigned int flags, void *ctx) { + unsigned long long to, unsigned int flags, void *ctx) { // cppcheck-suppress constParameterCallback printf("Match for pattern \"%s\" at offset %llu\n", (char *)ctx, to); return 0; } diff --git a/src/fdr/fdr.c b/src/fdr/fdr.c index 16f453c5..302487a3 100644 --- a/src/fdr/fdr.c +++ b/src/fdr/fdr.c @@ -333,7 +333,7 @@ void do_confirm_fdr(u64a *conf, u8 offset, hwlmcb_rv_t *control, } static really_inline -void dumpZoneInfo(UNUSED struct zone *z, UNUSED size_t zone_id) { +void dumpZoneInfo(UNUSED const struct zone *z, UNUSED size_t zone_id) { #ifdef DEBUG DEBUG_PRINTF("zone: zone=%zu, bufPtr=%p\n", zone_id, z->buf); DEBUG_PRINTF("zone: startPtr=%p, endPtr=%p, shift=%u\n", diff --git a/src/hwlm/hwlm.c b/src/hwlm/hwlm.c index e50deff7..40349def 100644 --- a/src/hwlm/hwlm.c +++ b/src/hwlm/hwlm.c @@ -170,8 +170,7 @@ void do_accel_streaming(const union AccelAux *aux, const u8 *hbuf, size_t hlen, DEBUG_PRINTF("got %zu/%zu in 2nd buffer\n", delta, len); *start += delta; } else if (hlen) { - UNUSED size_t remaining = offset + ptr2 - found; - DEBUG_PRINTF("got %zu/%zu remaining in 1st buffer\n", remaining, hlen); + DEBUG_PRINTF("got %zu/%zu remaining in 1st buffer\n", offset + ptr2 - found, hlen); } } diff --git a/src/nfa/castle.c b/src/nfa/castle.c index b6fadc75..e6769ac7 100644 --- a/src/nfa/castle.c +++ b/src/nfa/castle.c @@ -401,7 +401,7 @@ char castleFindMatch(const struct Castle *c, const u64a begin, const u64a end, static really_inline u64a subCastleNextMatch(const struct Castle *c, const void *full_state, - void *stream_state, const u64a loc, + const void *stream_state, const u64a loc, const u32 subIdx) { DEBUG_PRINTF("subcastle %u\n", subIdx); const struct SubCastle *sub = getSubCastle(c, subIdx); @@ -883,7 +883,7 @@ char nfaExecCastle_Q2(const struct NFA *n, struct mq *q, s64a end) { } static -s64a castleLastKillLoc(const struct Castle *c, struct mq *q) { +s64a castleLastKillLoc(const struct Castle *c, const struct mq *q) { assert(q_cur_type(q) == MQE_START); assert(q_last_type(q) == MQE_END); s64a sp = q_cur_loc(q); diff --git a/src/nfa/goughcompile.cpp b/src/nfa/goughcompile.cpp index 17193d25..bcb69a13 100644 --- a/src/nfa/goughcompile.cpp +++ b/src/nfa/goughcompile.cpp @@ -132,7 +132,7 @@ void GoughSSAVarMin::replace_input(GoughSSAVar *old_v, GoughSSAVar *new_v) { } static -void translateRawReports(UNUSED GoughGraph &cfg, UNUSED const raw_som_dfa &raw, +void translateRawReports(UNUSED const GoughGraph &cfg, UNUSED const raw_som_dfa &raw, const flat_map &joins_at_s, UNUSED GoughVertex s, const set &reports_in, @@ -433,6 +433,7 @@ unique_ptr makeCFG(const raw_som_dfa &raw) { } static +// cppcheck-suppress constParameterReference void copy_propagate_report_set(vector > &rep) { vector >::iterator it = rep.begin(); while (it != rep.end()) { @@ -650,8 +651,8 @@ GoughSSAVar *GoughSSAVarJoin::get_input(const GoughEdge &prev) const { return nullptr; } -const flat_set &GoughSSAVarJoin::get_edges_for_input( - GoughSSAVar *input) const { +// cppcheck-suppress constParameterPointer +const flat_set &GoughSSAVarJoin::get_edges_for_input(GoughSSAVar *input) const { return input_map.at(input); } diff --git a/src/nfa/goughcompile_reg.cpp b/src/nfa/goughcompile_reg.cpp index 60e32f12..4b0c90f1 100644 --- a/src/nfa/goughcompile_reg.cpp +++ b/src/nfa/goughcompile_reg.cpp @@ -278,7 +278,7 @@ set live_during(GoughSSAVar *def, const GoughGraph &g, template void set_initial_slots(const vector &vars, u32 *next_slot) { - for (auto &var : vars) { + for (const auto &var : vars) { assert(var->slot == INVALID_SLOT); var->slot = (*next_slot)++; } diff --git a/src/nfa/limex.h b/src/nfa/limex.h index 0223604d..03fcca0e 100644 --- a/src/nfa/limex.h +++ b/src/nfa/limex.h @@ -56,7 +56,7 @@ extern "C" char gf_name##_Q(const struct NFA *n, struct mq *q, s64a end); \ char gf_name##_Q2(const struct NFA *n, struct mq *q, s64a end); \ char gf_name##_QR(const struct NFA *n, struct mq *q, ReportID report); \ - char gf_name##_reportCurrent(const struct NFA *n, struct mq *q); \ + char gf_name##_reportCurrent(const struct NFA *n, const struct mq *q); \ char gf_name##_inAccept(const struct NFA *n, ReportID report, \ struct mq *q); \ char gf_name##_inAnyAccept(const struct NFA *n, struct mq *q); \ diff --git a/src/nfa/limex_runtime_impl.h b/src/nfa/limex_runtime_impl.h index d21739d6..d3ddb100 100644 --- a/src/nfa/limex_runtime_impl.h +++ b/src/nfa/limex_runtime_impl.h @@ -927,7 +927,7 @@ char JOIN(LIMEX_API_ROOT, _testEOD)(const struct NFA *n, const char *state, context); } -char JOIN(LIMEX_API_ROOT, _reportCurrent)(const struct NFA *n, struct mq *q) { +char JOIN(LIMEX_API_ROOT, _reportCurrent)(const struct NFA *n, const struct mq *q) { const IMPL_NFA_T *limex = getImplNfa(n); REPORTCURRENT_FN(limex, q); return 1; diff --git a/src/nfa/mcsheng_compile.cpp b/src/nfa/mcsheng_compile.cpp index 9b5d8f59..582d4722 100644 --- a/src/nfa/mcsheng_compile.cpp +++ b/src/nfa/mcsheng_compile.cpp @@ -534,7 +534,7 @@ double leakiness(const RdfaGraph &g, dfa_info &info, static dstate_id_t find_sheng_states(dfa_info &info, - map &accel_escape_info, + const map &accel_escape_info, size_t max_sheng_states) { RdfaGraph g(info.raw); auto cyclics = find_vertices_in_cycles(g); diff --git a/src/nfa/shengcompile.cpp b/src/nfa/shengcompile.cpp index c8a6daca..c746a66a 100644 --- a/src/nfa/shengcompile.cpp +++ b/src/nfa/shengcompile.cpp @@ -334,14 +334,14 @@ void fillAccelOut(const map &accel_escape_info, template static -u8 getShengState(UNUSED dstate &state, UNUSED dfa_info &info, - UNUSED map &accelInfo) { +u8 getShengState(UNUSED const dstate &state, UNUSED dfa_info &info, + UNUSED const map &accelInfo) { return 0; } template <> -u8 getShengState(dstate &state, dfa_info &info, - map &accelInfo) { +u8 getShengState(const dstate &state, dfa_info &info, + const map &accelInfo) { u8 s = state.impl_id; if (!state.reports.empty()) { s |= SHENG_STATE_ACCEPT; @@ -356,8 +356,8 @@ u8 getShengState(dstate &state, dfa_info &info, } template <> -u8 getShengState(dstate &state, dfa_info &info, - map &accelInfo) { +u8 getShengState(const dstate &state, dfa_info &info, + const map &accelInfo) { u8 s = state.impl_id; if (!state.reports.empty()) { s |= SHENG32_STATE_ACCEPT; @@ -372,8 +372,8 @@ u8 getShengState(dstate &state, dfa_info &info, } template <> -u8 getShengState(dstate &state, dfa_info &info, - UNUSED map &accelInfo) { +u8 getShengState(const dstate &state, dfa_info &info, + UNUSED const map &accelInfo) { u8 s = state.impl_id; if (!state.reports.empty()) { s |= SHENG64_STATE_ACCEPT; @@ -409,8 +409,8 @@ void fillAccelAux(struct NFA *n, dfa_info &info, template static -void populateBasicInfo(UNUSED struct NFA *n, UNUSED dfa_info &info, - UNUSED map &accelInfo, +void populateBasicInfo(UNUSED struct NFA *n, UNUSED dfa_info &info, // cppcheck-suppress constParameterPointer + UNUSED const map &accelInfo, UNUSED u32 aux_offset, UNUSED u32 report_offset, UNUSED u32 accel_offset, UNUSED u32 total_size, UNUSED u32 dfa_size) { @@ -418,7 +418,7 @@ void populateBasicInfo(UNUSED struct NFA *n, UNUSED dfa_info &info, template <> void populateBasicInfo(struct NFA *n, dfa_info &info, - map &accelInfo, + const map &accelInfo, u32 aux_offset, u32 report_offset, u32 accel_offset, u32 total_size, u32 dfa_size) { @@ -443,7 +443,7 @@ void populateBasicInfo(struct NFA *n, dfa_info &info, template <> void populateBasicInfo(struct NFA *n, dfa_info &info, - map &accelInfo, + const map &accelInfo, u32 aux_offset, u32 report_offset, u32 accel_offset, u32 total_size, u32 dfa_size) { @@ -468,7 +468,7 @@ void populateBasicInfo(struct NFA *n, dfa_info &info, template <> void populateBasicInfo(struct NFA *n, dfa_info &info, - map &accelInfo, + const map &accelInfo, u32 aux_offset, u32 report_offset, u32 accel_offset, u32 total_size, u32 dfa_size) { @@ -551,19 +551,19 @@ void fillSingleReport(NFA *n, ReportID r_id) { template static -bool createShuffleMasks(UNUSED T *s, UNUSED dfa_info &info, - UNUSED map &accelInfo) { +bool createShuffleMasks(UNUSED T *s, UNUSED dfa_info &info, // cppcheck-suppress constParameterPointer + UNUSED const map &accelInfo) { return true; } template <> bool createShuffleMasks(sheng *s, dfa_info &info, - map &accelInfo) { + const map &accelInfo) { for (u16 chr = 0; chr < 256; chr++) { u8 buf[16] = {0}; for (dstate_id_t idx = 0; idx < info.size(); idx++) { - auto &succ_state = info.next(idx, chr); + const auto &succ_state = info.next(idx, chr); buf[idx] = getShengState(succ_state, info, accelInfo); } @@ -577,13 +577,13 @@ bool createShuffleMasks(sheng *s, dfa_info &info, template <> bool createShuffleMasks(sheng32 *s, dfa_info &info, - map &accelInfo) { + const map &accelInfo) { for (u16 chr = 0; chr < 256; chr++) { u8 buf[64] = {0}; assert(info.size() <= 32); for (dstate_id_t idx = 0; idx < info.size(); idx++) { - auto &succ_state = info.next(idx, chr); + const auto &succ_state = info.next(idx, chr); buf[idx] = getShengState(succ_state, info, accelInfo); buf[32 + idx] = buf[idx]; @@ -598,13 +598,13 @@ bool createShuffleMasks(sheng32 *s, dfa_info &info, template <> bool createShuffleMasks(sheng64 *s, dfa_info &info, - map &accelInfo) { + const map &accelInfo) { for (u16 chr = 0; chr < 256; chr++) { u8 buf[64] = {0}; assert(info.size() <= 64); for (dstate_id_t idx = 0; idx < info.size(); idx++) { - auto &succ_state = info.next(idx, chr); + const auto &succ_state = info.next(idx, chr); if (accelInfo.find(info.raw_id(succ_state.impl_id)) != accelInfo.end()) { diff --git a/src/nfagraph/ng_redundancy.cpp b/src/nfagraph/ng_redundancy.cpp index 6da9a7fa..fc1fcbf9 100644 --- a/src/nfagraph/ng_redundancy.cpp +++ b/src/nfagraph/ng_redundancy.cpp @@ -315,7 +315,7 @@ bool hasInEdgeTops(const NGHolder &g, NFAVertex v) { /** Transform (1), removal of redundant vertices. */ static -bool doUselessMergePass(NGHolder &g, som_type som, VertexInfoMap &infoMap, +bool doUselessMergePass(const NGHolder &g, const som_type som, VertexInfoMap &infoMap, set &removable) { /* useless merges can be done in any order, no need to take any care with * ordering */ diff --git a/src/nfagraph/ng_repeat.cpp b/src/nfagraph/ng_repeat.cpp index 8f62ffbb..cf097671 100644 --- a/src/nfagraph/ng_repeat.cpp +++ b/src/nfagraph/ng_repeat.cpp @@ -1978,7 +1978,7 @@ vector makeOwnStraw(NGHolder &g, const BoundedRepeatData &rd, * rewire the straw to start instead of removing the startDs self-loop. */ static -bool improveLeadingRepeatOutfix(NGHolder &g, BoundedRepeatData &rd, +bool improveLeadingRepeatOutfix(NGHolder &g, const BoundedRepeatData &rd, unordered_set &created, const vector &all_repeats) { assert(g.kind == NFA_OUTFIX); diff --git a/src/rose/match.c b/src/rose/match.c index 643b1d9f..4e1d0f10 100644 --- a/src/rose/match.c +++ b/src/rose/match.c @@ -109,7 +109,7 @@ hwlmcb_rv_t roseHandleChainMatch(const struct RoseEngine *t, u64a top_squash_distance, u64a end, char in_catchup) { assert(event == MQE_TOP || event >= MQE_TOP_FIRST); - struct core_info *ci = &scratch->core_info; + const struct core_info *ci = &scratch->core_info; u8 *aa = getActiveLeafArray(t, scratch->core_info.state); u32 aaCount = t->activeArrayCount; diff --git a/src/rose/rose_build_anchored.cpp b/src/rose/rose_build_anchored.cpp index 25b137d1..08d464ed 100644 --- a/src/rose/rose_build_anchored.cpp +++ b/src/rose/rose_build_anchored.cpp @@ -867,7 +867,7 @@ vector buildAnchoredDfas(RoseBuildImpl &build, } bytecode_ptr -buildAnchoredMatcher(RoseBuildImpl &build, const vector &fragments, +buildAnchoredMatcher(const RoseBuildImpl &build, const vector &fragments, vector &dfas) { const CompileContext &cc = build.cc; diff --git a/src/rose/rose_build_anchored.h b/src/rose/rose_build_anchored.h index 37d268ac..8a25eb58 100644 --- a/src/rose/rose_build_anchored.h +++ b/src/rose/rose_build_anchored.h @@ -60,7 +60,7 @@ std::vector buildAnchoredDfas(RoseBuildImpl &build, * given in litPrograms. */ bytecode_ptr -buildAnchoredMatcher(RoseBuildImpl &build, +buildAnchoredMatcher(const RoseBuildImpl &build, const std::vector &fragments, std::vector &dfas); diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index b456c0b5..9b4fffcb 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -1229,7 +1229,7 @@ void updateTops(const RoseGraph &g, const TamaInfo &tamaInfo, const map, u32> &out_top_remap, const bool is_suffix) { u32 i = 0; - for (const auto &n : tamaInfo.subengines) { + for (const auto *n : tamaInfo.subengines) { for (const auto &v : subengines[i].vertices) { if (is_suffix) { tamaProto.add(n, g[v].index, g[v].suffix.top, out_top_remap); @@ -2733,7 +2733,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build, const build_context & } static -RoseProgram makeFragmentProgram(const RoseBuildImpl &build, build_context &bc, +RoseProgram makeFragmentProgram(const RoseBuildImpl &build, const build_context &bc, ProgramBuild &prog_build, const vector &lit_ids, const vector> &lit_edge_map) { diff --git a/src/rose/rose_build_merge.cpp b/src/rose/rose_build_merge.cpp index 985315d9..b312d877 100644 --- a/src/rose/rose_build_merge.cpp +++ b/src/rose/rose_build_merge.cpp @@ -1887,7 +1887,7 @@ void mergeSmallLeftfixes(RoseBuildImpl &tbi) { return; } - RoseGraph &g = tbi.g; + const RoseGraph &g = tbi.g; LeftfixBouquet nfa_leftfixes; @@ -2180,7 +2180,7 @@ void mergeAcyclicSuffixes(RoseBuildImpl &tbi) { SuffixBouquet suffixes; - RoseGraph &g = tbi.g; + const RoseGraph &g = tbi.g; for (auto v : vertices_range(g)) { shared_ptr h = g[v].suffix.graph; @@ -2240,7 +2240,7 @@ void mergeSmallSuffixes(RoseBuildImpl &tbi) { return; } - RoseGraph &g = tbi.g; + const RoseGraph &g = tbi.g; SuffixBouquet suffixes; for (auto v : vertices_range(g)) { diff --git a/src/rose/rose_build_role_aliasing.cpp b/src/rose/rose_build_role_aliasing.cpp index e25e174c..ae99c626 100644 --- a/src/rose/rose_build_role_aliasing.cpp +++ b/src/rose/rose_build_role_aliasing.cpp @@ -1356,7 +1356,7 @@ bool attemptRoseMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a, build.g[a].index, build.g[b].index); assert(a != b); - RoseGraph &g = build.g; + const RoseGraph &g = build.g; const LeftEngInfo &a_left = g[a].left; const LeftEngInfo &b_left = g[b].left; @@ -1996,7 +1996,7 @@ void filterDiamondCandidates(const RoseGraph &g, CandidateSet &candidates) { void aliasRoles(RoseBuildImpl &build, bool mergeRoses) { const CompileContext &cc = build.cc; - RoseGraph &g = build.g; + const RoseGraph &g = build.g; assert(!hasOrphanedTops(build)); assert(canImplementGraphs(build)); diff --git a/src/rose/stream.c b/src/rose/stream.c index 94da8717..b3a91569 100644 --- a/src/rose/stream.c +++ b/src/rose/stream.c @@ -133,7 +133,7 @@ enum MiracleAction roseScanForMiracles(const struct RoseEngine *t, char *state, struct hs_scratch *scratch, u32 qi, const struct LeftNfaInfo *left, const struct NFA *nfa) { - struct core_info *ci = &scratch->core_info; + const struct core_info *ci = &scratch->core_info; const u32 qCount = t->queueCount; struct mq *q = scratch->queues + qi; @@ -211,7 +211,7 @@ char roseCatchUpLeftfix(const struct RoseEngine *t, char *state, const struct LeftNfaInfo *left) { assert(!left->transient); // active roses only - struct core_info *ci = &scratch->core_info; + const struct core_info *ci = &scratch->core_info; const u32 qCount = t->queueCount; struct mq *q = scratch->queues + qi; const struct NFA *nfa = getNfaByQueue(t, qi); diff --git a/src/runtime.c b/src/runtime.c index a055e5f4..d91b5672 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -69,7 +69,7 @@ void prefetch_data(const char *data, unsigned length) { static int HS_CDECL null_onEvent(UNUSED unsigned id, UNUSED unsigned long long from, UNUSED unsigned long long to, UNUSED unsigned flags, - UNUSED void *ctxt) { + UNUSED void *ctxt) { // cppcheck-suppress constParameterCallback return 0; } @@ -576,7 +576,7 @@ hs_error_t HS_CDECL hs_open_stream(const hs_database_t *db, static really_inline -void rawEodExec(hs_stream_t *id, hs_scratch_t *scratch) { +void rawEodExec(const hs_stream_t *id, hs_scratch_t *scratch) { const struct RoseEngine *rose = id->rose; if (can_stop_matching(scratch)) { @@ -593,7 +593,7 @@ void rawEodExec(hs_stream_t *id, hs_scratch_t *scratch) { } static never_inline -void soleOutfixEodExec(hs_stream_t *id, hs_scratch_t *scratch) { +void soleOutfixEodExec(const hs_stream_t *id, hs_scratch_t *scratch) { const struct RoseEngine *t = id->rose; if (can_stop_matching(scratch)) { diff --git a/tools/hsbench/main.cpp b/tools/hsbench/main.cpp index 67904615..79eb80ad 100644 --- a/tools/hsbench/main.cpp +++ b/tools/hsbench/main.cpp @@ -227,7 +227,7 @@ struct BenchmarkSigs { /** Process command-line arguments. Prints usage and exits on error. */ static void processArgs(int argc, char *argv[], vector &sigSets, - UNUSED unique_ptr &grey) { + UNUSED const unique_ptr &grey) { const char options[] = "-b:c:Cd:e:E:G:hHi:n:No:p:PsS:Vw:z:" #if defined(HAVE_DECL_PTHREAD_SETAFFINITY_NP) "T:" // add the thread flag diff --git a/tools/hscheck/main.cpp b/tools/hscheck/main.cpp index 87bedf75..6ee14930 100644 --- a/tools/hscheck/main.cpp +++ b/tools/hscheck/main.cpp @@ -491,7 +491,7 @@ void usage() { } static -void processArgs(int argc, char *argv[], UNUSED unique_ptr &grey) { +void processArgs(int argc, char *argv[], UNUSED const unique_ptr &grey) { const char options[] = "e:E:s:z:hHLNV8G:T:BC"; bool signatureSet = false; int literalFlag = 0; diff --git a/util/ng_find_matches.cpp b/util/ng_find_matches.cpp index 56c38b97..0e5958cd 100644 --- a/util/ng_find_matches.cpp +++ b/util/ng_find_matches.cpp @@ -896,7 +896,7 @@ bool canReach(const NGHolder &g, const NFAEdge &e, const struct fmstate &state) static void getAcceptMatches(const NGHolder &g, MatchSet &matches, - struct fmstate &state, NFAVertex accept_vertex, + const struct fmstate &state, NFAVertex accept_vertex, vector &active_states) { assert(accept_vertex == g.accept || accept_vertex == g.acceptEod);