From 4b60f8a7f2d836419914af82e53400ed4b2dc872 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Dec 2023 10:19:39 +0100 Subject: [PATCH] Fix performance inefficiencies detected by Coverity Scan --- src/algorithms/PVT/libs/rinex_printer.cc | 2 +- .../signal_source/adapters/file_source_base.cc | 2 +- .../control-plane/file_configuration_test.cc | 7 ++++--- .../control-plane/gnss_block_factory_test.cc | 3 ++- .../control-plane/gnss_flowgraph_test.cc | 9 +++++---- .../filter/fir_filter_test.cc | 3 ++- .../filter/notch_filter_lite_test.cc | 3 ++- .../pvt/rinex_printer_test.cc | 16 ++++++++-------- src/utils/front-end-cal/front_end_cal.cc | 8 ++++---- 9 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 8f3042830..92098517f 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -5651,7 +5651,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.E1B_DVS); - std::string SVhealth_str = E5B_HS + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); + std::string SVhealth_str = std::move(E5B_HS) + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::string(E1B_DVS) + std::string(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); line += Rinex_Printer::doub2for(static_cast(SVhealth), 18, 2); line += std::string(1, ' '); diff --git a/src/algorithms/signal_source/adapters/file_source_base.cc b/src/algorithms/signal_source/adapters/file_source_base.cc index 220f65191..6efa7cdbc 100644 --- a/src/algorithms/signal_source/adapters/file_source_base.cc +++ b/src/algorithms/signal_source/adapters/file_source_base.cc @@ -171,7 +171,7 @@ void FileSourceBase::connect(gr::top_block_sptr top_block) // VALVE if (valve()) { - top_block->connect(input, 0, valve(), 0); + top_block->connect(std::move(input), 0, valve(), 0); DLOG(INFO) << "connected source to valve"; output = valve(); diff --git a/src/tests/unit-tests/control-plane/file_configuration_test.cc b/src/tests/unit-tests/control-plane/file_configuration_test.cc index 5b2036234..4b09f1096 100644 --- a/src/tests/unit-tests/control-plane/file_configuration_test.cc +++ b/src/tests/unit-tests/control-plane/file_configuration_test.cc @@ -19,6 +19,7 @@ #include "file_configuration.h" #include "gnss_sdr_make_unique.h" #include +#include TEST(FileConfigurationTest, OverridedProperties) @@ -31,7 +32,7 @@ TEST(FileConfigurationTest, OverridedProperties) std::string value = configuration->property("NotThere", default_value); EXPECT_STREQ("default_value", value.c_str()); configuration->set_property("NotThere", "Yes!"); - value = configuration->property("NotThere", default_value); + value = configuration->property("NotThere", std::move(default_value)); EXPECT_STREQ("Yes!", value.c_str()); } @@ -40,7 +41,7 @@ TEST(FileConfigurationTest, LoadFromNonExistentFile) { std::unique_ptr configuration = std::make_unique("./i_dont_exist.conf"); std::string default_value = "default_value"; - std::string value = configuration->property("whatever.whatever", default_value); + std::string value = configuration->property("whatever.whatever", std::move(default_value)); EXPECT_STREQ("default_value", value.c_str()); } @@ -51,6 +52,6 @@ TEST(FileConfigurationTest, PropertyDoesNotExist) std::string filename = path + "data/config_file_sample.txt"; std::unique_ptr configuration = std::make_unique(filename); std::string default_value = "default_value"; - std::string value = configuration->property("whatever.whatever", default_value); + std::string value = configuration->property("whatever.whatever", std::move(default_value)); EXPECT_STREQ("default_value", value.c_str()); } diff --git a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc index 89352892b..9ce4f0469 100644 --- a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc @@ -32,6 +32,7 @@ #include "tracking_interface.h" #include #include +#include #include TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) @@ -40,7 +41,7 @@ TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) configuration->set_property("SignalSource.implementation", "File_Signal_Source"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - configuration->set_property("SignalSource.filename", filename); + configuration->set_property("SignalSource.filename", std::move(filename)); std::shared_ptr> queue = std::make_shared>(); // Example of a factory as a shared_ptr std::shared_ptr factory = std::make_shared(); diff --git a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc index 63cf9ea90..158f0ee27 100644 --- a/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_flowgraph_test.cc @@ -28,6 +28,7 @@ #include "pass_through.h" #include "tracking_interface.h" #include +#include TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopOldNotation /*unused*/) @@ -42,7 +43,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopOldNotation /*unused*/ config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "1"); config->set_property("Channels.in_acquisition", "1"); @@ -76,7 +77,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStop /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "8"); config->set_property("Channels.in_acquisition", "1"); @@ -110,7 +111,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopGalileoE1B /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1B.count", "8"); config->set_property("Channels.in_acquisition", "1"); @@ -145,7 +146,7 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopHybrid /*unused*/) config->set_property("SignalSource.repeat", "true"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat"; - config->set_property("SignalSource.filename", filename); + config->set_property("SignalSource.filename", std::move(filename)); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels_1C.count", "8"); config->set_property("Channels_1B.count", "8"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index a0d064dac..60987b0f2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -37,6 +37,7 @@ #include "interleaved_short_to_complex_short.h" #include #include +#include DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -311,7 +312,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "ibyte"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index db12b3bfc..1c77dc929 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -36,6 +36,7 @@ #include "notch_filter_lite.h" #include #include +#include DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to filter in the tests (max: 2147483647)"); @@ -178,7 +179,7 @@ TEST_F(NotchFilterLiteTest, ConnectAndRunGrcomplex) config2->set_property("Test_Source.sampling_frequency", "4000000"); std::string path = std::string(TEST_PATH); std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; - config2->set_property("Test_Source.filename", filename); + config2->set_property("Test_Source.filename", std::move(filename)); config2->set_property("Test_Source.item_type", "gr_complex"); config2->set_property("Test_Source.repeat", "true"); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 68f029c1c..ea0aac0bd 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -149,12 +149,12 @@ TEST_F(RinexPrinterTest, GalileoObsHeader) auto pvt_solution = std::make_shared(rtk, conf, "filename", 4, false, false); auto eph = Galileo_Ephemeris(); eph.PRN = 1; - pvt_solution->galileo_ephemeris_map[1] = eph; + pvt_solution->galileo_ephemeris_map[1] = std::move(eph); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; - gnss_observables_map[1] = gs; + gnss_observables_map[1] = std::move(gs); auto rp = std::make_shared(); @@ -237,12 +237,12 @@ TEST_F(RinexPrinterTest, GlonassObsHeader) auto pvt_solution = std::make_shared(rtk, conf, "filename", 28, false, false); auto eph = Glonass_Gnav_Ephemeris(); eph.PRN = 1; - pvt_solution->glonass_gnav_ephemeris_map[1] = eph; + pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; - gnss_observables_map[1] = gs; + gnss_observables_map[1] = std::move(gs); auto rp = std::make_shared(3); @@ -305,7 +305,7 @@ TEST_F(RinexPrinterTest, MixedObsHeader) Gnss_Synchro gs{}; gs.PRN = 1; gnss_observables_map[1] = gs; - gnss_observables_map[2] = gs; + gnss_observables_map[2] = std::move(gs); auto rp = std::make_shared(); @@ -369,15 +369,15 @@ TEST_F(RinexPrinterTest, MixedObsHeaderGpsGlo) Pvt_Conf conf; conf.use_e6_for_pvt = false; auto pvt_solution = std::make_shared(rtk, conf, "filename", 26, false, false); - pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo; + pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph_glo); - pvt_solution->gps_ephemeris_map[1] = eph_gps; + pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps); std::map gnss_observables_map; Gnss_Synchro gs{}; gs.PRN = 1; gnss_observables_map[1] = gs; - gnss_observables_map[2] = gs; + gnss_observables_map[2] = std::move(gs); auto rp = std::make_shared(); diff --git a/src/utils/front-end-cal/front_end_cal.cc b/src/utils/front-end-cal/front_end_cal.cc index 8150fcfce..9c527d10e 100644 --- a/src/utils/front-end-cal/front_end_cal.cc +++ b/src/utils/front-end-cal/front_end_cal.cc @@ -86,8 +86,8 @@ int FrontEndCal::Get_SUPL_Assist() LOG(INFO) << "SUPL RRLP GPS assistance enabled!"; std::string default_acq_server = "supl.nokia.com"; std::string default_eph_server = "supl.google.com"; - supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", default_acq_server); - supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", default_eph_server); + supl_client_ephemeris_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_server", std::move(default_acq_server)); + supl_client_acquisition_.server_name = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_server", std::move(default_eph_server)); supl_client_ephemeris_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_port", 7275); supl_client_acquisition_.server_port = configuration_->property("GNSS-SDR.SUPL_gps_acquisition_port", 7275); supl_mcc = configuration_->property("GNSS-SDR.SUPL_MCC", 244); @@ -97,7 +97,7 @@ int FrontEndCal::Get_SUPL_Assist() std::string default_ci = "0x31b0"; try { - supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC", default_lac)); + supl_lac = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_LAC", std::move(default_lac))); } catch (boost::bad_lexical_cast &) { @@ -105,7 +105,7 @@ int FrontEndCal::Get_SUPL_Assist() } try { - supl_ci = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_CI", default_ci)); + supl_ci = boost::lexical_cast(configuration_->property("GNSS-SDR.SUPL_CI", std::move(default_ci))); } catch (boost::bad_lexical_cast &) {