From bd1f9e5ad978d25925ed8d9061b7217cca33f036 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 30 Nov 2023 09:48:04 +0100 Subject: [PATCH] Fix performance inefficiencies detected by Coverity Scan --- src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- .../conditioner/adapters/array_signal_conditioner.cc | 2 +- .../conditioner/adapters/signal_conditioner.cc | 2 +- .../signal_source/adapters/file_source_base.cc | 10 +++++----- .../signal_source/adapters/gen_signal_source.cc | 2 +- .../gnuradio_blocks/galileo_telemetry_decoder_gs.cc | 4 ++-- .../libs/acquisition_dump_reader.cc | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 1795671a6..80b41440a 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -227,7 +227,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of('/') + 1); dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of('/')); - d_dump_filename = dump_filename_; + d_dump_filename = std::move(dump_filename_); } else { diff --git a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc index 206d76793..02471e8a5 100644 --- a/src/algorithms/conditioner/adapters/array_signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/array_signal_conditioner.cc @@ -73,7 +73,7 @@ void ArraySignalConditioner::disconnect(gr::top_block_sptr top_block) // data_type_adapt_->disconnect(top_block); in_filt_->disconnect(top_block); - res_->disconnect(top_block); + res_->disconnect(std::move(top_block)); connected_ = false; } diff --git a/src/algorithms/conditioner/adapters/signal_conditioner.cc b/src/algorithms/conditioner/adapters/signal_conditioner.cc index ba724abb0..871ed0a51 100644 --- a/src/algorithms/conditioner/adapters/signal_conditioner.cc +++ b/src/algorithms/conditioner/adapters/signal_conditioner.cc @@ -101,7 +101,7 @@ void SignalConditioner::disconnect(gr::top_block_sptr top_block) data_type_adapt_->disconnect(top_block); in_filt_->disconnect(top_block); - res_->disconnect(top_block); + res_->disconnect(std::move(top_block)); connected_ = false; } diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 974d4acac..220f65191 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -186,11 +186,11 @@ void FileSourceBase::connect(gr::top_block_sptr top_block) // DUMP if (sink()) { - top_block->connect(output, 0, sink(), 0); + top_block->connect(std::move(output), 0, sink(), 0); DLOG(INFO) << "connected output to file sink"; } - post_connect_hook(top_block); + post_connect_hook(std::move(top_block)); } @@ -219,7 +219,7 @@ void FileSourceBase::disconnect(gr::top_block_sptr top_block) // VALVE if (valve()) { - top_block->disconnect(input, 0, valve(), 0); + top_block->disconnect(std::move(input), 0, valve(), 0); DLOG(INFO) << "disconnected source to valve"; output = valve(); @@ -234,11 +234,11 @@ void FileSourceBase::disconnect(gr::top_block_sptr top_block) // DUMP if (sink()) { - top_block->disconnect(output, 0, sink(), 0); + top_block->disconnect(std::move(output), 0, sink(), 0); DLOG(INFO) << "disconnected output to file sink"; } - post_disconnect_hook(top_block); + post_disconnect_hook(std::move(top_block)); } diff --git a/src/algorithms/signal_source/adapters/gen_signal_source.cc b/src/algorithms/signal_source/adapters/gen_signal_source.cc index db403234c..a87f77b12 100644 --- a/src/algorithms/signal_source/adapters/gen_signal_source.cc +++ b/src/algorithms/signal_source/adapters/gen_signal_source.cc @@ -70,7 +70,7 @@ void GenSignalSource::disconnect(gr::top_block_sptr top_block) filter_->get_left_block(), 0); signal_generator_->disconnect(top_block); - filter_->disconnect(top_block); + filter_->disconnect(std::move(top_block)); connected_ = false; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index 04c4fc61b..690715725 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -393,7 +393,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in if (page_part_bits[0] == 1) { // DECODE COMPLETE WORD (even + odd) and TEST CRC - d_inav_nav.split_page(page_String, d_flag_even_word_arrived); + d_inav_nav.split_page(std::move(page_String), d_flag_even_word_arrived); if (d_inav_nav.get_flag_CRC_test() == true) { if (d_band == '1') @@ -421,7 +421,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in else { // STORE HALF WORD (even page) - d_inav_nav.split_page(page_String, d_flag_even_word_arrived); + d_inav_nav.split_page(std::move(page_String), d_flag_even_word_arrived); d_flag_even_word_arrived = 1; } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index 07b5ff7a4..6ba023893 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -209,7 +209,7 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, } d_num_doppler_bins = static_cast(ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))); std::vector > mag_aux(d_num_doppler_bins, std::vector(d_samples_per_code)); - mag = mag_aux; + mag = std::move(mag_aux); d_dump_filename = d_basename + "_ch_" + std::to_string(channel) + "_" + std::to_string(execution) + "_sat_" + std::to_string(d_sat) + ".mat"; for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) {