mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-21 03:16:40 +03:00
Fix/Suppress remaining Cppcheck warnings (#291)
Fix/suppress the following cppcheck warnings: * arithOperationsOnVoidPointer * uninitMember * const* * shadowVariable * assignmentIntegerToAddress * containerOutOfBounds * pointer-related warnings in Ragel source * missingOverride * memleak * knownConditionTrueFalse * noExplicitConstructor * invalidPrintfArgType_sint * useStlAlgorithm * cstyleCast * clarifyCondition * VSX-related cstyleCast * unsignedLessThanZero Furthermore, we added a suppression list to be used, which also includes the following: * missingIncludeSystem * missingInclude * unmatchedSuppression
This commit is contained in:
committed by
GitHub
parent
cebc6541c1
commit
c837925087
@@ -1496,6 +1496,7 @@ void transformSuffixDelay(RoseInGraph &ig, const CompileContext &cc) {
|
||||
#ifndef NDEBUG
|
||||
static
|
||||
bool validateKinds(const RoseInGraph &g) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &e : edges_range(g)) {
|
||||
if (g[e].graph && g[e].graph->kind != whatRoseIsThis(g, e)) {
|
||||
return false;
|
||||
@@ -1934,10 +1935,9 @@ bool RoseBuildImpl::addAnchoredAcyclic(const NGHolder &h) {
|
||||
flat_set<u32> added_lit_ids; /* literal ids added for this NFA */
|
||||
|
||||
for (auto v : inv_adjacent_vertices_range(h.accept, h)) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (!prepAcceptForAddAnchoredNFA(*this, h, v, vertexDepths, depthMap,
|
||||
reportMap, allocated_reports,
|
||||
added_lit_ids)) {
|
||||
added_lit_ids)) { // cppcheck-suppress useStlAlgorithm
|
||||
removeAddedLiterals(*this, added_lit_ids);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ bool expandFmlCandidates(const CharReach &cr, vector<ue2_literal> &curr,
|
||||
}
|
||||
}
|
||||
|
||||
if (curr.back().length() > MAX_MASK2_WIDTH &&
|
||||
if (!curr.empty() && curr.back().length() > MAX_MASK2_WIDTH &&
|
||||
any_of(begin(curr), end(curr), mixed_sensitivity)) {
|
||||
DEBUG_PRINTF("mixed-sensitivity lit is too long, stopping\n");
|
||||
return false;
|
||||
|
||||
@@ -2457,6 +2457,7 @@ bool hasEodAnchors(const RoseBuildImpl &build, const build_context &bc,
|
||||
}
|
||||
|
||||
const RoseGraph &g = build.g;
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (auto v : vertices_range(g)) {
|
||||
if (g[v].eod_accept) {
|
||||
DEBUG_PRINTF("literally report eod\n");
|
||||
@@ -2975,8 +2976,8 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
|
||||
if (pfrag.included_frag_id != INVALID_FRAG_ID &&
|
||||
!lit_prog.empty()) {
|
||||
const auto &cfrag = fragments[pfrag.included_frag_id];
|
||||
assert(pfrag.s.length() >= cfrag.s.length() &&
|
||||
!pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
|
||||
// cppcheck-suppress comparisonOfTwoFuncsReturningBoolError
|
||||
assert(pfrag.s.length() >= cfrag.s.length() && !pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
|
||||
u32 child_offset = cfrag.lit_program_offset;
|
||||
DEBUG_PRINTF("child %u offset %u\n", cfrag.fragment_id,
|
||||
child_offset);
|
||||
|
||||
@@ -1325,10 +1325,8 @@ void rehomeAnchoredLiteral(RoseBuildImpl &tbi, const simple_anchored_info &sai,
|
||||
/* ensure bounds on the vertex's in-edge are correct */
|
||||
assert(in_degree(v, tbi.g) == 1);
|
||||
const RoseEdge &e = *in_edges(v, tbi.g).first;
|
||||
assert(tbi.g[e].minBound == sai.min_bound + sai.literal.length());
|
||||
assert(tbi.g[e].maxBound == sai.max_bound + sai.literal.length());
|
||||
tbi.g[e].minBound = sai.min_bound;
|
||||
tbi.g[e].maxBound = sai.max_bound;
|
||||
tbi.g[e].minBound = sai.min_bound; // cppcheck-suppress danglingTempReference
|
||||
tbi.g[e].maxBound = sai.max_bound; // cppcheck-suppress danglingTempReference
|
||||
}
|
||||
|
||||
/* mark the old literal as empty */
|
||||
@@ -1632,6 +1630,7 @@ void addAnchoredSmallBlockLiterals(RoseBuildImpl &tbi) {
|
||||
#ifndef NDEBUG
|
||||
static
|
||||
bool historiesAreValid(const RoseGraph &g) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &e : edges_range(g)) {
|
||||
if (g[e].history == ROSE_ROLE_HISTORY_INVALID) {
|
||||
DEBUG_PRINTF("edge [%zu,%zu] has invalid history\n",
|
||||
@@ -1648,7 +1647,7 @@ bool historiesAreValid(const RoseGraph &g) {
|
||||
* that no longer exists in the graph.
|
||||
*/
|
||||
static
|
||||
bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
bool danglingVertexRef(const RoseBuildImpl &tbi) {
|
||||
RoseGraph::vertex_iterator vi, ve;
|
||||
tie(vi, ve) = vertices(tbi.g);
|
||||
const unordered_set<RoseVertex> valid_vertices(vi, ve);
|
||||
@@ -1659,6 +1658,7 @@ bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &e : tbi.ghost) {
|
||||
if (!contains(valid_vertices, e.first)) {
|
||||
DEBUG_PRINTF("ghost key vertex %zu not in graph\n",
|
||||
@@ -1677,6 +1677,7 @@ bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
|
||||
static
|
||||
bool roleOffsetsAreValid(const RoseGraph &g) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (auto v : vertices_range(g)) {
|
||||
if (g[v].min_offset >= ROSE_BOUND_INF) {
|
||||
DEBUG_PRINTF("invalid min_offset for role %zu\n", g[v].index);
|
||||
|
||||
@@ -1421,6 +1421,7 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
|
||||
os << " base_offset " << ri->base_offset << endl;
|
||||
os << " last_start " << ri->last_start << endl;
|
||||
os << " fail_jump " << offset + ri->fail_jump << endl;
|
||||
// cppcheck-suppress pointerOutOfBounds
|
||||
dumpMultipathShufti(os, 16, ri->nib_mask, ri->nib_mask + 16,
|
||||
ri->bucket_select_mask,
|
||||
ri->data_select_mask,
|
||||
@@ -1868,6 +1869,7 @@ void dumpComponentInfoCsv(const RoseEngine *t, const string &base) {
|
||||
}
|
||||
}
|
||||
|
||||
// cppcheck-suppress invalidPrintfArgType_sint
|
||||
fprintf(f, "%u,%zd,\"%s\",%u,%u,%u,%s,%s\n", i,
|
||||
(reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(t)), describe(*n).c_str(),
|
||||
n->nPositions, n->streamStateSize, n->length,
|
||||
|
||||
@@ -140,6 +140,7 @@ static
|
||||
bool isSuffix(const vector<vector<CharReach>> &triggers1,
|
||||
const vector<vector<CharReach>> &triggers2) {
|
||||
// literal suffix test
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &lit1 : triggers1) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &lit2 : triggers2) {
|
||||
|
||||
@@ -1027,6 +1027,7 @@ bool hasOrphanedTops(const RoseBuildImpl &build) {
|
||||
}
|
||||
|
||||
for (const auto &e : leftfixes) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (all_tops(e.first) != e.second) {
|
||||
DEBUG_PRINTF("rose tops (%s) don't match rose graph (%s)\n",
|
||||
as_string_list(all_tops(e.first)).c_str(),
|
||||
@@ -1036,6 +1037,7 @@ bool hasOrphanedTops(const RoseBuildImpl &build) {
|
||||
}
|
||||
|
||||
for (const auto &e : suffixes) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (all_tops(e.first) != e.second) {
|
||||
DEBUG_PRINTF("suffix tops (%s) don't match rose graph (%s)\n",
|
||||
as_string_list(all_tops(e.first)).c_str(),
|
||||
|
||||
@@ -737,8 +737,8 @@ void pruneReportIfUnused(const RoseBuildImpl &build, shared_ptr<NGHolder> h,
|
||||
DEBUG_PRINTF("trying to prune %u from %p (v %zu)\n", report, h.get(),
|
||||
verts.size());
|
||||
for (RoseVertex v : verts) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (build.g[v].left.graph == h &&
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
build.g[v].left.leftfix_report == report) {
|
||||
DEBUG_PRINTF("report %u still in use\n", report);
|
||||
return;
|
||||
|
||||
@@ -65,7 +65,7 @@ u32 findMinWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
|
||||
const RoseGraph &g = tbi.g;
|
||||
|
||||
vector<RoseVertex> table_verts;
|
||||
auto tvs = [&tbi=tbi, &table=table](const RoseVertex &v) {
|
||||
auto tvs = [&tbi=tbi, table](const RoseVertex &v) {
|
||||
return (tbi.hasLiteralInTable(v, table));
|
||||
};
|
||||
const auto &vr = vertices_range(g);
|
||||
@@ -189,7 +189,7 @@ u32 findMaxBAWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
|
||||
table == ROSE_FLOATING ? "floating" : "anchored");
|
||||
|
||||
vector<RoseVertex> table_verts;
|
||||
auto tvs = [&tbi=tbi, &table=table](const RoseVertex &v) {
|
||||
auto tvs = [&tbi=tbi, table](const RoseVertex &v) {
|
||||
return ((table == ROSE_FLOATING && tbi.isFloating(v))
|
||||
|| (table == ROSE_ANCHORED && tbi.isAnchored(v)));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user