]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4111: Make add_peg_count and set_peg_count protected to be available...
authorSai Srinivas Dunne (sadunne) <sadunne@cisco.com>
Wed, 29 Nov 2023 07:13:30 +0000 (07:13 +0000)
committerBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Wed, 29 Nov 2023 07:13:30 +0000 (07:13 +0000)
Merge in SNORT/snort3 from ~SADUNNE/snort3:sadunne_counter_fix to master

Squashed commit of the following:

commit 7508e2410ece25983e2865bc26a69f957b470b74
Author: Sai Srinivas Dunne <sadunne@cisco.com>
Date:   Fri Nov 24 17:51:24 2023 +0530

    perf_mon: fix variable name issue reported by cppcheck

commit ce868f78ddc45a11b2402a321587a8de06fd4e9d
Author: Sai Srinivas Dunne <sadunne@cisco.com>
Date:   Fri Nov 24 11:46:43 2023 +0530

    pegs: Make add_peg_count and set_peg_count protected to be available for
    the derived class.

src/framework/module.h
src/network_inspectors/perf_monitor/base_tracker.cc

index e1c3001f3271d3ddc8e7052cd5b240001b7e47db..7615f81fc3b24a5c5e57df6594ff40607a7750c0 100644 (file)
@@ -206,21 +206,10 @@ protected:
 
     bool dump_stats_initialized = false;
 
-private:
-    friend ModuleManager;
-    void init(const char*, const char* = nullptr);
-
     std::vector<PegCount> counts;
     std::vector<PegCount> dump_stats_counts;
     int num_counts = -1;
 
-    const char* name;
-    const char* help;
-
-    const Parameter* params;
-    bool list;
-    int table_level = 0;
-
     void set_peg_count(int index, PegCount value, bool dump_stats = false)
     {
         assert(index < num_counts);
@@ -230,6 +219,26 @@ private:
             counts[index] = value;
     }
 
+    void add_peg_count(int index, PegCount value, bool dump_stats = false)
+    {
+        assert(index < num_counts);
+        if(dump_stats)
+            dump_stats_counts[index] += value;
+        else
+            counts[index] += value;
+    }
+
+private:
+    friend ModuleManager;
+    void init(const char*, const char* = nullptr);
+
+    const char* name;
+    const char* help;
+
+    const Parameter* params;
+    bool list;
+    int table_level = 0;
+
     void set_max_peg_count(int index, PegCount value, bool dump_stats = false)
     {
         assert(index < num_counts);
@@ -244,16 +253,6 @@ private:
                 counts[index] = value;
         }
     }
-
-    void add_peg_count(int index, PegCount value, bool dump_stats = false)
-    {
-        assert(index < num_counts);
-        if(dump_stats)
-            dump_stats_counts[index] += value;
-        else
-            counts[index] += value;
-
-    }
 };
 }
 #endif
index ae8de643bf9517d545c5ea99663c715fd9bdc0ae..3b783407055e76ad69de3fab2d26c26b24ffa230 100644 (file)
@@ -71,17 +71,17 @@ class MockModule : public Module
 public:
     MockModule() : Module("mockery", "mockery")
     {
-        counts = (PegCount*)snort_alloc(5 * sizeof(PegCount));
+        mock_counts = (PegCount*)snort_alloc(5 * sizeof(PegCount));
 
         for( unsigned i = 0; i < 5; i++ )
-            counts[i] = i;
+            mock_counts[i] = i;
     }
 
-    ~MockModule() override { snort_free(counts); }
+    ~MockModule() override { snort_free(mock_counts); }
 
     const PegInfo* get_pegs() const override { return pegs; }
 
-    PegCount* get_counts() const override { return counts; }
+    PegCount* get_counts() const override { return mock_counts; }
 
     void sum_stats(bool) override {}
 
@@ -91,7 +91,7 @@ public:
     { return INSPECT; }
 
 private:
-    PegCount* counts;
+    PegCount* mock_counts;
 
     PegInfo pegs[6] =
     {