diff --git a/src/coredump/coredumpctl-core.c b/src/coredump/coredumpctl-core.c index 4baaadd4b5..5a69d1fc20 100644 --- a/src/coredump/coredumpctl-core.c +++ b/src/coredump/coredumpctl-core.c @@ -180,7 +180,7 @@ int verb_dump_core(int argc, char *argv[], uintptr_t _data, void *userdata) { return log_error_errno(errno, "Failed to open \"%s\" for writing: %m", arg_output); } - print_info(f ? stdout : stderr, j, false); + (void) print_entry(f ? stdout : stderr, j, /* need_space= */ false, /* table= */ NULL); r = save_core(j, f, NULL, NULL); if (r < 0) diff --git a/src/coredump/coredumpctl-debugger.c b/src/coredump/coredumpctl-debugger.c index 9145d38709..89bc25df97 100644 --- a/src/coredump/coredumpctl-debugger.c +++ b/src/coredump/coredumpctl-debugger.c @@ -63,7 +63,7 @@ int verb_run_debug(int argc, char *argv[], uintptr_t _data, void *userdata) { return r; if (!arg_quiet) { - print_info(stdout, j, false); + (void) print_entry(stdout, j, /* need_space= */ false, /* table= */ NULL); fputs("\n", stdout); } diff --git a/src/coredump/coredumpctl-info.c b/src/coredump/coredumpctl-info.c index f2cad48114..6205ac8662 100644 --- a/src/coredump/coredumpctl-info.c +++ b/src/coredump/coredumpctl-info.c @@ -330,7 +330,7 @@ static int coredump_fields_load(sd_journal *j, CoredumpFields *f) { return 0; } -int print_info(FILE *file, sd_journal *j, bool need_space) { +static int print_info(FILE *file, sd_journal *j, bool need_space) { _cleanup_(coredump_fields_done) CoredumpFields f = { .disk_size = UINT64_MAX, }; @@ -598,14 +598,15 @@ static int print_info_json(FILE *file, sd_journal *j) { return 0; } -int print_entry(sd_journal *j, size_t n_found, Table *t) { +int print_entry(FILE *f, sd_journal *j, bool need_space, Table *table) { + assert(f); assert(j); - if (t) - return print_list(stdout, j, t); + if (table) + return print_list(f, j, table); if (arg_field) - return print_field(stdout, j); + return print_field(f, j); if (sd_json_format_enabled(arg_json_format_flags)) - return print_info_json(stdout, j); - return print_info(stdout, j, n_found > 0); + return print_info_json(f, j); + return print_info(f, j, need_space); } diff --git a/src/coredump/coredumpctl-info.h b/src/coredump/coredumpctl-info.h index 5caf2b55cc..8120fb0f66 100644 --- a/src/coredump/coredumpctl-info.h +++ b/src/coredump/coredumpctl-info.h @@ -3,5 +3,4 @@ #include "forward.h" -int print_info(FILE *file, sd_journal *j, bool need_space); -int print_entry(sd_journal *j, size_t n_found, Table *t); +int print_entry(FILE *f, sd_journal *j, bool need_space, Table *table); diff --git a/src/coredump/coredumpctl-list.c b/src/coredump/coredumpctl-list.c index 08872110e8..009268fdf1 100644 --- a/src/coredump/coredumpctl-list.c +++ b/src/coredump/coredumpctl-list.c @@ -48,7 +48,7 @@ int verb_dump_list(int argc, char *argv[], uintptr_t _data, void *userdata) { if (r < 0) return r; - r = print_entry(j, 0, t); + r = print_entry(stdout, j, /* need_space= */ false, t); if (r < 0) return r; } else { @@ -93,10 +93,12 @@ int verb_dump_list(int argc, char *argv[], uintptr_t _data, void *userdata) { break; } - r = print_entry(j, n_found++, t); + r = print_entry(stdout, j, /* need_space= */ n_found > 0, t); if (r < 0) return r; + n_found++; + if (arg_rows_max != SIZE_MAX && n_found >= arg_rows_max) break; }