From: Frantisek Sumsal Date: Mon, 14 Mar 2022 17:26:53 +0000 (+0100) Subject: journal: use table_set_json_field_name() to override a column name X-Git-Tag: v251-rc1~146^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e4b9a252b434b7f8c74271df8dc4f07d7960c32;p=thirdparty%2Fsystemd.git journal: use table_set_json_field_name() to override a column name Pointed out in: https://github.com/systemd/systemd/pull/22721#discussion_r826014227 Follow-up for: 5a1355d848a0f6564a04c6d8268e72bc93d173de --- diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index e0951f9682e..55c48eded58 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1460,13 +1460,17 @@ static int list_boots(sd_journal *j) { if (count == 0) return count; - table = table_new(OUTPUT_MODE_IS_JSON(arg_output) ? "index" : "idx", "boot id", "first entry", "last entry"); + table = table_new("idx", "boot id", "first entry", "last entry"); if (!table) return log_oom(); if (arg_full) table_set_width(table, 0); + r = table_set_json_field_name(table, 0, "index"); + if (r < 0) + return log_error_errno(r, "Failed to set JSON field name of column 0: %m"); + i = 0; LIST_FOREACH(boot_list, id, all_ids) { r = table_add_many(table,