Skip to content

Commit

Permalink
fix(c++): move trivial initializations to declaration site
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaist committed Feb 11, 2024
1 parent d034dd5 commit 99b7518
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
4 changes: 1 addition & 3 deletions userspace/falco/stats_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ stats_writer::ticker_t stats_writer::get_ticker()
stats_writer::stats_writer(
const std::shared_ptr<falco_outputs>& outputs,
const std::shared_ptr<const falco_configuration>& config)
: m_initialized(false)
, m_total_samples(0)
, m_config(config)
: m_config(config)
{
if (config->m_metrics_enabled)
{
Expand Down
4 changes: 2 additions & 2 deletions userspace/falco/stats_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class stats_writer
void stop_worker();
inline void push(const stats_writer::msg& m);

bool m_initialized;
uint64_t m_total_samples;
bool m_initialized = false;
uint64_t m_total_samples = 0;
std::thread m_worker;
std::ofstream m_file_output;
#ifndef __EMSCRIPTEN__
Expand Down
10 changes: 1 addition & 9 deletions userspace/falco/versions_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ limitations under the License.

#include "versions_info.h"

#include "config_falco.h"
#include "falco_engine_version.h"

#include <libsinsp/plugin_manager.h>

// todo: move string conversion to scap
Expand Down Expand Up @@ -49,14 +46,9 @@ static inline std::string get_driver_schema_version(const std::shared_ptr<sinsp>
}

falco::versions_info::versions_info(const std::shared_ptr<sinsp>& inspector)
: falco_version(FALCO_VERSION)
, engine_version(FALCO_ENGINE_VERSION)
, libs_version(FALCOSECURITY_LIBS_VERSION)
, plugin_api_version(inspector->get_plugin_api_version())
: plugin_api_version(inspector->get_plugin_api_version())
, driver_api_version(get_driver_api_version(inspector))
, driver_schema_version(get_driver_schema_version(inspector))
, default_driver_version(DRIVER_VERSION)

{
for (const auto &p : inspector->get_plugin_manager()->plugins())
{
Expand Down
11 changes: 7 additions & 4 deletions userspace/falco/versions_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ limitations under the License.
#include <libsinsp/sinsp.h>
#include <nlohmann/json.hpp>

#include "config_falco.h"
#include "falco_engine_version.h"

namespace falco
{
/**
Expand All @@ -45,13 +48,13 @@ namespace falco
*/
nlohmann::json as_json() const;

std::string falco_version;
std::string engine_version;
std::string libs_version;
std::string falco_version = FALCO_VERSION;
std::string engine_version = FALCO_ENGINE_VERSION;
std::string libs_version = FALCOSECURITY_LIBS_VERSION;
std::string plugin_api_version;
std::string driver_api_version;
std::string driver_schema_version;
std::string default_driver_version;
std::string default_driver_version = DRIVER_VERSION;
std::unordered_map<std::string, std::string> plugin_versions;
};
};

0 comments on commit 99b7518

Please sign in to comment.