]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ddressing some cppcheck warnings. yes this will be cleaned up in a
authorG.E <gregory.economou@vectorcamp.gr>
Tue, 23 Apr 2024 16:08:24 +0000 (19:08 +0300)
committerG.E <gregory.economou@vectorcamp.gr>
Tue, 23 Apr 2024 16:08:24 +0000 (19:08 +0300)
following commit. tests pass.

benchmarks/benchmarks.cpp
src/nfagraph/ng.cpp
src/nfagraph/ng_limex_accel.cpp
src/nfagraph/ng_som_util.cpp
src/rose/rose_build_bytecode.cpp
src/rose/rose_build_castle.cpp
tools/hscheck/main.cpp
util/ExpressionParser.rl
util/ng_corpus_generator.h

index 91cab3f8daec4582ff8540d3953e4b619e56a1f3..d8b77992c2e01b2f5bdc9fba03be4d9233f13a8c 100644 (file)
@@ -113,7 +113,7 @@ static void run_benchmarks(int size, int loops, int max_matches, bool is_reverse
         auto end = std::chrono::steady_clock::now();
         total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
         /*calculate transferred size*/
-        total_size = size * loops;
+        total_size = (u64a)size * (u64a)loops;
         /*calculate average time*/
         avg_time = total_sec / loops;
         /*convert microseconds to seconds*/
index b2a8752361bc454f3ed2146a642d11a7c4126e84..7189baad41148ccc83f6c9568d8d496f34ea6d66 100644 (file)
@@ -193,9 +193,6 @@ void reduceGraph(NGHolder &g, som_type som, bool utf8,
 
     if (!som) {
         mergeCyclicDotStars(g);
-    }
-
-    if (!som) {
         removeSiblingsOfStartDotStar(g);
     }
 }
index 8bac753d902644d19f8a3bbec1bc649cd45a5cec..58149ad3a7467517957bbdde5f2318e0207109d6 100644 (file)
@@ -811,11 +811,11 @@ depth_done:
                 return true;
             }
         }
-    }
+    // } 
 
     // Second option: a two-byte shufti (i.e. less than eight 2-byte
     // literals)
-    if (depth > 1) {
+    // if (depth > 1) {
         for (unsigned int i = 0; i < (depth - 1); i++) {
             if (depthReach[i].count() * depthReach[i+1].count()
                 <= DOUBLE_SHUFTI_LIMIT) {
index 82277c061fe18fe8b4cce5ab73783e17f6d9941b..01beec8d24b745502003368634131def0cb95dae 100644 (file)
@@ -267,17 +267,18 @@ bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
     boost::depth_first_search(c_g, visitor(backEdgeVisitor)
                                    .root_vertex(c_g.start));
 
-    for (const auto &e : be) {
-        NFAVertex s = source(e, c_g);
-        NFAVertex t = target(e, c_g);
-        DEBUG_PRINTF("back edge %zu %zu\n", c_g[s].index, c_g[t].index);
-        if (s != t) {
-            assert(0);
-            DEBUG_PRINTF("eek big cycle\n");
-            rv = true; /* big cycle -> eek */
-            goto exit;
-        }
-    }
+    // with be.clear right above does this ever run at all?
+    //for (const auto &e : be) {
+    //    NFAVertex s = source(e, c_g);
+    //    NFAVertex t = target(e, c_g);
+    //    DEBUG_PRINTF("back edge %zu %zu\n", c_g[s].index, c_g[t].index);
+    //    if (s != t) {
+    //        assert(0);
+    //        DEBUG_PRINTF("eek big cycle\n");
+    //        rv = true; /* big cycle -> eek */
+    //        goto exit;
+    //    }
+    //}
 
     DEBUG_PRINTF("checking acyclic+selfloop graph\n");
 
index 06f36582b38c714f43f0982de0a0ba1ac9de68fe..2df3b3a393d35bab9886a9ca29fc92084e82d495 100644 (file)
@@ -2975,7 +2975,8 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
             !lit_prog.empty()) {
             auto &cfrag = fragments[pfrag.included_frag_id];
             assert(pfrag.s.length() >= cfrag.s.length() &&
-                   !pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
+                   !pfrag.s.any_nocase() == !cfrag.s.any_nocase());
+                   /** !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);
@@ -2993,7 +2994,8 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
         if (pfrag.included_delay_frag_id != INVALID_FRAG_ID &&
             !rebuild_prog.empty()) {
             auto &cfrag = fragments[pfrag.included_delay_frag_id];
-            assert(pfrag.s.length() >= cfrag.s.length() &&
+            /** assert(pfrag.s.length() >= cfrag.s.length() && **/
+            assert(pfrag.s.length() == cfrag.s.length() &&
                    !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,
index f3357982e5f238ae633e2139ce9fa93315c90c54..2a1dcdd972d34bc0b0dea18513a3b51cde8bf720 100644 (file)
@@ -170,7 +170,7 @@ void renovateCastle(RoseBuildImpl &tbi, CastleProto *castle,
                 return; /* bail - TODO: be less lazy */
             }
 
-            vector<CharReach> rem_local_cr;
+            //vector<CharReach> rem_local_cr;
             u32 ok_count = 0;
             for (auto it = e.s.end() - g[v].left.lag; it != e.s.end(); ++it) {
                 if (!isSubsetOf(*it, cr)) {
index f3e9419ac6c2b037508a22f82748ccbc862237fd..2c73baf55e3edebb15b616d37c66bf9a55216c5f 100644 (file)
@@ -97,7 +97,7 @@ unsigned int countFailures = 0;
 
 class ParsedExpr {
 public:
-    ParsedExpr(string regex_in, unsigned int flags_in, hs_expr_ext ext_in)
+    ParsedExpr(string regex_in, unsigned int flags_in, hs_expr_ext& ext_in)
         : regex(regex_in), flags(flags_in), ext(ext_in) {}
     ~ParsedExpr() {}
     string regex;
index b93f069d3e17a2ca2597c5b47957449230a8d231..ad201fec25c4d01d1b43501e9e1b14b4e02dcaf0 100644 (file)
@@ -152,7 +152,7 @@ bool HS_CDECL readExpression(const std::string &input, std::string &expr,
     UNUSED const char *eof = pe;
     UNUSED const char *ts = p, *te = p;
     int cs;
-    UNUSED int act;
+    //UNUSED int act;
 
     assert(p);
     assert(pe);
index f230a10d03b9a3bb648e33741c730d4f13899f95..cd84a9abdca9aea3b328320032a85ca1a57df804 100644 (file)
@@ -47,7 +47,7 @@ class NGHolder;
 } // namespace ue2
 
 struct CorpusGenerationFailure {
-    explicit CorpusGenerationFailure(const std::string s) :
+    explicit CorpusGenerationFailure(const std::string& s) :
         message(std::move(s)) {}
     std::string message;
 };