X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fcoredumpctl.c;h=d4756fe67dcd8761ce79791dc287262a6472277c;hb=bf3d3e2bb7ae2d3854be57f28dd1403c8f7e4c3c;hp=d1450c09a28df907f772a9866fd58a1ac7dcc6cd;hpb=31cda3d1759dee3e48c8ed4a949d99f041bdca1c;p=elogind.git diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index d1450c09a..d4756fe67 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -26,7 +26,7 @@ #include #include -#include +#include "systemd/sd-journal.h" #include "build.h" #include "set.h" @@ -58,7 +58,7 @@ static Set *new_matches(void) { char *tmp; int r; - set = set_new(trivial_hash_func, trivial_compare_func); + set = set_new(NULL); if (!set) { log_oom(); return NULL; @@ -81,29 +81,6 @@ static Set *new_matches(void) { return set; } -static int help(void) { - - printf("%s [OPTIONS...]\n\n" - "List or retrieve coredumps from the journal.\n\n" - "Flags:\n" - " -h --help Show this help\n" - " --version Print version string\n" - " --no-pager Do not pipe output into a pager\n" - " --no-legend Do not print the column headers.\n" - " -1 Show information about most recent entry only\n" - " -F --field=FIELD List all values a certain field takes\n" - " -o --output=FILE Write output to FILE\n\n" - - "Commands:\n" - " list [MATCHES...] List available coredumps (default)\n" - " info [MATCHES...] Show detailed information about one or more coredumps\n" - " dump [MATCHES...] Print first matching coredump to stdout\n" - " gdb [MATCHES...] Start gdb for the first matching coredump\n" - , program_invocation_short_name); - - return 0; -} - static int add_match(Set *set, const char *match) { int r = -ENOMEM; unsigned pid; @@ -131,11 +108,9 @@ static int add_match(Set *set, const char *match) { goto fail; log_debug("Adding pattern: %s", pattern); - r = set_put(set, pattern); + r = set_consume(set, pattern); if (r < 0) { - log_error("Failed to add pattern '%s': %s", - pattern, strerror(-r)); - free(pattern); + log_error("Failed to add pattern: %s", strerror(-r)); goto fail; } @@ -145,6 +120,26 @@ fail: return r; } +static void help(void) { + printf("%s [OPTIONS...]\n\n" + "List or retrieve coredumps from the journal.\n\n" + "Flags:\n" + " -h --help Show this help\n" + " --version Print version string\n" + " --no-pager Do not pipe output into a pager\n" + " --no-legend Do not print the column headers.\n" + " -1 Show information about most recent entry only\n" + " -F --field=FIELD List all values a certain field takes\n" + " -o --output=FILE Write output to FILE\n\n" + + "Commands:\n" + " list [MATCHES...] List available coredumps (default)\n" + " info [MATCHES...] Show detailed information about one or more coredumps\n" + " dump [MATCHES...] Print first matching coredump to stdout\n" + " gdb [MATCHES...] Start gdb for the first matching coredump\n" + , program_invocation_short_name); +} + static int parse_argv(int argc, char *argv[], Set *matches) { enum { ARG_VERSION = 0x100, @@ -172,7 +167,8 @@ static int parse_argv(int argc, char *argv[], Set *matches) { case 'h': arg_action = ACTION_NONE; - return help(); + help(); + return 0; case ARG_VERSION: arg_action = ACTION_NONE;