From: Kamalesh Babulal Date: Fri, 30 Sep 2022 06:23:57 +0000 (+0000) Subject: tools/cgsnapshot: use exit code 129 on invalid usage X-Git-Tag: v3.1.0~296 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8af5441bcbfee6e624455f124ef2273251f7c111;p=thirdparty%2Flibcgroup.git tools/cgsnapshot: 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/cgsnapshot.c b/src/tools/cgsnapshot.c index a17d9f1c..6d2e8c80 100644 --- a/src/tools/cgsnapshot.c +++ b/src/tools/cgsnapshot.c @@ -746,7 +746,7 @@ int main(int argc, char *argv[]) break; default: usage(1, argv[0]); - return -1; + exit(EXIT_BADARGS); } } @@ -773,14 +773,18 @@ int main(int argc, char *argv[]) /* load the blacklist from the default location */ ret = load_list(BLACKLIST_CONF, &black_list); } - if (ret != 0) + if (ret != 0) { + ret = EXIT_BADARGS; goto finish; + } /* whitelist */ if (flags & FL_WHITE) ret = load_list(wl_file, &white_list); - if (ret != 0) + if (ret != 0) { + ret = EXIT_BADARGS; goto finish; + } /* print the header */ fprintf(output_f, "# Configuration file generated by cgsnapshot\n"); @@ -793,6 +797,7 @@ int main(int argc, char *argv[]) /* print mount points section */ ret = parse_mountpoints(wanted_cont, argv[0]); + ret = ret ? EXIT_BADARGS : 0; /* continue with processing on error*/ /* print hierarchies section */