From: Kamalesh Babulal Date: Thu, 29 Sep 2022 10:19:55 +0000 (+0530) Subject: tools/cgget: use exit code 129 on invalid usage X-Git-Tag: v3.1.0~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c2b005b4544fea075b92d609d792d76913836db;p=thirdparty%2Flibcgroup.git tools/cgget: 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 --- diff --git a/src/tools/cgget.c b/src/tools/cgget.c index 33928c37..bf3e0aad 100644 --- a/src/tools/cgget.c +++ b/src/tools/cgget.c @@ -321,7 +321,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); } /* @@ -336,7 +336,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) { @@ -436,14 +436,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); @@ -725,7 +725,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();