From: Kamalesh Babulal Date: Fri, 30 Sep 2022 14:40:07 +0000 (-0600) Subject: tools/cgxget: use exit code 129 on invalid usage X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7219dafef3719bb247b51f8f0b393401b6c63d4b;p=thirdparty%2Flibcgroup.git tools/cgxget: use exit code 129 on invalid usage The exit code 1 refers to general error and using -1 wraps to 255, both codes do not signify bad arguments. Let's use exit code 129 (EXIT_BADARGS) for hinting to the users about invalid usage. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka (cherry picked from commit f46f811f55d0218d0450998c74e98c4b3578607c) --- diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index 0d7da5b8..6aee4fd4 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -337,7 +337,7 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[], */ if (argv[optind] == NULL && first_cg_is_dummy) { usage(1, argv[0]); - exit(-1); + exit(EXIT_BADARGS); } /* @@ -351,7 +351,7 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[], */ if (argv[optind] != NULL && (*cg_list_len) > 0 && strcmp((*cg_list)[0]->name, "") != 0) { usage(1, argv[0]); - exit(-1); + exit(EXIT_BADARGS); } while (argv[optind] != NULL) { @@ -462,14 +462,14 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c break; default: usage(1, argv[0]); - exit(1); + exit(EXIT_BADARGS); } } /* Don't allow '-r' and ('-g' or '-a') */ if (fill_controller && do_not_fill_controller) { usage(1, argv[0]); - exit(1); + exit(EXIT_BADARGS); } ret = parse_opt_args(argc, argv, cg_list, cg_list_len, first_cgroup_is_dummy); @@ -797,7 +797,7 @@ int main(int argc, char *argv[]) /* No parameter on input? */ if (argc < 2) { usage(1, argv[0]); - return 1; + exit(EXIT_BADARGS); } ret = cgroup_init();