From: Arnaud Giersch Date: Tue, 4 Jan 2011 14:36:41 +0000 (+0100) Subject: Use bool for return type of parse_args(). X-Git-Tag: v0.1~209 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/0c55251c3227ee5608f07d61bf4c1392b4985c72?ds=sidebyside;hp=-c Use bool for return type of parse_args(). --- 0c55251c3227ee5608f07d61bf4c1392b4985c72 diff --git a/main.cpp b/main.cpp index 5326e73..8a23727 100644 --- a/main.cpp +++ b/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) MSG_global_init(&argc, argv); // Parse global parameters - int parse_res = opt::parse_args(&argc, argv); + bool parse_res = opt::parse_args(&argc, argv); if (!parse_res || opt::version_requested || opt::help_requested) { if (opt::version_requested) diff --git a/options.cpp b/options.cpp index 2c8e61d..1420566 100644 --- a/options.cpp +++ b/options.cpp @@ -75,9 +75,9 @@ namespace opt { } // namespace opt -int opt::parse_args(int* argc, char* argv[]) +bool opt::parse_args(int* argc, char* argv[]) { - int result = 1; + bool result = true; opt::program_name = argv[0]; opt::program_name.erase(0, 1 + opt::program_name.find_last_of('/')); @@ -91,7 +91,7 @@ int opt::parse_args(int* argc, char* argv[]) if (!opt::loba_algorithms.exists(opt::loba_algo)) { ERROR1("unknownw load balancing algorithm -- %s", opt::loba_algo.c_str()); - result = 0; + result = false; } break; case 'b': @@ -126,7 +126,7 @@ int opt::parse_args(int* argc, char* argv[]) if (!opt::topologies.exists(opt::auto_depl::topology)) { ERROR1("unknownw topology -- %s", opt::auto_depl::topology.c_str()); - result = 0; + result = false; } break; case 'v': @@ -138,7 +138,7 @@ int opt::parse_args(int* argc, char* argv[]) break; case '?': ERROR1("invalid option -- '%c'", optopt); - result = 0; + result = false; break; } } @@ -150,7 +150,7 @@ int opt::parse_args(int* argc, char* argv[]) opt::platform_file = argv[optind++]; } else { ERROR0("missing parameter -- "); - result = 0; + result = false; } if (optind < *argc) { opt::deployment_file = argv[optind++]; @@ -159,7 +159,7 @@ int opt::parse_args(int* argc, char* argv[]) while (optind < *argc) { ERROR1("unused parameter -- \"%s\"", argv[optind++]); - result = 0; + result = false; } return result; diff --git a/options.h b/options.h index 5c43e6f..838dfa0 100644 --- a/options.h +++ b/options.h @@ -55,7 +55,7 @@ namespace opt { } topologies; // Utility functions - int parse_args(int* argc, char* argv[]); + bool parse_args(int* argc, char* argv[]); void print(); void usage();