From 2c7bead089ad807364305b96f7d1797a3dcb37fb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Dec 2021 17:03:29 +0100 Subject: [PATCH] Prefer initialization to assignment in constructors --- src/core/monitor/gnss_synchro_monitor.cc | 12 ++++++------ src/core/monitor/gnss_synchro_udp_sink.cc | 7 +++++-- src/core/receiver/control_thread.cc | 16 ++++++++-------- src/core/receiver/file_configuration.cc | 4 ++-- src/core/receiver/gnss_flowgraph.cc | 15 ++++++++------- src/core/receiver/tcp_cmd_interface.cc | 10 +++++----- src/core/system_parameters/gnss_signal.cc | 6 +++--- 7 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/core/monitor/gnss_synchro_monitor.cc b/src/core/monitor/gnss_synchro_monitor.cc index 2f0d7ca96..502a5ed48 100644 --- a/src/core/monitor/gnss_synchro_monitor.cc +++ b/src/core/monitor/gnss_synchro_monitor.cc @@ -42,13 +42,13 @@ gnss_synchro_monitor::gnss_synchro_monitor(int n_channels, int decimation_factor, int udp_port, const std::vector& udp_addresses, - bool enable_protobuf) : gr::block("gnss_synchro_monitor", - gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)), - gr::io_signature::make(0, 0, 0)) + bool enable_protobuf) + : gr::block("gnss_synchro_monitor", + gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)), + gr::io_signature::make(0, 0, 0)), + d_nchannels(n_channels), + d_decimation_factor(decimation_factor) { - d_decimation_factor = decimation_factor; - d_nchannels = n_channels; - udp_sink_ptr = std::make_unique(udp_addresses, udp_port, enable_protobuf); } diff --git a/src/core/monitor/gnss_synchro_udp_sink.cc b/src/core/monitor/gnss_synchro_udp_sink.cc index 3eb61578d..ca613d460 100644 --- a/src/core/monitor/gnss_synchro_udp_sink.cc +++ b/src/core/monitor/gnss_synchro_udp_sink.cc @@ -21,9 +21,12 @@ #include #include -Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(const std::vector& addresses, const uint16_t& port, bool enable_protobuf) : socket{io_context} +Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(const std::vector& addresses, + const uint16_t& port, + bool enable_protobuf) + : socket{io_context}, + use_protobuf(enable_protobuf) { - use_protobuf = enable_protobuf; if (enable_protobuf) { serdes = Serdes_Gnss_Synchro(); diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index cac176f7f..5b0448799 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -129,15 +129,15 @@ ControlThread::ControlThread() ControlThread::ControlThread(std::shared_ptr configuration) + : configuration_(std::move(configuration)), + well_formatted_configuration_(true), + conf_file_has_section_(true), + conf_file_has_mandatory_globals_(true), + conf_has_signal_sources_(true), + conf_has_observables_(true), + conf_has_pvt_(true), + restart_(false) { - configuration_ = std::move(configuration); - conf_file_has_section_ = true; - conf_file_has_mandatory_globals_ = true; - conf_has_signal_sources_ = true; - conf_has_observables_ = true; - conf_has_pvt_ = true; - well_formatted_configuration_ = true; - restart_ = false; init(); } diff --git a/src/core/receiver/file_configuration.cc b/src/core/receiver/file_configuration.cc index 9828a332d..659895934 100644 --- a/src/core/receiver/file_configuration.cc +++ b/src/core/receiver/file_configuration.cc @@ -27,15 +27,15 @@ FileConfiguration::FileConfiguration(std::string filename) + : filename_(std::move(filename)) { - filename_ = std::move(filename); init(); } FileConfiguration::FileConfiguration() + : filename_("./default_config_file.txt") { - filename_ = "./default_config_file.txt"; init(); } diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 3a15b03a0..17292c3f4 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -69,14 +69,15 @@ #define GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS 8 -GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, std::shared_ptr> queue) // NOLINT(performance-unnecessary-value-param) +GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, + std::shared_ptr> queue) // NOLINT(performance-unnecessary-value-param) + : configuration_(std::move(configuration)), + queue_(std::move(queue)), + connected_(false), + running_(false), + multiband_(GNSSFlowgraph::is_multiband()), + enable_e6_has_rx_(false) { - connected_ = false; - running_ = false; - enable_e6_has_rx_ = false; - configuration_ = std::move(configuration); - queue_ = std::move(queue); - multiband_ = GNSSFlowgraph::is_multiband(); enable_fpga_offloading_ = configuration_->property("GNSS-SDR.enable_FPGA", false); init(); } diff --git a/src/core/receiver/tcp_cmd_interface.cc b/src/core/receiver/tcp_cmd_interface.cc index d18a2da62..1a47fb269 100644 --- a/src/core/receiver/tcp_cmd_interface.cc +++ b/src/core/receiver/tcp_cmd_interface.cc @@ -32,14 +32,14 @@ using b_io_context = boost::asio::io_service; #endif TcpCmdInterface::TcpCmdInterface() + : rx_latitude_(0.0), + rx_longitude_(0.0), + rx_altitude_(0.0), + receiver_utc_time_(0), + keep_running_(true) { register_functions(); - keep_running_ = true; control_queue_ = nullptr; - rx_latitude_ = 0.0; - rx_longitude_ = 0.0; - rx_altitude_ = 0.0; - receiver_utc_time_ = 0; } diff --git a/src/core/system_parameters/gnss_signal.cc b/src/core/system_parameters/gnss_signal.cc index f815edd5c..45d54a434 100644 --- a/src/core/system_parameters/gnss_signal.cc +++ b/src/core/system_parameters/gnss_signal.cc @@ -19,15 +19,15 @@ Gnss_Signal::Gnss_Signal(const std::string& signal_) + : signal(signal_) { - this->signal = signal_; } Gnss_Signal::Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_) + : satellite(satellite_), + signal(signal_) { - this->satellite = satellite_; - this->signal = signal_; }