X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcgtop%2Fcgtop.c;h=fd0023b0a84ef7f57c7bb5d81a8040422627b91c;hp=293a2113bdcbcc9510e34eeb4d0e262b0a6960af;hb=39883f622f392d8579f4428fc5a789a102efbb10;hpb=7ff7394d9e4e9189c30fd018235e6b1728c6f2d0 diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 293a2113b..fd0023b0a 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -98,7 +98,7 @@ static void group_hashmap_free(Hashmap *h) { static int process(const char *controller, const char *path, Hashmap *a, Hashmap *b, unsigned iteration) { Group *g; int r; - FILE *f; + FILE *f = NULL; pid_t pid; unsigned n; @@ -548,7 +548,7 @@ static int display(Hashmap *a) { return 0; } -static void help(void) { +static int help(void) { printf("%s [OPTIONS...]\n\n" "Show top control groups by their resource usage.\n\n" @@ -563,12 +563,10 @@ static void help(void) { " -d --delay=DELAY Delay between updates\n" " -n --iterations=N Run for N iterations before exiting\n" " -b --batch Run in batch mode, accepting no input\n" - " --depth=DEPTH Maximum traversal depth (default: %d)\n", + " --depth=DEPTH Maximum traversal depth (default: %u)\n", program_invocation_short_name, arg_depth); -} -static void version(void) { - puts(PACKAGE_STRING " cgtop"); + return 0; } static int parse_argv(int argc, char *argv[]) { @@ -587,7 +585,7 @@ static int parse_argv(int argc, char *argv[]) { { "batch", no_argument, NULL, 'b' }, { "depth", required_argument, NULL, ARG_DEPTH }, { "cpu", optional_argument, NULL, ARG_CPU_TYPE}, - { NULL, 0, NULL, 0 } + {} }; int c; @@ -601,11 +599,11 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { case 'h': - help(); - return 0; + return help(); case ARG_VERSION: - version(); + puts(PACKAGE_STRING); + puts(SYSTEMD_FEATURES); return 0; case ARG_CPU_TYPE: @@ -674,8 +672,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; default: - log_error("Unknown option code %c", c); - return -EINVAL; + assert_not_reached("Unhandled option"); } }