]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Cppcheck errors fixed and suppressed (#319)
authorgtsoul-tech <56584633+gtsoul-tech@users.noreply.github.com>
Tue, 12 Nov 2024 08:01:11 +0000 (10:01 +0200)
committerGitHub <noreply@github.com>
Tue, 12 Nov 2024 08:01:11 +0000 (10:01 +0200)
* supress knownConditionTrueFalse

* cppcheck suppress redundantInitialization

* cppcheck solve stlcstrStream

* cppcheck suppress useStlAlgorithm

* cppcheck-suppress derefInvalidIteratorRedundantCheck

* cppcheck solvwe constParameterReference

* const parameter reference cppcheck

* removed wrong fix

* cppcheck-suppress memsetClassFloat

* cppcheck fix memsetClassFloat

* cppcheck fix unsignedLessThanZero

* supressing all errors on simde gitmodule

* fix typo (unsignedLessThanZero)

* fix cppcheck suppress simde gitmodule

* cppcheck-suppress unsignedLessThanZero

---------

Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
12 files changed:
cppcheck-suppression-list.txt
src/nfa/accel_dfa_build_strat.cpp
src/nfa/limex_compile.cpp
src/nfagraph/ng_limex.cpp
src/nfagraph/ng_literal_analysis.cpp
src/rose/rose_build_bytecode.cpp
src/rose/rose_build_role_aliasing.cpp
src/util/arch/x86/simd_utils.h
src/util/supervector/arch/x86/impl.cpp
tools/hsbench/engine_hyperscan.cpp
unit/internal/truffle.cpp
unit/internal/uniform_ops.cpp

index aa7fedc638a97f44210fbe7b06e193479fd07e42..79c73fe94ac0f1d0a413c4c7a30ae22321698560 100644 (file)
@@ -3,10 +3,11 @@ knownConditionTrueFalse:*Parser.rl
 knownConditionTrueFalse:*Parser.cpp
 variableScope:*Parser.rl
 unreadVariable:*control_verbs.cpp
+*:*simde/*
 assertWithSideEffect
 syntaxError
 internalError
 checkersReport
 missingInclude
 missingIncludeSystem
-unmatchedSuppression
+unmatchedSuppression
\ No newline at end of file
index ef66432c0a3173c0e9e0f959b5479370143ee8db..ddce0350f043c1b99464f1dbfae594b3336e281e 100644 (file)
@@ -431,6 +431,7 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
 
     DEBUG_PRINTF("accelerations scheme has offset s%u/d%u\n", info.offset,
                  info.double_offset);
+    // cppcheck-suppress redundantInitialization
     accel->generic.offset = verify_u8(info.offset);
 
     if (double_byte_ok(info) && info.double_cr.none() &&
index 39214bd8f165d38a1c9087733d16974e4d9456de..575b299499cb560600db79087adaff9417c1de12 100644 (file)
@@ -331,6 +331,7 @@ void buildReachMapping(const build_info &args, vector<NFAStateSet> &reach,
     vector<NFAVertex> verts;
     verts.reserve(args.num_states);
     auto sidat = [&state_ids=state_ids](const NFAVertex &v) {
+        // cppcheck-suppress knownConditionTrueFalse
         return (state_ids.at(v) != NO_STATE);
     };
     const auto &vr = vertices_range(h);
@@ -921,11 +922,13 @@ void buildAccel(const build_info &args, NFAStateSet &accelMask,
 
     // Start with the NONE case.
     auxvec.emplace_back(AccelAux());
+    // cppcheck-suppress memsetClassFloat
     memset(&auxvec[0], 0, sizeof(AccelAux));
     auxvec[0].accel_type = ACCEL_NONE; // no states on.
 
     AccelAux aux;
     for (u32 i = 1; i < accelCount; i++) {
+        // cppcheck-suppress memsetClassFloat
         memset(&aux, 0, sizeof(aux));
 
         NFAStateSet effective_states(args.num_states);
@@ -1218,10 +1221,11 @@ bool hasSquashableInitDs(const build_info &args) {
 static
 bool hasInitDsStates(const NGHolder &h,
                      const unordered_map<NFAVertex, u32> &state_ids) {
+    // cppcheck-suppress knownConditionTrueFalse
     if (state_ids.at(h.startDs) != NO_STATE) {
         return true;
     }
-
+    // cppcheck-suppress knownConditionTrueFalse
     if (is_triggered(h) && state_ids.at(h.start) != NO_STATE) {
         return true;
     }
@@ -1696,7 +1700,7 @@ static
 bool cannotDie(const build_info &args) {
     const auto &h = args.h;
     const auto &state_ids = args.state_ids;
-
+    // cppcheck-suppress knownConditionTrueFalse
     // If we have a startDs we're actually using, we can't die.
     if (state_ids.at(h.startDs) != NO_STATE) {
         DEBUG_PRINTF("is using startDs\n");
index 0160f6ea1ac8508eb111c51281706a167f361f1c..b97162ce43b31a5e64ab2deb035969113ed845d5 100644 (file)
@@ -512,6 +512,7 @@ set<NFAVertex> findZombies(const NGHolder &h,
     }
 
     for (const auto &v : inv_adjacent_vertices_range(h.accept, h)) {
+        // cppcheck-suppress knownConditionTrueFalse
         if (state_ids.at(v) != NO_STATE) {
             zombies.insert(v);
         }
index 119bd33fd15cf5780d2271ac745c72494275244b..91082d6658fd1bb5d474a294454102d12164cb78 100644 (file)
@@ -262,6 +262,7 @@ static
 bool hasSuffixLiterals(const set<ue2_literal> &s) {
     for (auto it = s.begin(), ite = s.end(); it != ite; ++it) {
         for (auto jt = std::next(it); jt != ite; ++jt) {
+            // cppcheck-suppress useStlAlgorithm
             if (isSuffix(*it, *jt) || isSuffix(*jt, *it)) {
                 DEBUG_PRINTF("'%s' and '%s' have suffix issues\n",
                              dumpString(*it).c_str(),
@@ -530,7 +531,7 @@ void findMinCut(LitGraph &lg, vector<LitEdge> &cutset) {
     vector<s32> distances(num_verts);
     vector<LitEdge> predecessors(num_verts);
     vector<u64a> residuals(num_edges(lg));
-
+    //cppcheck-suppress unreadVariable
     UNUSED u64a flow = boykov_kolmogorov_max_flow(lg,
             get(&LitGraphEdgeProps::score, lg),
             make_iterator_property_map(residuals.begin(), e_index_map),
index c2316f9f0416ff3c57e178640ef2e2f4a4a673d0..217dadb79a0289042c74df035ad72289d73f9175 100644 (file)
@@ -2018,8 +2018,7 @@ void buildCountingMiracles(build_context &bc) {
             continue;
         }
 
-        RoseCountingMiracle rcm;
-        memset(&rcm, 0, sizeof(rcm));
+        RoseCountingMiracle rcm = {}; // Initialize rcm to zero
 
         if (cr.count() == 1) {
             rcm.c = cr.find_first();
@@ -3299,7 +3298,7 @@ void addEodAnchorProgram(const RoseBuildImpl &build, const build_context &bc,
 }
 
 static
-void addEodEventProgram(const RoseBuildImpl &build, build_context &bc,
+void addEodEventProgram(const RoseBuildImpl &build,const build_context &bc,
                         ProgramBuild &prog_build, RoseProgram &program) {
     if (build.eod_event_literal_id == MO_INVALID_IDX) {
         return;
@@ -3336,7 +3335,7 @@ void addEodEventProgram(const RoseBuildImpl &build, build_context &bc,
 }
 
 static
-RoseProgram makeEodProgram(const RoseBuildImpl &build, build_context &bc,
+RoseProgram makeEodProgram(const RoseBuildImpl &build,const build_context &bc,
                            ProgramBuild &prog_build, u32 eodNfaIterOffset) {
     RoseProgram program;
 
index 60ff8384a7ec6709c8a3886774c2493619a20db7..2240a7fdfa78a039df755ed74a01e22f345ecfe9 100644 (file)
@@ -2223,6 +2223,7 @@ void mergeCluster(RoseGraph &g, const ReportManager &rm,
         for (it2 = it;
              it2 != vcluster.end() && cluster.size() < MERGE_GROUP_SIZE_MAX;
              ++it2) {
+            // cppcheck-suppress derefInvalidIteratorRedundantCheck 
             RoseVertex v = *it2;
             NGHolder *h = g[v].suffix.graph.get();
             assert(!g[v].suffix.haig); /* should not be here if haig */
index e39c791be819ef7172f385b020ffa368f22ba3cb..3fbe3f16f305a9b82c0f3679f6ef43f2c27c5ad5 100644 (file)
@@ -127,6 +127,7 @@ static really_really_inline
 m128 lshift64_m128(m128 a, unsigned b) {
 #if defined(HAVE__BUILTIN_CONSTANT_P)
     if (__builtin_constant_p(b)) {
+        // cppcheck-suppress unsignedLessThanZero
         return _mm_slli_epi64(a, b);
     }
 #endif
index 38b8b17956f12ab865beb04fa5db2433230ab05b..3fb54f1eb6137455d0c13a0fec2c227ea717461e 100644 (file)
@@ -339,7 +339,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_16 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_slli_epi16(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_slli_epi16(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -354,7 +354,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_32 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_slli_epi32(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_slli_epi32(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -369,7 +369,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_64 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_slli_epi64(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_slli_epi64(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -384,7 +384,7 @@ really_inline SuperVector<16> SuperVector<16>::vshl_128(uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_slli_si128(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_slli_si128(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -414,7 +414,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_16 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_srli_epi16(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_srli_epi16(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -429,7 +429,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_32 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_srli_epi32(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_srli_epi32(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -444,7 +444,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_64 (uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_srli_epi64(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_srli_epi64(v->u.v128[0], i.value))}; });
     return result;
 }
 
@@ -459,7 +459,7 @@ really_inline SuperVector<16> SuperVector<16>::vshr_128(uint8_t const N) const
     if (N == 0) return *this;
     if (N == 16) return Zeroes();
     SuperVector result;
-    Unroller<1, 16>::iterator([&,v=this](auto const i) { constexpr uint8_t n = i.value; if (N == n) result = {SuperVector<16>(_mm_srli_si128(v->u.v128[0], n))}; });
+    Unroller<1, 16>::iterator([&,v=this](auto const i) { if (N == i.value) result = {SuperVector<16>(_mm_srli_si128(v->u.v128[0], i.value))}; });
     return result;
 }
 
index 218a2d4c0731b0ac2eaa63fb8c85667ee11d621f..c49278e6a65d8c3ff6cda7920d3342d2f5bdd485 100644 (file)
@@ -312,7 +312,7 @@ static
 string dbSettingsHash(const string &filename, u32 mode) {
     ostringstream info_oss;
 
-    info_oss << filename.c_str() << ' ';
+    info_oss << filename << ' ';
     info_oss << mode << ' ';
 
     string info = info_oss.str();
index a7187fe569d11e4b2ab8cede46501227a74d4ed5..3a2d67d69c61a0a8b5ac81ffa09ed68f72ae32e4 100644 (file)
@@ -38,8 +38,8 @@ using namespace ue2;
 
 TEST(Truffle, CompileDot) {
     m128 mask1, mask2;
-    memset(&mask1, 0, sizeof(mask1));
-    memset(&mask2, 0, sizeof(mask2));
+    memset(&mask1, 0, sizeof(mask1)); // cppcheck-suppress memsetClassFloat
+    memset(&mask2, 0, sizeof(mask2)); // cppcheck-suppress memsetClassFloat
 
     CharReach chars;
 
@@ -93,8 +93,8 @@ TEST(Truffle, CompileChars) {
 
 TEST(Truffle, ExecNoMatch1) {
     m128 mask1, mask2;
-    memset(&mask1, 0, sizeof(mask1));
-    memset(&mask2, 0, sizeof(mask2));
+    memset(&mask1, 0, sizeof(mask1)); // cppcheck-suppress memsetClassFloat
+    memset(&mask2, 0, sizeof(mask2)); // cppcheck-suppress memsetClassFloat
 
     CharReach chars;
 
index 17a3f668f836f3b5f4cc33fc1fa1a30634e60894..b1f7b3f2cbf31fbc59a22375782bcdb6854ad549 100644 (file)
@@ -105,7 +105,7 @@ TEST(Uniform, loadstore_m128) {
         u32 words[128/32];
     } in;
     for (int i = 0; i < 128; i++) {
-        memset(&in, 0, sizeof(in));
+        memset(&in, 0, sizeof(in)); // cppcheck-suppress memsetClassFloat
         in.words[i/32] = 1U << (i % 32);
         const char *cin = reinterpret_cast<const char *>(&in);
         m128 out = load_m128(cin);
@@ -123,7 +123,7 @@ TEST(Uniform, loadstore_m256) {
         u32 words[256/32];
     } in;
     for (int i = 0; i < 256; i++) {
-        memset(&in, 0, sizeof(in));
+        memset(&in, 0, sizeof(in)); // cppcheck-suppress memsetClassFloat
         in.words[i/32] = 1U << (i % 32);
         const char *cin = reinterpret_cast<const char *>(&in);
         m256 out = load_m256(cin);
@@ -141,7 +141,7 @@ TEST(Uniform, loadstore_m512) {
         u32 words[512/32];
     } in;
     for (int i = 0; i < 512; i++) {
-        memset(&in, 0, sizeof(in));
+        memset(&in, 0, sizeof(in)); // cppcheck-suppress memsetClassFloat
         in.words[i/32] = 1U << (i % 32);
         const char *cin = reinterpret_cast<const char *>(&in);
         m512 out = load_m512(cin);