diff --git a/benchmarks/benchmarks.cpp b/benchmarks/benchmarks.cpp index 81402994..3bcd3f88 100644 --- a/benchmarks/benchmarks.cpp +++ b/benchmarks/benchmarks.cpp @@ -51,7 +51,7 @@ struct hlmMatchEntry { std::vector ctxt; static hwlmcb_rv_t hlmSimpleCallback(size_t to, u32 id, - UNUSED struct hs_scratch *scratch) { + UNUSED struct hs_scratch *scratch) { // cppcheck-suppress constParameterCallback DEBUG_PRINTF("match @%zu = %u\n", to, id); ctxt.push_back(hlmMatchEntry(to, id)); @@ -152,7 +152,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return shuftiExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(), b.buf.data() + b.size); }); @@ -169,7 +169,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return rshuftiExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(), b.buf.data() + b.size); }); @@ -186,7 +186,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return truffleExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(), b.buf.data() + b.size); }); @@ -203,7 +203,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return rtruffleExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(), b.buf.data() + b.size); }); @@ -218,7 +218,7 @@ int main(){ ue2::truffleBuildMasksWide(b.chars, reinterpret_cast(&b.truffle_mask)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return truffleExecWide(b.truffle_mask, b.buf.data(), b.buf.data() + b.size); } ); @@ -232,7 +232,7 @@ int main(){ ue2::truffleBuildMasksWide(b.chars, reinterpret_cast(&b.truffle_mask)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return rtruffleExecWide(b.truffle_mask, b.buf.data(), b.buf.data() + b.size); } ); @@ -251,7 +251,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return vermicelliExec('a', 'b', b.buf.data(), b.buf.data() + b.size); }); @@ -268,7 +268,7 @@ int main(){ reinterpret_cast(&b.truffle_mask_hi)); memset(b.buf.data(), 'b', b.size); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark const &b) { return rvermicelliExec('a', 'b', b.buf.data(), b.buf.data() + b.size); }); @@ -297,7 +297,7 @@ int main(){ b.nt = ue2::noodBuildTable(lit); assert(b.nt.get() != nullptr); }, - [&](MicroBenchmark &b) { + [&](MicroBenchmark &b) { // cppcheck-suppress constParameterReference noodExec(b.nt.get(), b.buf.data(), b.size, 0, hlmSimpleCallback, &b.scratch); return b.buf.data() + b.size; diff --git a/cppcheck-suppression-list.txt b/cppcheck-suppression-list.txt index 79c73fe9..b2fdd08d 100644 --- a/cppcheck-suppression-list.txt +++ b/cppcheck-suppression-list.txt @@ -2,7 +2,9 @@ unknownMacro:*gtest-all.cc knownConditionTrueFalse:*Parser.rl knownConditionTrueFalse:*Parser.cpp variableScope:*Parser.rl +duplicateBreak:*.rl unreadVariable:*control_verbs.cpp +unreachableCode:*rose_build_dump.cpp *:*simde/* assertWithSideEffect syntaxError @@ -10,4 +12,4 @@ internalError checkersReport missingInclude missingIncludeSystem -unmatchedSuppression \ No newline at end of file +unmatchedSuppression diff --git a/src/nfa/lbr.c b/src/nfa/lbr.c index 52e81ad6..c3bd8a57 100644 --- a/src/nfa/lbr.c +++ b/src/nfa/lbr.c @@ -307,7 +307,7 @@ char lbrMatchLoop(const struct lbr_common *l, const u64a begin, const u64a end, static really_inline char lbrRevScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf, UNUSED size_t begin, UNUSED size_t end, - UNUSED size_t *loc) { + UNUSED const size_t *loc) { assert(begin <= end); assert(nfa->type == LBR_NFA_DOT); // Nothing can kill a dot! @@ -413,7 +413,7 @@ char lbrRevScanTruf(const struct NFA *nfa, const u8 *buf, static really_inline char lbrFwdScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf, UNUSED size_t begin, UNUSED size_t end, - UNUSED size_t *loc) { + UNUSED const size_t *loc) { assert(begin <= end); assert(nfa->type == LBR_NFA_DOT); // Nothing can kill a dot! diff --git a/src/nfa/lbr_common_impl.h b/src/nfa/lbr_common_impl.h index 4f530e6d..8bffa1fc 100644 --- a/src/nfa/lbr_common_impl.h +++ b/src/nfa/lbr_common_impl.h @@ -180,7 +180,7 @@ found_top:; u64a ep = MIN(MIN(end, (s64a)q->length) + offset, first_match); if (ep > sp && sp >= offset) { - size_t eloc; + size_t eloc = 0; DEBUG_PRINTF("rev b%llu e%llu/%zu\n", sp - offset, ep - offset, q->length); assert(ep - offset <= q->length); diff --git a/src/nfagraph/ng_repeat.cpp b/src/nfagraph/ng_repeat.cpp index b94e22a1..4a1c6d30 100644 --- a/src/nfagraph/ng_repeat.cpp +++ b/src/nfagraph/ng_repeat.cpp @@ -662,7 +662,7 @@ void buildTugTrigger(NGHolder &g, NFAVertex cyclic, NFAVertex v, } static -NFAVertex createCyclic(NGHolder &g, ReachSubgraph &rsi) { +NFAVertex createCyclic(NGHolder &g, ReachSubgraph const &rsi) { NFAVertex last = rsi.vertices.back(); NFAVertex cyclic = clone_vertex(g, last); add_edge(cyclic, cyclic, g); @@ -672,7 +672,7 @@ NFAVertex createCyclic(NGHolder &g, ReachSubgraph &rsi) { } static -NFAVertex createPos(NGHolder &g, ReachSubgraph &rsi) { +NFAVertex createPos(NGHolder &g, ReachSubgraph const &rsi) { NFAVertex pos = add_vertex(g); NFAVertex first = rsi.vertices.front(); diff --git a/src/rose/rose_build_dump.cpp b/src/rose/rose_build_dump.cpp index 5c485255..ad57dfc6 100644 --- a/src/rose/rose_build_dump.cpp +++ b/src/rose/rose_build_dump.cpp @@ -861,7 +861,7 @@ void dumpMultipathShufti(ofstream &os, u32 len, const u8 *lo, const u8 *hi, os << endl; } - #define PROGRAM_CASE(name) \ +#define PROGRAM_CASE(name) \ case ROSE_INSTR_##name: { \ os << " " << std::setw(4) << std::setfill('0') << (pc - pc_base) \ << ": " #name "\n"; \ diff --git a/src/rose/rose_build_program.cpp b/src/rose/rose_build_program.cpp index 11c7aba3..4b725146 100644 --- a/src/rose/rose_build_program.cpp +++ b/src/rose/rose_build_program.cpp @@ -763,7 +763,7 @@ void makeRoleSetState(const unordered_map &roleStateIndices, static void makePushDelayedInstructions(const RoseLiteralMap &literals, - ProgramBuild &prog_build, + ProgramBuild const &prog_build, const flat_set &delayed_ids, RoseProgram &program) { vector delay_instructions; @@ -903,7 +903,7 @@ void makeRoleCheckBounds(const RoseBuildImpl &build, RoseVertex v, } static -void makeRoleGroups(const RoseGraph &g, ProgramBuild &prog_build, +void makeRoleGroups(const RoseGraph &g, ProgramBuild const &prog_build, RoseVertex v, RoseProgram &program) { rose_group groups = g[v].groups; if (!groups) { @@ -1020,7 +1020,7 @@ bool makeRoleMask(const vector &look, RoseProgram &program) { } static UNUSED -string convertMaskstoString(u8 *p, int byte_len) { +string convertMaskstoString(u8 const *p, int byte_len) { string s; for (int i = 0; i < byte_len; i++) { u8 hi = *p >> 4; @@ -1625,7 +1625,7 @@ bool hasDelayedLiteral(const RoseBuildImpl &build, static RoseProgram makeLitInitialProgram(const RoseBuildImpl &build, - ProgramBuild &prog_build, u32 lit_id, + ProgramBuild const &prog_build, u32 lit_id, const vector &lit_edges, bool is_anchored_replay_program) { RoseProgram program; @@ -2309,7 +2309,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build, } RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build, - ProgramBuild &prog_build, + ProgramBuild const &prog_build, const vector &lit_ids) { assert(!lit_ids.empty()); assert(build.cc.streaming); diff --git a/src/rose/rose_build_program.h b/src/rose/rose_build_program.h index b8323dc8..c81feb71 100644 --- a/src/rose/rose_build_program.h +++ b/src/rose/rose_build_program.h @@ -243,7 +243,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build, bool is_anchored_replay_program); RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build, - ProgramBuild &prog_build, + ProgramBuild const &prog_build, const std::vector &lit_ids); RoseProgram makeEodAnchorProgram(const RoseBuildImpl &build, diff --git a/unit/internal/fdr.cpp b/unit/internal/fdr.cpp index 3411064b..92340d51 100644 --- a/unit/internal/fdr.cpp +++ b/unit/internal/fdr.cpp @@ -93,7 +93,7 @@ extern "C" { static hwlmcb_rv_t decentCallback(size_t end, u32 id, - UNUSED struct hs_scratch *scratch) { + UNUSED struct hs_scratch *scratch) { // cppcheck-suppress constParameterCallback DEBUG_PRINTF("match @%zu : %u\n", end, id); matches.push_back(match(end, id)); @@ -102,7 +102,7 @@ hwlmcb_rv_t decentCallback(size_t end, u32 id, static hwlmcb_rv_t decentCallbackT(size_t end, u32 id, - UNUSED struct hs_scratch *scratch) { + UNUSED struct hs_scratch *scratch) { // cppcheck-suppress constParameterCallback matches.push_back(match(end, id)); return HWLM_TERMINATE_MATCHING; } diff --git a/unit/internal/fdr_flood.cpp b/unit/internal/fdr_flood.cpp index dbfefb00..e2f48fe9 100644 --- a/unit/internal/fdr_flood.cpp +++ b/unit/internal/fdr_flood.cpp @@ -101,7 +101,7 @@ map matchesCounts; extern "C" { static hwlmcb_rv_t countCallback(UNUSED size_t end, u32 id, - UNUSED struct hs_scratch *scratch) { + UNUSED struct hs_scratch *scratch) { // cppcheck-suppress constParameterCallback matchesCounts[id]++; return HWLM_CONTINUE_MATCHING; } diff --git a/util/string_util.h b/util/string_util.h index 04d778af..a3ceeff8 100644 --- a/util/string_util.h +++ b/util/string_util.h @@ -142,9 +142,9 @@ static really_inline char *makeHex(const unsigned char *pat, unsigned patlen) { size_t hexlen = patlen * 4; char *hexbuf = reinterpret_cast(malloc(hexlen + 1)); - unsigned i; - char *buf; - for (i = 0, buf = hexbuf; i < patlen; i++, buf += 4) { + if (!hexbuf) abort(); + char *buf = hexbuf; + for (size_t i = 0; i < patlen; i++, buf += 4) { snprintf(buf, 5, "\\x%02x", (unsigned char)pat[i]); } hexbuf[hexlen] = '\0';