mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Various cppcheck fixes (#337)
This commit is contained in:
parent
d90ab3ac1c
commit
689556d5f9
@ -51,7 +51,7 @@ struct hlmMatchEntry {
|
|||||||
std::vector<hlmMatchEntry> ctxt;
|
std::vector<hlmMatchEntry> ctxt;
|
||||||
|
|
||||||
static hwlmcb_rv_t hlmSimpleCallback(size_t to, u32 id,
|
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);
|
DEBUG_PRINTF("match @%zu = %u\n", to, id);
|
||||||
|
|
||||||
ctxt.push_back(hlmMatchEntry(to, id));
|
ctxt.push_back(hlmMatchEntry(to, id));
|
||||||
@ -152,7 +152,7 @@ int main(){
|
|||||||
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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(),
|
return shuftiExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -169,7 +169,7 @@ int main(){
|
|||||||
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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(),
|
return rshuftiExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -186,7 +186,7 @@ int main(){
|
|||||||
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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(),
|
return truffleExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -203,7 +203,7 @@ int main(){
|
|||||||
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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(),
|
return rtruffleExec(b.truffle_mask_lo, b.truffle_mask_hi, b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -218,7 +218,7 @@ int main(){
|
|||||||
ue2::truffleBuildMasksWide(b.chars, reinterpret_cast<u8 *>(&b.truffle_mask));
|
ue2::truffleBuildMasksWide(b.chars, reinterpret_cast<u8 *>(&b.truffle_mask));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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);
|
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));
|
ue2::truffleBuildMasksWide(b.chars, reinterpret_cast<u8 *>(&b.truffle_mask));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
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);
|
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));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
memset(b.buf.data(), 'b', b.size);
|
||||||
},
|
},
|
||||||
[&](MicroBenchmark &b) {
|
[&](MicroBenchmark const &b) {
|
||||||
return vermicelliExec('a', 'b', b.buf.data(),
|
return vermicelliExec('a', 'b', b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -268,7 +268,7 @@ int main(){
|
|||||||
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
reinterpret_cast<u8 *>(&b.truffle_mask_hi));
|
||||||
memset(b.buf.data(), 'b', b.size);
|
memset(b.buf.data(), 'b', b.size);
|
||||||
},
|
},
|
||||||
[&](MicroBenchmark &b) {
|
[&](MicroBenchmark const &b) {
|
||||||
return rvermicelliExec('a', 'b', b.buf.data(),
|
return rvermicelliExec('a', 'b', b.buf.data(),
|
||||||
b.buf.data() + b.size);
|
b.buf.data() + b.size);
|
||||||
});
|
});
|
||||||
@ -297,7 +297,7 @@ int main(){
|
|||||||
b.nt = ue2::noodBuildTable(lit);
|
b.nt = ue2::noodBuildTable(lit);
|
||||||
assert(b.nt.get() != nullptr);
|
assert(b.nt.get() != nullptr);
|
||||||
},
|
},
|
||||||
[&](MicroBenchmark &b) {
|
[&](MicroBenchmark &b) { // cppcheck-suppress constParameterReference
|
||||||
noodExec(b.nt.get(), b.buf.data(), b.size, 0,
|
noodExec(b.nt.get(), b.buf.data(), b.size, 0,
|
||||||
hlmSimpleCallback, &b.scratch);
|
hlmSimpleCallback, &b.scratch);
|
||||||
return b.buf.data() + b.size;
|
return b.buf.data() + b.size;
|
||||||
|
@ -2,7 +2,9 @@ unknownMacro:*gtest-all.cc
|
|||||||
knownConditionTrueFalse:*Parser.rl
|
knownConditionTrueFalse:*Parser.rl
|
||||||
knownConditionTrueFalse:*Parser.cpp
|
knownConditionTrueFalse:*Parser.cpp
|
||||||
variableScope:*Parser.rl
|
variableScope:*Parser.rl
|
||||||
|
duplicateBreak:*.rl
|
||||||
unreadVariable:*control_verbs.cpp
|
unreadVariable:*control_verbs.cpp
|
||||||
|
unreachableCode:*rose_build_dump.cpp
|
||||||
*:*simde/*
|
*:*simde/*
|
||||||
assertWithSideEffect
|
assertWithSideEffect
|
||||||
syntaxError
|
syntaxError
|
||||||
|
@ -307,7 +307,7 @@ char lbrMatchLoop(const struct lbr_common *l, const u64a begin, const u64a end,
|
|||||||
static really_inline
|
static really_inline
|
||||||
char lbrRevScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf,
|
char lbrRevScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf,
|
||||||
UNUSED size_t begin, UNUSED size_t end,
|
UNUSED size_t begin, UNUSED size_t end,
|
||||||
UNUSED size_t *loc) {
|
UNUSED const size_t *loc) {
|
||||||
assert(begin <= end);
|
assert(begin <= end);
|
||||||
assert(nfa->type == LBR_NFA_DOT);
|
assert(nfa->type == LBR_NFA_DOT);
|
||||||
// Nothing can kill a dot!
|
// Nothing can kill a dot!
|
||||||
@ -413,7 +413,7 @@ char lbrRevScanTruf(const struct NFA *nfa, const u8 *buf,
|
|||||||
static really_inline
|
static really_inline
|
||||||
char lbrFwdScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf,
|
char lbrFwdScanDot(UNUSED const struct NFA *nfa, UNUSED const u8 *buf,
|
||||||
UNUSED size_t begin, UNUSED size_t end,
|
UNUSED size_t begin, UNUSED size_t end,
|
||||||
UNUSED size_t *loc) {
|
UNUSED const size_t *loc) {
|
||||||
assert(begin <= end);
|
assert(begin <= end);
|
||||||
assert(nfa->type == LBR_NFA_DOT);
|
assert(nfa->type == LBR_NFA_DOT);
|
||||||
// Nothing can kill a dot!
|
// Nothing can kill a dot!
|
||||||
|
@ -180,7 +180,7 @@ found_top:;
|
|||||||
|
|
||||||
u64a ep = MIN(MIN(end, (s64a)q->length) + offset, first_match);
|
u64a ep = MIN(MIN(end, (s64a)q->length) + offset, first_match);
|
||||||
if (ep > sp && sp >= offset) {
|
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,
|
DEBUG_PRINTF("rev b%llu e%llu/%zu\n", sp - offset, ep - offset,
|
||||||
q->length);
|
q->length);
|
||||||
assert(ep - offset <= q->length);
|
assert(ep - offset <= q->length);
|
||||||
|
@ -662,7 +662,7 @@ void buildTugTrigger(NGHolder &g, NFAVertex cyclic, NFAVertex v,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
NFAVertex createCyclic(NGHolder &g, ReachSubgraph &rsi) {
|
NFAVertex createCyclic(NGHolder &g, ReachSubgraph const &rsi) {
|
||||||
NFAVertex last = rsi.vertices.back();
|
NFAVertex last = rsi.vertices.back();
|
||||||
NFAVertex cyclic = clone_vertex(g, last);
|
NFAVertex cyclic = clone_vertex(g, last);
|
||||||
add_edge(cyclic, cyclic, g);
|
add_edge(cyclic, cyclic, g);
|
||||||
@ -672,7 +672,7 @@ NFAVertex createCyclic(NGHolder &g, ReachSubgraph &rsi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
NFAVertex createPos(NGHolder &g, ReachSubgraph &rsi) {
|
NFAVertex createPos(NGHolder &g, ReachSubgraph const &rsi) {
|
||||||
NFAVertex pos = add_vertex(g);
|
NFAVertex pos = add_vertex(g);
|
||||||
NFAVertex first = rsi.vertices.front();
|
NFAVertex first = rsi.vertices.front();
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ void dumpMultipathShufti(ofstream &os, u32 len, const u8 *lo, const u8 *hi,
|
|||||||
os << endl;
|
os << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROGRAM_CASE(name) \
|
#define PROGRAM_CASE(name) \
|
||||||
case ROSE_INSTR_##name: { \
|
case ROSE_INSTR_##name: { \
|
||||||
os << " " << std::setw(4) << std::setfill('0') << (pc - pc_base) \
|
os << " " << std::setw(4) << std::setfill('0') << (pc - pc_base) \
|
||||||
<< ": " #name "\n"; \
|
<< ": " #name "\n"; \
|
||||||
|
@ -763,7 +763,7 @@ void makeRoleSetState(const unordered_map<RoseVertex, u32> &roleStateIndices,
|
|||||||
|
|
||||||
static
|
static
|
||||||
void makePushDelayedInstructions(const RoseLiteralMap &literals,
|
void makePushDelayedInstructions(const RoseLiteralMap &literals,
|
||||||
ProgramBuild &prog_build,
|
ProgramBuild const &prog_build,
|
||||||
const flat_set<u32> &delayed_ids,
|
const flat_set<u32> &delayed_ids,
|
||||||
RoseProgram &program) {
|
RoseProgram &program) {
|
||||||
vector<RoseInstrPushDelayed> delay_instructions;
|
vector<RoseInstrPushDelayed> delay_instructions;
|
||||||
@ -903,7 +903,7 @@ void makeRoleCheckBounds(const RoseBuildImpl &build, RoseVertex v,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void makeRoleGroups(const RoseGraph &g, ProgramBuild &prog_build,
|
void makeRoleGroups(const RoseGraph &g, ProgramBuild const &prog_build,
|
||||||
RoseVertex v, RoseProgram &program) {
|
RoseVertex v, RoseProgram &program) {
|
||||||
rose_group groups = g[v].groups;
|
rose_group groups = g[v].groups;
|
||||||
if (!groups) {
|
if (!groups) {
|
||||||
@ -1020,7 +1020,7 @@ bool makeRoleMask(const vector<LookEntry> &look, RoseProgram &program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static UNUSED
|
static UNUSED
|
||||||
string convertMaskstoString(u8 *p, int byte_len) {
|
string convertMaskstoString(u8 const *p, int byte_len) {
|
||||||
string s;
|
string s;
|
||||||
for (int i = 0; i < byte_len; i++) {
|
for (int i = 0; i < byte_len; i++) {
|
||||||
u8 hi = *p >> 4;
|
u8 hi = *p >> 4;
|
||||||
@ -1625,7 +1625,7 @@ bool hasDelayedLiteral(const RoseBuildImpl &build,
|
|||||||
|
|
||||||
static
|
static
|
||||||
RoseProgram makeLitInitialProgram(const RoseBuildImpl &build,
|
RoseProgram makeLitInitialProgram(const RoseBuildImpl &build,
|
||||||
ProgramBuild &prog_build, u32 lit_id,
|
ProgramBuild const &prog_build, u32 lit_id,
|
||||||
const vector<RoseEdge> &lit_edges,
|
const vector<RoseEdge> &lit_edges,
|
||||||
bool is_anchored_replay_program) {
|
bool is_anchored_replay_program) {
|
||||||
RoseProgram program;
|
RoseProgram program;
|
||||||
@ -2309,7 +2309,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build,
|
|||||||
}
|
}
|
||||||
|
|
||||||
RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build,
|
RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build,
|
||||||
ProgramBuild &prog_build,
|
ProgramBuild const &prog_build,
|
||||||
const vector<u32> &lit_ids) {
|
const vector<u32> &lit_ids) {
|
||||||
assert(!lit_ids.empty());
|
assert(!lit_ids.empty());
|
||||||
assert(build.cc.streaming);
|
assert(build.cc.streaming);
|
||||||
|
@ -243,7 +243,7 @@ RoseProgram makeLiteralProgram(const RoseBuildImpl &build,
|
|||||||
bool is_anchored_replay_program);
|
bool is_anchored_replay_program);
|
||||||
|
|
||||||
RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build,
|
RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build,
|
||||||
ProgramBuild &prog_build,
|
ProgramBuild const &prog_build,
|
||||||
const std::vector<u32> &lit_ids);
|
const std::vector<u32> &lit_ids);
|
||||||
|
|
||||||
RoseProgram makeEodAnchorProgram(const RoseBuildImpl &build,
|
RoseProgram makeEodAnchorProgram(const RoseBuildImpl &build,
|
||||||
|
@ -93,7 +93,7 @@ extern "C" {
|
|||||||
|
|
||||||
static
|
static
|
||||||
hwlmcb_rv_t decentCallback(size_t end, u32 id,
|
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);
|
DEBUG_PRINTF("match @%zu : %u\n", end, id);
|
||||||
|
|
||||||
matches.push_back(match(end, id));
|
matches.push_back(match(end, id));
|
||||||
@ -102,7 +102,7 @@ hwlmcb_rv_t decentCallback(size_t end, u32 id,
|
|||||||
|
|
||||||
static
|
static
|
||||||
hwlmcb_rv_t decentCallbackT(size_t end, u32 id,
|
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));
|
matches.push_back(match(end, id));
|
||||||
return HWLM_TERMINATE_MATCHING;
|
return HWLM_TERMINATE_MATCHING;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ map<u32, int> matchesCounts;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static hwlmcb_rv_t countCallback(UNUSED size_t end, u32 id,
|
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]++;
|
matchesCounts[id]++;
|
||||||
return HWLM_CONTINUE_MATCHING;
|
return HWLM_CONTINUE_MATCHING;
|
||||||
}
|
}
|
||||||
|
@ -142,9 +142,9 @@ static really_inline
|
|||||||
char *makeHex(const unsigned char *pat, unsigned patlen) {
|
char *makeHex(const unsigned char *pat, unsigned patlen) {
|
||||||
size_t hexlen = patlen * 4;
|
size_t hexlen = patlen * 4;
|
||||||
char *hexbuf = reinterpret_cast<char *>(malloc(hexlen + 1));
|
char *hexbuf = reinterpret_cast<char *>(malloc(hexlen + 1));
|
||||||
unsigned i;
|
if (!hexbuf) abort();
|
||||||
char *buf;
|
char *buf = hexbuf;
|
||||||
for (i = 0, buf = hexbuf; i < patlen; i++, buf += 4) {
|
for (size_t i = 0; i < patlen; i++, buf += 4) {
|
||||||
snprintf(buf, 5, "\\x%02x", (unsigned char)pat[i]);
|
snprintf(buf, 5, "\\x%02x", (unsigned char)pat[i]);
|
||||||
}
|
}
|
||||||
hexbuf[hexlen] = '\0';
|
hexbuf[hexlen] = '\0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user