Skip to content

Commit

Permalink
fix(userspace/libsinsp): make sure all destructors are invoked
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce authored and poiana committed Dec 1, 2023
1 parent 443bca5 commit 6044d7b
Show file tree
Hide file tree
Showing 23 changed files with 24 additions and 101 deletions.
4 changes: 0 additions & 4 deletions userspace/libsinsp/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ sinsp_container_manager::sinsp_container_manager(sinsp* inspector, bool static_c
{
}

sinsp_container_manager::~sinsp_container_manager()
{
}

bool sinsp_container_manager::remove_inactive_containers()
{
bool res = false;
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class sinsp_container_manager :
const std::string static_name = "",
const std::string static_image = "");

virtual ~sinsp_container_manager();
virtual ~sinsp_container_manager() = default;

/**
* @brief Get the whole container map (read-only)
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class SINSP_PUBLIC sinsp_evt : public gen_event

sinsp_evt();
sinsp_evt(sinsp* inspector);
~sinsp_evt();
virtual ~sinsp_evt();

/*!
\brief Set the inspector.
Expand Down
4 changes: 0 additions & 4 deletions userspace/libsinsp/eventformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,6 @@ sinsp_evt_formatter_factory::sinsp_evt_formatter_factory(sinsp *inspector, filte
{
}

sinsp_evt_formatter_factory::~sinsp_evt_formatter_factory()
{
}

void sinsp_evt_formatter_factory::set_output_format(gen_event_formatter::output_format of)
{
m_formatters.clear();
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/eventformatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SINSP_PUBLIC sinsp_evt_formatter : public gen_event_formatter

void set_format(gen_event_formatter::output_format of, const std::string& fmt) override;

~sinsp_evt_formatter();
virtual ~sinsp_evt_formatter();

/*!
\brief Resolve all the formatted tokens and return them in a key/value
Expand Down Expand Up @@ -121,7 +121,7 @@ class sinsp_evt_formatter_factory : public gen_event_formatter_factory
{
public:
sinsp_evt_formatter_factory(sinsp *inspector, filter_check_list &available_checks);
virtual ~sinsp_evt_formatter_factory();
virtual ~sinsp_evt_formatter_factory() = default;

void set_output_format(gen_event_formatter::output_format of) override;

Expand Down
8 changes: 0 additions & 8 deletions userspace/libsinsp/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ sinsp_filter::sinsp_filter(sinsp *inspector)
m_inspector = inspector;
}

sinsp_filter::~sinsp_filter()
{
}

///////////////////////////////////////////////////////////////////////////////
// sinsp_filter_compiler implementation
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -389,10 +385,6 @@ sinsp_filter_factory::sinsp_filter_factory(sinsp *inspector,
{
}

sinsp_filter_factory::~sinsp_filter_factory()
{
}

gen_event_filter *sinsp_filter_factory::new_filter()
{
return new sinsp_filter(m_inspector);
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SINSP_PUBLIC sinsp_filter : public gen_event_filter
{
public:
sinsp_filter(sinsp* inspector);
~sinsp_filter();
virtual ~sinsp_filter() = default;

private:
sinsp* m_inspector;
Expand Down Expand Up @@ -144,7 +144,7 @@ class sinsp_filter_factory : public gen_event_filter_factory
public:
sinsp_filter_factory(sinsp *inspector, filter_check_list &available_checks);

virtual ~sinsp_filter_factory();
virtual ~sinsp_filter_factory() = default;

gen_event_filter* new_filter() override;
gen_event_filter_check* new_filtercheck(const char* fldname) override;
Expand Down
6 changes: 0 additions & 6 deletions userspace/libsinsp/filter_check_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////
// sinsp_filter_check_list implementation
///////////////////////////////////////////////////////////////////////////////
filter_check_list::filter_check_list()
{
}

filter_check_list::~filter_check_list()
{
Expand Down Expand Up @@ -127,6 +124,3 @@ sinsp_filter_check_list::sinsp_filter_check_list()
add_filter_check(new sinsp_filter_check_evtin());
}

sinsp_filter_check_list::~sinsp_filter_check_list()
{
}
4 changes: 2 additions & 2 deletions userspace/libsinsp/filter_check_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class sinsp;
class filter_check_list
{
public:
filter_check_list();
filter_check_list() = default;
virtual ~filter_check_list();
void add_filter_check(sinsp_filter_check* filter_check);
void get_all_fields(std::vector<const filter_check_info*>& list);
Expand All @@ -48,6 +48,6 @@ class sinsp_filter_check_list : public filter_check_list
{
public:
sinsp_filter_check_list();
virtual ~sinsp_filter_check_list();
virtual ~sinsp_filter_check_list() = default;
};

31 changes: 0 additions & 31 deletions userspace/libsinsp/gen_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ limitations under the License.
#include "sinsp.h"
#include "sinsp_int.h"

gen_event::gen_event()
{
}

gen_event::~gen_event()
{
}

gen_event_filter_check::gen_event_filter_check()
{
}

gen_event_filter_check::~gen_event_filter_check()
{
}

///////////////////////////////////////////////////////////////////////////////
// gen_event_filter_expression implementation
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -459,18 +443,3 @@ std::string gen_event_filter_factory::filter_fieldclass_info::as_string(bool ver
return os.str();
}

gen_event_formatter::gen_event_formatter()
{
}

gen_event_formatter::~gen_event_formatter()
{
}

gen_event_formatter_factory::gen_event_formatter_factory()
{
}

gen_event_formatter_factory::~gen_event_formatter_factory()
{
}
16 changes: 8 additions & 8 deletions userspace/libsinsp/gen_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ enum evt_src
class gen_event
{
public:
gen_event();
virtual ~gen_event();
gen_event() = default;
virtual ~gen_event() = default;

// Every event must expose a timestamp
virtual uint64_t get_ts() const = 0;
Expand All @@ -104,8 +104,8 @@ typedef struct extract_value {
class gen_event_filter_check
{
public:
gen_event_filter_check();
virtual ~gen_event_filter_check();
gen_event_filter_check() = default;
virtual ~gen_event_filter_check() = default;

boolop m_boolop;
cmpop m_cmpop;
Expand Down Expand Up @@ -275,8 +275,8 @@ class gen_event_formatter
OF_JSON = 1
};

gen_event_formatter();
virtual ~gen_event_formatter();
gen_event_formatter() = default;
virtual ~gen_event_formatter() = default;

virtual void set_format(output_format of, const std::string &format) = 0;

Expand All @@ -300,8 +300,8 @@ class gen_event_formatter
class gen_event_formatter_factory
{
public:
gen_event_formatter_factory();
virtual ~gen_event_formatter_factory();
gen_event_formatter_factory() = default;
virtual ~gen_event_formatter_factory() = default;

// This should be called before any calls to
// create_formatter(), and changes the output format of new
Expand Down
8 changes: 0 additions & 8 deletions userspace/libsinsp/prefix_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ limitations under the License.

using namespace std;

path_prefix_search::path_prefix_search()
{
}

path_prefix_search::~path_prefix_search()
{
}

void path_prefix_search::add_search_path(const char *path)
{
bool dummy = true;
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/prefix_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ std::string path_prefix_map<Value>::as_string(const std::string &prefix, bool in
class path_prefix_search : public path_prefix_map<bool>
{
public:
path_prefix_search();
~path_prefix_search();
path_prefix_search() = default;
virtual ~path_prefix_search() = default;

void add_search_path(const char *path);
void add_search_path(const filter_value_t &path);
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
const std::string &static_name = "",
const std::string &static_image = "");

~sinsp() override;
virtual ~sinsp() override;


/* Wrappers to open a specific engine. */
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_filtercheck_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class sinsp_filter_check_event : public sinsp_filter_check
};

sinsp_filter_check_event();
~sinsp_filter_check_event();
virtual ~sinsp_filter_check_event();

sinsp_filter_check* allocate_new() override;
int32_t parse_field_name(const char* str, bool alloc_state, bool needed_for_filtering) override;
Expand Down
4 changes: 0 additions & 4 deletions userspace/libsinsp/sinsp_filtercheck_evtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ sinsp_filter_check_evtin::sinsp_filter_check_evtin()
m_info.m_nfields = sizeof(sinsp_filter_check_evtin_fields) / sizeof(sinsp_filter_check_evtin_fields[0]);
}

sinsp_filter_check_evtin::~sinsp_filter_check_evtin()
{
}

int32_t sinsp_filter_check_evtin::extract_arg(string fldname, string val)
{
uint32_t parsed_len = 0;
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_filtercheck_evtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class sinsp_filter_check_evtin : public sinsp_filter_check
};

sinsp_filter_check_evtin();
~sinsp_filter_check_evtin();
virtual ~sinsp_filter_check_evtin() = default;

sinsp_filter_check* allocate_new() override;
int32_t parse_field_name(const char* str, bool alloc_state, bool needed_for_filtering) override;
Expand Down
4 changes: 0 additions & 4 deletions userspace/libsinsp/sinsp_filtercheck_gen_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ sinsp_filter_check_gen_event::sinsp_filter_check_gen_event()
m_u64val = 0;
}

sinsp_filter_check_gen_event::~sinsp_filter_check_gen_event()
{
}

sinsp_filter_check* sinsp_filter_check_gen_event::allocate_new()
{
return (sinsp_filter_check*) new sinsp_filter_check_gen_event();
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_filtercheck_gen_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class sinsp_filter_check_gen_event : public sinsp_filter_check
};

sinsp_filter_check_gen_event();
~sinsp_filter_check_gen_event();
virtual ~sinsp_filter_check_gen_event() = default;

sinsp_filter_check* allocate_new() override;
uint8_t* extract(sinsp_evt*, OUT uint32_t* len, bool sanitize_strings = true) override;
Expand Down
4 changes: 0 additions & 4 deletions userspace/libsinsp/sinsp_filtercheck_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ sinsp_filter_check_tracer::sinsp_filter_check_tracer()
m_cargname = NULL;
}

sinsp_filter_check_tracer::~sinsp_filter_check_tracer()
{
}

sinsp_filter_check* sinsp_filter_check_tracer::allocate_new()
{
return (sinsp_filter_check*) new sinsp_filter_check_tracer();
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/sinsp_filtercheck_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class sinsp_filter_check_tracer : public sinsp_filter_check
};

sinsp_filter_check_tracer();
~sinsp_filter_check_tracer();
virtual ~sinsp_filter_check_tracer() = default;

sinsp_filter_check* allocate_new() override;
int32_t parse_field_name(const char* str, bool alloc_state, bool needed_for_filtering) override;
Expand Down
4 changes: 0 additions & 4 deletions userspace/libsinsp/token_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ token_bucket::token_bucket(std::function<uint64_t()> timer)
init(1, 1);
}

token_bucket::~token_bucket()
{
}

void token_bucket::init(double rate, double max_tokens, uint64_t now)
{
m_rate = rate;
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/token_bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class token_bucket
public:
token_bucket();
token_bucket(std::function<uint64_t()> timer);
virtual ~token_bucket();
virtual ~token_bucket() = default;

//
// Initialize the token bucket and start accumulating tokens
Expand Down

0 comments on commit 6044d7b

Please sign in to comment.