From 68787def1dde5fe07ee3ff48ed16500e46c1fd87 Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Tue, 6 Sep 2016 14:26:38 +0200 Subject: [PATCH] ziomon: Use exit code 0 for --version and --help Besides of this also unify the exit codes for help in case of wrong number of parameters: # /usr/sbin/ziomon_util Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q ... # echo $? 255 # /usr/sbin/ziomon_mgr Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q ... # echo $? 0 With this patch we use exit code 1 (EXIT_FAILURE) in this case: # ./ziomon_util Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q ... # echo $? 1 Signed-off-by: Michael Holzheu --- ziomon/ziomon_mgr.c | 6 +++--- ziomon/ziomon_util.c | 6 +++--- ziomon/ziorep_traffic.cpp | 6 +++--- ziomon/ziorep_utilization.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ziomon/ziomon_mgr.c b/ziomon/ziomon_mgr.c index a8cad6e..f9d4ea9 100644 --- a/ziomon/ziomon_mgr.c +++ b/ziomon/ziomon_mgr.c @@ -301,7 +301,7 @@ static int parse_params(int argc, char **argv, struct options *opts) if (argc <= 1) { print_help(); - return 1; + exit(EXIT_FAILURE); } while ((c = getopt_long(argc, argv, "r:Q:q:u:b:z:i:l:o:x:Vhfev", @@ -356,7 +356,7 @@ static int parse_params(int argc, char **argv, struct options *opts) break; case 'h': print_help(); - return 1; + exit(EXIT_SUCCESS); case 'e': print_bin_struct_sizes(); return 1; @@ -440,7 +440,7 @@ static int parse_params(int argc, char **argv, struct options *opts) break; case 'v': print_version(); - return 1; + exit(EXIT_SUCCESS); default: fprintf(stderr, "Try '%s --help' for" " more information.\n", toolname); diff --git a/ziomon/ziomon_util.c b/ziomon/ziomon_util.c index 74e4940..b3ca473 100644 --- a/ziomon/ziomon_util.c +++ b/ziomon/ziomon_util.c @@ -1007,7 +1007,7 @@ static int parse_params(int argc, char **argv, struct options *opts) if (argc <= 1) { print_help(); - return 1; + exit(EXIT_FAILURE); } /* this is too much, but argc/2 is a reliable upper boundary @@ -1078,10 +1078,10 @@ static int parse_params(int argc, char **argv, struct options *opts) break; case 'v': print_version(); - return 1; + exit(EXIT_SUCCESS); case 'h': print_help(); - return 1; + exit(EXIT_SUCCESS); default: fprintf(stderr, "%s: Try '%s --help' for more" " information.\n", toolname, toolname); diff --git a/ziomon/ziorep_traffic.cpp b/ziomon/ziorep_traffic.cpp index bc1ae25..2c03bb0 100644 --- a/ziomon/ziorep_traffic.cpp +++ b/ziomon/ziorep_traffic.cpp @@ -145,7 +145,7 @@ static int parse_params(int argc, char **argv, struct options *opts) if (argc < 2) { print_help(); - return 1; + exit(EXIT_FAILURE); } assert(sizeof(long long int) == sizeof(__u64)); @@ -157,10 +157,10 @@ static int parse_params(int argc, char **argv, struct options *opts) break; case 'h': print_help(); - return 1; + exit(EXIT_SUCCESS); case 'v': print_version(); - return 1; + exit(EXIT_SUCCESS); case 'b': if (get_datetime_val(optarg, &opts->begin)) return -1; diff --git a/ziomon/ziorep_utilization.cpp b/ziomon/ziorep_utilization.cpp index ac4576f..9c86284 100644 --- a/ziomon/ziorep_utilization.cpp +++ b/ziomon/ziorep_utilization.cpp @@ -123,7 +123,7 @@ static int parse_params(int argc, char **argv, struct options *opts) if (argc < 2) { print_help(); - return 1; + exit(EXIT_FAILURE); } assert(sizeof(long long int) == sizeof(__u64)); @@ -135,10 +135,10 @@ static int parse_params(int argc, char **argv, struct options *opts) break; case 'h': print_help(); - return 1; + exit(EXIT_SUCCESS); case 'v': print_version(); - return 1; + exit(EXIT_SUCCESS); case 'b': if (get_datetime_val(optarg, &opts->begin)) return -1; -- 2.8.4