Fix performance inefficiencies detected by Coverity Scan

This commit is contained in:
Carles Fernandez 2023-12-01 10:19:39 +01:00
parent 0b4d525feb
commit 4b60f8a7f2
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
9 changed files with 29 additions and 24 deletions

View File

@ -5651,7 +5651,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map<int32_t, Gal
std::string E1B_DVS = std::to_string(galileo_ephemeris_iter->second.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<double>(SVhealth), 18, 2);
line += std::string(1, ' ');

View File

@ -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();

View File

@ -19,6 +19,7 @@
#include "file_configuration.h"
#include "gnss_sdr_make_unique.h"
#include <string>
#include <utility>
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<ConfigurationInterface> configuration = std::make_unique<FileConfiguration>("./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<ConfigurationInterface> configuration = std::make_unique<FileConfiguration>(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());
}

View File

@ -32,6 +32,7 @@
#include "tracking_interface.h"
#include <gtest/gtest.h>
#include <pmt/pmt.h>
#include <utility>
#include <vector>
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<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
// Example of a factory as a shared_ptr
std::shared_ptr<GNSSBlockFactory> factory = std::make_shared<GNSSBlockFactory>();

View File

@ -28,6 +28,7 @@
#include "pass_through.h"
#include "tracking_interface.h"
#include <gtest/gtest.h>
#include <utility>
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");

View File

@ -37,6 +37,7 @@
#include "interleaved_short_to_complex_short.h"
#include <gnuradio/blocks/null_sink.h>
#include <gtest/gtest.h>
#include <utility>
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");

View File

@ -36,6 +36,7 @@
#include "notch_filter_lite.h"
#include <gnuradio/blocks/null_sink.h>
#include <gtest/gtest.h>
#include <utility>
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");

View File

@ -149,12 +149,12 @@ TEST_F(RinexPrinterTest, GalileoObsHeader)
auto pvt_solution = std::make_shared<Rtklib_Solver>(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<int, Gnss_Synchro> 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<Rinex_Printer>();
@ -237,12 +237,12 @@ TEST_F(RinexPrinterTest, GlonassObsHeader)
auto pvt_solution = std::make_shared<Rtklib_Solver>(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<int, Gnss_Synchro> 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<Rinex_Printer>(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<Rinex_Printer>();
@ -369,15 +369,15 @@ TEST_F(RinexPrinterTest, MixedObsHeaderGpsGlo)
Pvt_Conf conf;
conf.use_e6_for_pvt = false;
auto pvt_solution = std::make_shared<Rtklib_Solver>(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<int, Gnss_Synchro> 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<Rinex_Printer>();

View File

@ -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<int>(configuration_->property("GNSS-SDR.SUPL_LAC", default_lac));
supl_lac = boost::lexical_cast<int>(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<int>(configuration_->property("GNSS-SDR.SUPL_CI", default_ci));
supl_ci = boost::lexical_cast<int>(configuration_->property("GNSS-SDR.SUPL_CI", std::move(default_ci)));
}
catch (boost::bad_lexical_cast &)
{