Prefer initialization to assignment in constructors

This commit is contained in:
Carles Fernandez 2021-12-14 17:34:35 +01:00
parent 158abd06db
commit 7fa437232a
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 12 additions and 11 deletions

View File

@ -34,12 +34,16 @@
#include <utility> // for move
Fpga_buffer_monitor::Fpga_buffer_monitor(const std::string &device_name, uint32_t num_freq_bands, bool dump, std::string dump_filename)
Fpga_buffer_monitor::Fpga_buffer_monitor(const std::string &device_name,
uint32_t num_freq_bands,
bool dump,
std::string dump_filename)
: d_dump_filename(std::move(dump_filename)),
d_num_freq_bands(num_freq_bands),
d_max_buff_occ_freq_band_0(0),
d_max_buff_occ_freq_band_1(0),
d_dump(dump)
{
d_num_freq_bands = num_freq_bands;
d_dump = dump;
d_dump_filename = std::move(dump_filename);
// open device descriptor
if ((d_device_descriptor = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1)
{
@ -69,10 +73,6 @@ Fpga_buffer_monitor::Fpga_buffer_monitor(const std::string &device_name, uint32_
DLOG(INFO) << "FPGA buffer monitor class created";
// initialize maximum buffer occupancy in case buffer monitoring is enabled
d_max_buff_occ_freq_band_0 = 0;
d_max_buff_occ_freq_band_1 = 0;
if (d_dump)
{
std::string dump_path;

View File

@ -81,6 +81,9 @@ private:
int32_t buffer_monitor_test_register();
void close_device();
std::string d_dump_filename;
std::ofstream d_dump_file;
volatile unsigned* d_map_base; // driver memory map corresponding to the FPGA buffer monitor
int d_device_descriptor; // driver descriptor corresponding to the FPGA buffer monitor
@ -90,8 +93,6 @@ private:
uint32_t d_max_buff_occ_freq_band_1;
bool d_dump;
std::string d_dump_filename;
std::ofstream d_dump_file;
};