Various cppcheck fixes (#337)

This commit is contained in:
Konstantinos Margaritis 2025-05-30 12:27:28 +03:00 committed by GitHub
parent d90ab3ac1c
commit 689556d5f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 31 additions and 29 deletions

View File

@ -51,7 +51,7 @@ struct hlmMatchEntry {
std::vector<hlmMatchEntry> 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<u8 *>(&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<u8 *>(&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<u8 *>(&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<u8 *>(&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<u8 *>(&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<u8 *>(&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<u8 *>(&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<u8 *>(&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;

View File

@ -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

View File

@ -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!

View File

@ -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);

View File

@ -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();

View File

@ -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"; \

View File

@ -763,7 +763,7 @@ void makeRoleSetState(const unordered_map<RoseVertex, u32> &roleStateIndices,
static
void makePushDelayedInstructions(const RoseLiteralMap &literals,
ProgramBuild &prog_build,
ProgramBuild const &prog_build,
const flat_set<u32> &delayed_ids,
RoseProgram &program) {
vector<RoseInstrPushDelayed> 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<LookEntry> &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<RoseEdge> &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<u32> &lit_ids) {
assert(!lit_ids.empty());
assert(build.cc.streaming);

View File

@ -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<u32> &lit_ids);
RoseProgram makeEodAnchorProgram(const RoseBuildImpl &build,

View File

@ -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;
}

View File

@ -101,7 +101,7 @@ map<u32, int> 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;
}

View File

@ -142,9 +142,9 @@ static really_inline
char *makeHex(const unsigned char *pat, unsigned patlen) {
size_t hexlen = patlen * 4;
char *hexbuf = reinterpret_cast<char *>(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';