Skip to content

Commit

Permalink
build: Make a few more functions const
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <[email protected]>
  • Loading branch information
federico-sysdig authored and poiana committed Jan 19, 2024
1 parent d6b5e12 commit 1e86789
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
24 changes: 11 additions & 13 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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_stats_v2> sinsp::get_sinsp_stats_v2()
{
return m_sinsp_stats_v2;
}

std::shared_ptr<const sinsp_stats_v2> 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();
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,15 @@ 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.
\note sinsp stats may be refactored near-term.
*/
std::shared_ptr<sinsp_stats_v2> get_sinsp_stats_v2();
std::shared_ptr<const sinsp_stats_v2> get_sinsp_stats_v2() const;

/*!
\brief Look up a thread given its tid and return its information,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_cycledumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_cycledumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1e86789

Please sign in to comment.