Merge pull request #279 from VectorCamp/bugfix/cppcheck-unreadVariable-others

Fix marked as done cppcheck warnings unreadVariable & others
This commit is contained in:
Konstantinos Margaritis
2024-05-15 23:18:02 +03:00
committed by GitHub
27 changed files with 54 additions and 52 deletions

View File

@@ -267,7 +267,8 @@ hwlmcb_rv_t playDelaySlot(const struct RoseEngine *t,
const u32 *programs = getByOffset(t, t->delayProgramOffset);
for (u32 it = fatbit_iterate(vicSlot, delay_count, MMB_INVALID);
it != MMB_INVALID; it = fatbit_iterate(vicSlot, delay_count, it)) {
it != MMB_INVALID; it = fatbit_iterate(vicSlot, delay_count, it)) {
// cppcheck-suppress unreadVariable
UNUSED rose_group old_groups = tctxt->groups;
DEBUG_PRINTF("DELAYED MATCH id=%u offset=%llu\n", it, offset);

View File

@@ -1039,9 +1039,9 @@ bool canImplementGraph(NGHolder &h, bool prefilter, const ReportManager &rm,
if (prefilter && cc.grey.prefilterReductions) {
// If we're prefiltering, we can have another go with a reduced graph.
UNUSED size_t numBefore = num_vertices(h);
UNUSED size_t numBefore = num_vertices(h); // cppcheck-suppress unreadVariable
prefilterReductions(h, cc);
UNUSED size_t numAfter = num_vertices(h);
UNUSED size_t numAfter = num_vertices(h); // cppcheck-suppress unreadVariable
DEBUG_PRINTF("reduced from %zu to %zu vertices\n", numBefore, numAfter);
if (isImplementableNFA(h, &rm, cc)) {

View File

@@ -392,8 +392,9 @@ bool validateTransientMask(const vector<CharReach> &mask, bool anchored,
none_of(begin(lits), end(lits), mixed_sensitivity));
// Build the HWLM literal mask.
vector<u8> msk, lcmp;
vector<u8> msk;
if (grey.roseHamsterMasks) {
vector<u8> lcmp;
buildLiteralMask(mask, msk, lcmp, delay);
}

View File

@@ -1901,8 +1901,8 @@ void findExclusiveSuffixes(RoseBuildImpl &tbi, build_context &bc,
// We may have already built this NFA.
if (contains(suffixes, s)) {
u32 id = suffixes[s];
if (!tbi.isInETable(v)) {
u32 id = suffixes[s];
vertex_map[id].emplace_back(v);
}
continue;
@@ -2233,10 +2233,10 @@ vector<u32> buildSuffixEkeyLists(const RoseBuildImpl &build, build_context &bc,
for (const auto &e : bc.suffixes) {
const suffix_id &s = e.first;
u32 qi = e.second;
set<u32> ekeys = reportsToEkeys(all_reports(s), build.rm);
if (!ekeys.empty()) {
u32 qi = e.second;
qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()};
}
}
@@ -2987,7 +2987,7 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
const auto &cfrag = fragments[pfrag.included_frag_id];
/** assert(pfrag.s.length() >= cfrag.s.length() && **/
assert(pfrag.s.length() == cfrag.s.length() &&
!pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
!pfrag.s.any_nocase() != !cfrag.s.any_nocase());
u32 child_offset = cfrag.delay_program_offset;
DEBUG_PRINTF("child %u offset %u\n", cfrag.fragment_id,
child_offset);

View File

@@ -98,8 +98,7 @@ void addToBloomFilter(vector<u8> &bloom, const u8 *substr, bool nocase) {
const auto hash_functions = { bloomHash_1, bloomHash_2, bloomHash_3 };
for (const auto &hash_func : hash_functions) {
u32 hash = hash_func(substr, nocase);
u32 key = hash & key_mask;
u32 key = hash_func(substr, nocase) & key_mask;
DEBUG_PRINTF("set key %u (of %zu)\n", key, bloom.size() * 8);
bloom[key / 8] |= 1U << (key % 8);
}
@@ -193,11 +192,9 @@ vector<RoseLongLitHashEntry> buildHashTable(
}
for (const auto &m : hashToLitOffPairs) {
u32 hash = m.first;
u32 bucket = m.first % numEntries;
const LitOffsetVector &d = m.second;
u32 bucket = hash % numEntries;
// Placement via linear probing.
for (const auto &lit_offset : d) {
while (tab[bucket].str_offset != 0) {

View File

@@ -861,7 +861,6 @@ u32 roseQuality(const RoseResources &res, const RoseEngine *t) {
}
if (eod_prefix) {
always_run++;
DEBUG_PRINTF("eod prefixes are slow");
return 0;
}