Fix more defects detected by Coverity Scan

This commit is contained in:
Carles Fernandez 2023-12-03 10:10:40 +01:00
parent 3ad02f6dc1
commit e836d8f471
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
8 changed files with 24 additions and 22 deletions

View File

@ -21,7 +21,7 @@ option_t::option_t(std::string t_longform,
void (*t_callback)())
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
msg(std::move(t_msg)),
callback(t_callback)
{
option_type = VOID_CALLBACK;
@ -34,7 +34,7 @@ option_t::option_t(std::string t_longform,
void (*t_callback)(int))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
msg(std::move(t_msg)),
callback((void (*)())t_callback)
{
option_type = INT_CALLBACK;
@ -47,7 +47,7 @@ option_t::option_t(std::string t_longform,
void (*t_callback)(float))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
msg(std::move(t_msg)),
callback((void (*)())t_callback)
{
option_type = FLOAT_CALLBACK;
@ -60,7 +60,7 @@ option_t::option_t(std::string t_longform,
void (*t_callback)(bool))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
msg(std::move(t_msg)),
callback((void (*)())t_callback)
{
option_type = BOOL_CALLBACK;
@ -73,7 +73,7 @@ option_t::option_t(std::string t_longform,
void (*t_callback)(std::string))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
msg(std::move(t_msg)),
callback((void (*)())t_callback)
{
option_type = STRING_CALLBACK;
@ -86,8 +86,8 @@ option_t::option_t(std::string t_longform,
std::string t_printval)
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
printval(t_printval)
msg(std::move(t_msg)),
printval(std::move(t_printval))
{
option_type = STRING;
}

View File

@ -168,7 +168,7 @@ int main(int argc, char *argv[])
if (!dry_run)
{
if (config_file != "")
write_results(&results, false, config_file);
write_results(&results, false, std::move(config_file));
else
write_results(&results, false);
}

View File

@ -33,8 +33,8 @@ int main(int argc, char* argv[])
std::string def_kernel_regex = "";
volk_gnsssdr_test_params_t test_params(def_tol, def_scalar, def_vlen, def_iter,
def_benchmark_mode, def_kernel_regex);
std::vector<volk_gnsssdr_test_case_t> test_cases = init_test_list(test_params);
def_benchmark_mode, std::move(def_kernel_regex));
std::vector<volk_gnsssdr_test_case_t> test_cases = init_test_list(std::move(test_params));
std::vector<volk_gnsssdr_test_results_t> results;
if (argc > 1)
{
@ -94,7 +94,7 @@ int main(int argc, char* argv[])
}
// Generate XML results
print_qa_xml(results, qa_failures.size());
print_qa_xml(std::move(results), qa_failures.size());
// Summarize QA results
std::cerr << "Kernel QA finished: " << qa_failures.size() << " failures out of "

View File

@ -18,6 +18,7 @@
#include "configuration_interface.h"
#include "gnss_sdr_make_unique.h"
#include "in_memory_configuration.h"
#include <utility>
TEST(InMemoryConfiguration, IsPresent)
{
@ -35,7 +36,7 @@ TEST(InMemoryConfiguration, StoreAndRetrieve)
auto configuration = std::make_unique<InMemoryConfiguration>();
configuration->set_property("Foo.property1", "value");
std::string default_value = "default_value";
std::string value = configuration->property("Foo.property1", default_value);
std::string value = configuration->property("Foo.property1", std::move(default_value));
EXPECT_STREQ("value", value.c_str());
}
@ -45,7 +46,7 @@ TEST(InMemoryConfiguration, NoStoringAndRetrieve)
// std::shared_ptr<ConfigurationInterface> configuration = std::make_shared<InMemoryConfiguration>();
auto configuration = std::make_unique<InMemoryConfiguration>();
std::string default_value = "default_value";
std::string value = configuration->property("Foo.property1", default_value);
std::string value = configuration->property("Foo.property1", std::move(default_value));
EXPECT_STREQ("default_value", value.c_str());
}

View File

@ -225,7 +225,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_1()
config = std::make_shared<InMemoryConfiguration>();
config->set_property("Channel.signal", signal);
config->set_property("Channel.signal", std::move(signal));
config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in));
config->set_property("SignalSource.fs_hz", std::to_string(fs_in));
config->set_property("SignalSource.item_type", "gr_complex");

View File

@ -267,7 +267,7 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts)
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", "ishort");
config2->set_property("Test_Source.repeat", "true");
@ -357,7 +357,7 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex)
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

@ -796,8 +796,8 @@ TEST_F(RinexPrinterTest, MixedObsLog)
Pvt_Conf conf;
conf.use_e6_for_pvt = false;
auto pvt_solution = std::make_shared<Rtklib_Solver>(rtk, conf, "filename", 9, false, false);
pvt_solution->gps_ephemeris_map[1] = eph_gps;
pvt_solution->galileo_ephemeris_map[1] = eph_gal;
pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps);
pvt_solution->galileo_ephemeris_map[1] = std::move(eph_gal);
std::map<int, Gnss_Synchro> gnss_observables_map;
Gnss_Synchro gs1 = Gnss_Synchro();
@ -922,8 +922,8 @@ TEST_F(RinexPrinterTest, MixedObsLogGpsGlo)
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->gps_ephemeris_map[1] = eph_gps;
pvt_solution->glonass_gnav_ephemeris_map[1] = eph_glo;
pvt_solution->gps_ephemeris_map[1] = std::move(eph_gps);
pvt_solution->glonass_gnav_ephemeris_map[1] = std::move(eph_glo);
std::map<int, Gnss_Synchro> gnss_observables_map;
Gnss_Synchro gs1 = Gnss_Synchro();

View File

@ -22,6 +22,7 @@
#include <gnuradio/top_block.h>
#include <gtest/gtest.h>
#include <stdexcept>
#include <utility>
TEST(FileSignalSource, Instantiate)
{
@ -32,7 +33,7 @@ TEST(FileSignalSource, Instantiate)
config->set_property("Test.sampling_frequency", "0");
std::string path = std::string(TEST_PATH);
std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat";
config->set_property("Test.filename", filename);
config->set_property("Test.filename", std::move(filename));
config->set_property("Test.item_type", "gr_complex");
config->set_property("Test.repeat", "false");
@ -57,5 +58,5 @@ TEST(FileSignalSource, InstantiateFileNotExists)
// connect doesn't matter, since the exception should be thrown sooner than any connections
auto top = gr::make_top_block("GNSSUnitTest");
auto uptr = std::make_shared<FileSignalSource>(config.get(), "Test", 0, 1, queue.get());
EXPECT_THROW({ uptr->connect(top); }, std::exception);
EXPECT_THROW({ uptr->connect(std::move(top)); }, std::exception);
}