From: fangxiuning Date: Tue, 7 Jul 2020 02:13:13 +0000 (+0800) Subject: table add table_log_show_error() X-Git-Tag: v246-rc1~9^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d836018a73bc0cc9c1525aea0706e56213589a70;p=thirdparty%2Fsystemd.git table add table_log_show_error() --- diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 3ab90de63e2..f6345888171 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -371,7 +371,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) { else r = table_print(table, stdout); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); return 0; } diff --git a/src/home/homectl.c b/src/home/homectl.c index 149f960f76a..b5ad9d53d08 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -177,7 +177,7 @@ static int list_homes(int argc, char *argv[], void *userdata) { else r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } if (arg_legend && !arg_json) { diff --git a/src/login/inhibit.c b/src/login/inhibit.c index a1602031b4b..d82aba8ec3a 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -138,7 +138,7 @@ static int print_inhibitors(sd_bus *bus) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } if (arg_legend) { diff --git a/src/login/loginctl.c b/src/login/loginctl.c index ee617929ff6..78dfab70716 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -100,7 +100,7 @@ static int show_table(Table *table, const char *word) { else r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } if (arg_legend) { diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index f41cf464b17..ace6439c79e 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -246,7 +246,7 @@ static int show_table(Table *table, const char *word) { else r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } if (arg_legend) { diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 46bb0e5437f..d4de823345b 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -750,7 +750,7 @@ static int list_images(int argc, char *argv[], void *userdata) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } if (arg_legend) { diff --git a/src/shared/format-table.h b/src/shared/format-table.h index 20b4ebd39b5..c828105f2c6 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -130,3 +130,6 @@ int table_print_json(Table *t, FILE *f, JsonFormatFlags json_flags); #define table_log_add_error(r) \ log_error_errno(r, "Failed to add cell(s) to table: %m") + +#define table_log_show_error(r) \ + log_error_errno(r, "Failed to show table: %m") diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 954e5080eab..3933011c927 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -392,7 +392,7 @@ static int output_table(Table *table) { else r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); return 0; } diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 96be78746d6..102ffece634 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -160,7 +160,7 @@ static int print_status_info(const StatusInfo *i) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); if (i->rtc_local) printf("\n%s" @@ -433,7 +433,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); return 0; } @@ -442,7 +442,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) { log_error("Invalid NTP response"); r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); return 0; } @@ -526,7 +526,7 @@ static int print_ntp_status_info(NTPStatusInfo *i) { r = table_print(table, NULL); if (r < 0) - log_error_errno(r, "Failed to show table: %m"); + table_log_show_error(r); return 0; } diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 382a1cc9e4a..55984518d07 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -180,7 +180,7 @@ static int display_user(int argc, char *argv[], void *userdata) { if (table) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } return ret; @@ -330,7 +330,7 @@ static int display_group(int argc, char *argv[], void *userdata) { if (table) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } return ret; @@ -463,7 +463,7 @@ static int display_memberships(int argc, char *argv[], void *userdata) { if (table) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_show_error(r); } return ret;