From 1e86789bf63785312175a4d1382a9619c41c959a Mon Sep 17 00:00:00 2001 From: Federico Aponte Date: Mon, 18 Dec 2023 10:41:26 +0100 Subject: [PATCH] build: Make a few more functions const Signed-off-by: Federico Aponte --- userspace/libsinsp/sinsp.cpp | 24 +++++++++++------------- userspace/libsinsp/sinsp.h | 5 +++-- userspace/libsinsp/sinsp_cycledumper.cpp | 2 +- userspace/libsinsp/sinsp_cycledumper.h | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/userspace/libsinsp/sinsp.cpp b/userspace/libsinsp/sinsp.cpp index eb4d24d7b1..64db63608c 100644 --- a/userspace/libsinsp/sinsp.cpp +++ b/userspace/libsinsp/sinsp.cpp @@ -691,7 +691,7 @@ void sinsp::open_test_input(scap_test_input_data* data, sinsp_mode_t mode) /*=============================== Engine related ===============================*/ -bool sinsp::check_current_engine(const std::string& engine_name) +bool sinsp::check_current_engine(const std::string& engine_name) const { return scap_check_current_engine(m_h, engine_name.data()); } @@ -1823,11 +1823,21 @@ scap_stats_v2* sinsp::get_sinsp_stats_v2_buffer() return m_sinsp_stats_v2_buffer; } +const scap_stats_v2* sinsp::get_sinsp_stats_v2_buffer() const +{ + return m_sinsp_stats_v2_buffer; +} + std::shared_ptr sinsp::get_sinsp_stats_v2() { return m_sinsp_stats_v2; } +std::shared_ptr sinsp::get_sinsp_stats_v2() const +{ + return m_sinsp_stats_v2; +} + sinsp_filter_check* sinsp::new_generic_filtercheck() { return new sinsp_filter_check_gen_event(); @@ -1984,18 +1994,6 @@ sinsp_parser* sinsp::get_parser() return m_parser; } -bool sinsp::setup_cycle_writer(std::string base_file_name, int rollover_mb, int duration_seconds, int file_limit, unsigned long event_limit, bool compress) -{ - m_compress = compress; - - if(rollover_mb != 0 || duration_seconds != 0 || file_limit != 0 || event_limit != 0) - { - m_write_cycling = true; - } - - return m_cycle_writer->setup(base_file_name, rollover_mb, duration_seconds, file_limit, event_limit); -} - double sinsp::get_read_progress_file() const { if(m_input_fd != 0) diff --git a/userspace/libsinsp/sinsp.h b/userspace/libsinsp/sinsp.h index c4628a94d4..21907e697a 100644 --- a/userspace/libsinsp/sinsp.h +++ b/userspace/libsinsp/sinsp.h @@ -455,6 +455,7 @@ class SINSP_PUBLIC sinsp : public capture_stats_source \note sinsp stats may be refactored near-term. */ scap_stats_v2* get_sinsp_stats_v2_buffer(); + const scap_stats_v2* get_sinsp_stats_v2_buffer() const; /*! \brief Return sinsp stats v2 containing continually updated counters around thread and fd state tables. @@ -462,6 +463,7 @@ class SINSP_PUBLIC sinsp : public capture_stats_source \note sinsp stats may be refactored near-term. */ std::shared_ptr get_sinsp_stats_v2(); + std::shared_ptr get_sinsp_stats_v2() const; /*! \brief Look up a thread given its tid and return its information, @@ -830,11 +832,10 @@ class SINSP_PUBLIC sinsp : public capture_stats_source * @param engine_name engine that we want to check. * @return true if the passed engine is the active one otherwise false. */ - bool check_current_engine(const std::string& engine_name); + bool check_current_engine(const std::string& engine_name) const; /*=============================== Engine related ===============================*/ - bool setup_cycle_writer(std::string base_file_name, int rollover_mb, int duration_seconds, int file_limit, unsigned long event_limit, bool compress); void import_ipv4_interface(const sinsp_ipv4_ifinfo& ifinfo); uint64_t get_bytes_read() const diff --git a/userspace/libsinsp/sinsp_cycledumper.cpp b/userspace/libsinsp/sinsp_cycledumper.cpp index 196cd17db6..d2a2595fb9 100644 --- a/userspace/libsinsp/sinsp_cycledumper.cpp +++ b/userspace/libsinsp/sinsp_cycledumper.cpp @@ -213,7 +213,7 @@ void sinsp_cycledumper::next_file() m_file_index++; } -bool sinsp_cycledumper::is_new_file_needed(sinsp_evt* evt) const +bool sinsp_cycledumper::is_new_file_needed(sinsp_evt* evt) { m_event_count++; diff --git a/userspace/libsinsp/sinsp_cycledumper.h b/userspace/libsinsp/sinsp_cycledumper.h index be231aad80..873bf243bf 100644 --- a/userspace/libsinsp/sinsp_cycledumper.h +++ b/userspace/libsinsp/sinsp_cycledumper.h @@ -87,7 +87,7 @@ class SINSP_PUBLIC sinsp_cycledumper at the current time. The reason for the return code is written to m_last_reason. */ - bool is_new_file_needed(sinsp_evt*) const; + bool is_new_file_needed(sinsp_evt* evt); /*! \brief Setups the new current filename.