Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c++): add missing explicit to single argument constructors #3069

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion unit_tests/engine/test_add_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace
class test_ruleset_factory : public evttype_index_ruleset_factory
{
public:
test_ruleset_factory(std::shared_ptr<sinsp_filter_factory> factory):
explicit test_ruleset_factory(std::shared_ptr<sinsp_filter_factory> factory):
evttype_index_ruleset_factory(factory)
{
ruleset = evttype_index_ruleset_factory::new_ruleset();
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/engine/test_alt_rule_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class test_reader : public rule_loader::reader
class test_ruleset : public evttype_index_ruleset
{
public:
test_ruleset(std::shared_ptr<sinsp_filter_factory> factory):
explicit test_ruleset(std::shared_ptr<sinsp_filter_factory> factory):
evttype_index_ruleset(factory){};
virtual ~test_ruleset() = default;

Expand Down Expand Up @@ -154,7 +154,7 @@ class test_ruleset : public evttype_index_ruleset
class test_ruleset_factory : public filter_ruleset_factory
{
public:
test_ruleset_factory(std::shared_ptr<sinsp_filter_factory> factory):
explicit test_ruleset_factory(std::shared_ptr<sinsp_filter_factory> factory):
m_filter_factory(factory)
{
}
Expand Down
4 changes: 2 additions & 2 deletions userspace/engine/evttype_index_ruleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ limitations under the License.
class evttype_index_ruleset: public filter_ruleset
{
public:
evttype_index_ruleset(std::shared_ptr<sinsp_filter_factory> factory);
explicit evttype_index_ruleset(std::shared_ptr<sinsp_filter_factory> factory);
virtual ~evttype_index_ruleset();

void add(
Expand Down Expand Up @@ -158,7 +158,7 @@ class evttype_index_ruleset: public filter_ruleset
class evttype_index_ruleset_factory: public filter_ruleset_factory
{
public:
inline evttype_index_ruleset_factory(
inline explicit evttype_index_ruleset_factory(
std::shared_ptr<sinsp_filter_factory> factory
): m_filter_factory(factory) { }

Expand Down
2 changes: 1 addition & 1 deletion userspace/engine/falco_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct falco_exception : std::exception
{
}

falco_exception(std::string error_str)
explicit falco_exception(std::string error_str)
{
m_error_str = error_str;
}
Expand Down
2 changes: 1 addition & 1 deletion userspace/engine/falco_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ limitations under the License.
class falco_engine
{
public:
falco_engine(bool seed_rng=true);
explicit falco_engine(bool seed_rng=true);
virtual ~falco_engine();

// A given engine has a version which identifies the fields
Expand Down
2 changes: 1 addition & 1 deletion userspace/engine/filter_details_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class filter_details_resolver
private:
struct visitor : public libsinsp::filter::ast::expr_visitor
{
visitor(filter_details& details) :
explicit visitor(filter_details& details) :
m_details(details),
m_expect_list(false),
m_expect_macro(false),
Expand Down
16 changes: 8 additions & 8 deletions userspace/engine/rule_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ namespace rule_loader
class result : public falco::load_result
{
public:
result(const std::string &name);
explicit result(const std::string &name);
virtual ~result() = default;
result(result&&) = default;
result& operator = (result&&) = default;
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace rule_loader
struct engine_version_info
{
engine_version_info() : ctx("no-filename-given"), version("0.0.0") { };
engine_version_info(context &ctx);
explicit engine_version_info(context &ctx);
~engine_version_info() = default;
engine_version_info(engine_version_info&&) = default;
engine_version_info& operator = (engine_version_info&&) = default;
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace rule_loader
// a default constructor. This allows it to be used
// by falco_engine, which aliases the type.
plugin_version_info();
plugin_version_info(context &ctx);
explicit plugin_version_info(context &ctx);
~plugin_version_info() = default;
plugin_version_info(plugin_version_info&&) = default;
plugin_version_info& operator = (plugin_version_info&&) = default;
Expand All @@ -345,7 +345,7 @@ namespace rule_loader
*/
struct list_info
{
list_info(context &ctx);
explicit list_info(context &ctx);
~list_info() = default;
list_info(list_info&&) = default;
list_info& operator = (list_info&&) = default;
Expand All @@ -364,7 +364,7 @@ namespace rule_loader
*/
struct macro_info
{
macro_info(context &ctx);
explicit macro_info(context &ctx);
~macro_info() = default;
macro_info(macro_info&&) = default;
macro_info& operator = (macro_info&&) = default;
Expand All @@ -384,7 +384,7 @@ namespace rule_loader
*/
struct rule_exception_info
{
rule_exception_info(context &ctx);
explicit rule_exception_info(context &ctx);
~rule_exception_info() = default;
rule_exception_info(rule_exception_info&&) = default;
rule_exception_info& operator = (rule_exception_info&&) = default;
Expand Down Expand Up @@ -429,7 +429,7 @@ namespace rule_loader
*/
struct rule_info
{
rule_info(context &ctx);
explicit rule_info(context &ctx);
~rule_info() = default;
rule_info(rule_info&&) = default;
rule_info& operator = (rule_info&&) = default;
Expand Down Expand Up @@ -461,7 +461,7 @@ namespace rule_loader

struct rule_update_info
{
rule_update_info(context &ctx);
explicit rule_update_info(context &ctx);
~rule_update_info() = default;
rule_update_info(rule_update_info&&) = default;
rule_update_info& operator = (rule_update_info&&) = default;
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/app/actions/process_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace falco::app::actions;
class source_sync_context
{
public:
source_sync_context(falco::semaphore& s)
explicit source_sync_context(falco::semaphore& s)
: m_finished(false), m_joined(false), m_semaphore(s) { }

inline void finish()
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/app/restart_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class restart_handler
*/
using watch_list_t = std::vector<std::string>;

restart_handler(
explicit restart_handler(
on_check_t on_check,
const watch_list_t& watch_files = {},
const watch_list_t& watch_dirs = {})
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/falco_semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace falco
/**
* @brief Creates a semaphore with the given initial counter value
*/
semaphore(int c = 0): count(c) {}
explicit semaphore(int c = 0): count(c) {}

/**
* @brief Increments the internal counter and unblocks acquirers
Expand Down
6 changes: 3 additions & 3 deletions userspace/falco/grpc_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const std::string meta_request = "request_id";
class context
{
public:
context(::grpc::ServerContext* ctx);
explicit context(::grpc::ServerContext* ctx);
virtual ~context() = default;

void get_metadata(std::string key, std::string& val);
Expand All @@ -49,7 +49,7 @@ class context
class stream_context : public context
{
public:
stream_context(::grpc::ServerContext* ctx):
explicit stream_context(::grpc::ServerContext* ctx):
context(ctx){};
virtual ~stream_context() = default;

Expand All @@ -68,7 +68,7 @@ class stream_context : public context
class bidi_context : public stream_context
{
public:
bidi_context(::grpc::ServerContext* ctx):
explicit bidi_context(::grpc::ServerContext* ctx):
stream_context(ctx){};
virtual ~bidi_context() = default;
};
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/grpc_request_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ template<>
void request_context<version::service, version::request, version::response>::process(server* srv)
{
version::response res;
(srv->*m_process_func)(m_srv_ctx.get(), m_req, res);
(srv->*m_process_func)(context(m_srv_ctx.get()), m_req, res);

// Notify the gRPC runtime that this processing is done
m_state = request_context_base::FINISH;
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/versions_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace falco
* @brief Construct a versions info by using an inspector to obtain
* versions about the drivers and the loaded plugins.
*/
versions_info(const std::shared_ptr<sinsp>& inspector);
explicit versions_info(const std::shared_ptr<sinsp>& inspector);
versions_info(versions_info&&) = default;
versions_info& operator = (versions_info&&) = default;
versions_info(const versions_info& s) = default;
Expand Down
2 changes: 1 addition & 1 deletion userspace/falco/yaml_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class yaml_helper;
class yaml_visitor {
private:
using Callback = std::function<void(YAML::Node&)>;
yaml_visitor(Callback cb): seen(), cb(std::move(cb)) {}
explicit yaml_visitor(Callback cb): seen(), cb(std::move(cb)) {}

void operator()(YAML::Node &cur) {
seen.push_back(cur);
Expand Down
Loading