1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-08-07 22:43:52 +00:00

Small fixes to make Coverity Scan happy

This commit is contained in:
Carles Fernandez 2018-02-10 23:34:40 +01:00
parent 9672f34d71
commit 1c4cfbcb66
4 changed files with 36 additions and 13 deletions

View File

@ -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()));
try
{
our_options.parse(argc, argv);
}
catch(...)
{
return 1;
}
return 0;
}

View File

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

View File

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

View File

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