From: Sai Srinivas Dunne (sadunne) Date: Wed, 29 Nov 2023 07:13:30 +0000 (+0000) Subject: Pull request #4111: Make add_peg_count and set_peg_count protected to be available... X-Git-Tag: 3.1.76.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f2b76d8e607f2bd6490e995996af85602a76c55;p=thirdparty%2Fsnort3.git Pull request #4111: Make add_peg_count and set_peg_count protected to be available for the derived class Merge in SNORT/snort3 from ~SADUNNE/snort3:sadunne_counter_fix to master Squashed commit of the following: commit 7508e2410ece25983e2865bc26a69f957b470b74 Author: Sai Srinivas Dunne Date: Fri Nov 24 17:51:24 2023 +0530 perf_mon: fix variable name issue reported by cppcheck commit ce868f78ddc45a11b2402a321587a8de06fd4e9d Author: Sai Srinivas Dunne 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. --- diff --git a/src/framework/module.h b/src/framework/module.h index e1c3001f3..7615f81fc 100644 --- a/src/framework/module.h +++ b/src/framework/module.h @@ -206,21 +206,10 @@ protected: bool dump_stats_initialized = false; -private: - friend ModuleManager; - void init(const char*, const char* = nullptr); - std::vector counts; std::vector 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 diff --git a/src/network_inspectors/perf_monitor/base_tracker.cc b/src/network_inspectors/perf_monitor/base_tracker.cc index ae8de643b..3b7834070 100644 --- a/src/network_inspectors/perf_monitor/base_tracker.cc +++ b/src/network_inspectors/perf_monitor/base_tracker.cc @@ -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] = {