mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 12:40:35 +00:00
Small fixes to make Coverity Scan happy
This commit is contained in:
parent
9672f34d71
commit
1c4cfbcb66
@ -62,7 +62,13 @@ int main(int argc, char **argv)
|
||||
print_malloc));
|
||||
our_options.add(option_t("version", "v", "print the VOLK_GNSSSDR version", volk_gnsssdr_version()));
|
||||
|
||||
our_options.parse(argc, argv);
|
||||
|
||||
try
|
||||
{
|
||||
our_options.parse(argc, argv);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ option_list::option_list(std::string program_name) :
|
||||
{ internal_list = std::vector<option_t>(); }
|
||||
}
|
||||
|
||||
void option_list::add(option_t opt) { internal_list.push_back(opt); }
|
||||
void option_list::add(const option_t & opt) { internal_list.push_back(opt); }
|
||||
|
||||
void option_list::parse(int argc, char **argv) {
|
||||
for (int arg_number = 0; arg_number < argc; ++arg_number) {
|
||||
@ -115,12 +115,15 @@ void option_list::parse(int argc, char **argv) {
|
||||
} catch (std::exception &exc) {
|
||||
throw std::exception();
|
||||
};
|
||||
break;
|
||||
case STRING:
|
||||
std::cout << this_option->printval << std::endl;
|
||||
break;
|
||||
default:
|
||||
this_option->callback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (std::string("--help") == std::string(argv[arg_number]) ||
|
||||
std::string("-h") == std::string(argv[arg_number])) {
|
||||
@ -131,7 +134,7 @@ void option_list::parse(int argc, char **argv) {
|
||||
|
||||
void option_list::help() {
|
||||
std::cout << program_name << std::endl;
|
||||
std::cout << " -h [ --help ] \t\tdisplay this help message" << std::endl;
|
||||
std::cout << " -h [ --help ] \t\tDisplay this help message" << std::endl;
|
||||
for (std::vector<option_t>::iterator this_option = internal_list.begin();
|
||||
this_option != internal_list.end();
|
||||
this_option++) {
|
||||
@ -144,13 +147,19 @@ void option_list::help() {
|
||||
|
||||
switch (help_line.size() / 8) {
|
||||
case 0:
|
||||
help_line += "\t";
|
||||
help_line += "\t\t\t\t";
|
||||
break;
|
||||
case 1:
|
||||
help_line += "\t";
|
||||
help_line += "\t\t\t";
|
||||
break;
|
||||
case 2:
|
||||
help_line += "\t";
|
||||
help_line += "\t\t";
|
||||
break;
|
||||
case 3:
|
||||
help_line += "\t";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
help_line += this_option->msg;
|
||||
std::cout << help_line << std::endl;
|
||||
|
@ -55,7 +55,7 @@ class option_list
|
||||
public:
|
||||
option_list(std::string program_name);
|
||||
|
||||
void add(option_t opt);
|
||||
void add(const option_t & opt);
|
||||
|
||||
void parse(int argc, char **argv);
|
||||
|
||||
|
@ -60,7 +60,15 @@ int main(int argc, char *argv[])
|
||||
profile_options.add((option_t("dry-run", "n", "Dry run. Respect other options, but don't write to file", set_dryrun)));
|
||||
profile_options.add((option_t("json", "j", "Write results to JSON file named as argument value", set_json)));
|
||||
profile_options.add((option_t("path", "p", "Specify the volk_config path", set_volk_config)));
|
||||
profile_options.parse(argc, argv);
|
||||
|
||||
try
|
||||
{
|
||||
profile_options.parse(argc, argv);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int arg_number = 0; arg_number < argc; ++arg_number) {
|
||||
if (std::string("--help") == std::string(argv[arg_number]) ||
|
||||
@ -216,20 +224,20 @@ void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool
|
||||
// do not overwrite volk_gnsssdr_config when using a regex.
|
||||
if (not fs::exists(config_path.branch_path()))
|
||||
{
|
||||
std::cout << "Creating " << config_path.branch_path() << "..." << std::endl;
|
||||
std::cout << "Creating " << config_path.branch_path() << " ..." << std::endl;
|
||||
fs::create_directories(config_path.branch_path());
|
||||
}
|
||||
|
||||
std::ofstream config;
|
||||
if(update_result) {
|
||||
std::cout << "Updating " << path << "..." << std::endl;
|
||||
std::cout << "Updating " << path << " ..." << std::endl;
|
||||
config.open(path.c_str(), std::ofstream::app);
|
||||
if (!config.is_open()) { //either we don't have write access or we don't have the dir yet
|
||||
std::cout << "Error opening file " << path << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "Writing " << path << "..." << std::endl;
|
||||
std::cout << "Writing " << path << " ..." << std::endl;
|
||||
config.open(path.c_str());
|
||||
if (!config.is_open()) { //either we don't have write access or we don't have the dir yet
|
||||
std::cout << "Error opening file " << path << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user