diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 3ab90de63e..56fb8d9367 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_print_error(r); return 0; } diff --git a/src/home/homectl.c b/src/home/homectl.c index 149f960f76..33e262706d 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -168,7 +168,7 @@ static int list_homes(int argc, char *argv[], void *userdata) { if (table_get_rows(table) > 1 || arg_json) { r = table_set_sort(table, (size_t) 0, (size_t) -1); if (r < 0) - return log_error_errno(r, "Failed to sort table: %m"); + return table_log_sort_error(r); table_set_header(table, arg_legend); @@ -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_print_error(r); } if (arg_legend && !arg_json) { diff --git a/src/id128/id128.c b/src/id128/id128.c index 13996573ab..236043bf8a 100644 --- a/src/id128/id128.c +++ b/src/id128/id128.c @@ -139,7 +139,7 @@ static int verb_show(int argc, char **argv, void *userdata) { if (table) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); } return 0; diff --git a/src/login/inhibit.c b/src/login/inhibit.c index a1602031b4..e3866eee55 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -132,13 +132,13 @@ static int print_inhibitors(sd_bus *bus) { if (table_get_rows(table) > 1) { r = table_set_sort(table, (size_t) 1, (size_t) 0, (size_t) 5, (size_t) 6, (size_t) -1); if (r < 0) - return log_error_errno(r, "Failed to sort table: %m"); + return table_log_sort_error(r); table_set_header(table, arg_legend); r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_print_error(r); } if (arg_legend) { diff --git a/src/login/loginctl.c b/src/login/loginctl.c index ee617929ff..2b48a9acb7 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -91,7 +91,7 @@ static int show_table(Table *table, const char *word) { if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) { r = table_set_sort(table, (size_t) 0, (size_t) -1); if (r < 0) - return log_error_errno(r, "Failed to sort table: %m"); + return table_log_sort_error(r); table_set_header(table, arg_legend); @@ -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_print_error(r); } if (arg_legend) { diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index f41cf464b1..26fa48d870 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -237,7 +237,7 @@ static int show_table(Table *table, const char *word) { if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) { r = table_set_sort(table, (size_t) 0, (size_t) -1); if (r < 0) - return log_error_errno(r, "Failed to sort table: %m"); + return table_log_sort_error(r); table_set_header(table, arg_legend); @@ -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_print_error(r); } if (arg_legend) { diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 13f8a37ddf..84d5288c75 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1436,7 +1436,7 @@ static int list_devices(void) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); return 0; } diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 3b9da74e43..cc4639aeaf 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -719,7 +719,7 @@ static int list_links(int argc, char *argv[], void *userdata) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); if (arg_legend) printf("\n%i links listed.\n", c); @@ -1064,7 +1064,7 @@ static int dump_address_labels(sd_netlink *rtnl) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); return 0; } @@ -2129,7 +2129,7 @@ static int link_status_one( r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); return show_logs(info); } @@ -2201,7 +2201,7 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); return show_logs(NULL); } @@ -2421,7 +2421,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); if (arg_legend) { lldp_capabilities_legend(all); diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 46bb0e5437..aa6369864a 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -744,13 +744,13 @@ static int list_images(int argc, char *argv[], void *userdata) { if (table_get_rows(table) > 1) { r = table_set_sort(table, (size_t) 0, (size_t) -1); if (r < 0) - return log_error_errno(r, "Failed to sort table: %m"); + return table_log_sort_error(r); table_set_header(table, arg_legend); r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to show table: %m"); + return table_log_print_error(r); } if (arg_legend) { diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index b40f159c76..c01524b9cc 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -1079,7 +1079,7 @@ static int show_statistics(int argc, char **argv, void *userdata) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); return 0; } @@ -1519,7 +1519,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); if (empty_line) *empty_line = true; @@ -1760,7 +1760,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) { r = table_print(table, NULL); if (r < 0) - return log_error_errno(r, "Failed to print table: %m"); + return table_log_print_error(r); *empty_line = true; diff --git a/src/shared/format-table.h b/src/shared/format-table.h index 20b4ebd39b..1851f1d14a 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -130,3 +130,9 @@ 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_print_error(r) \ + log_error_errno(r, "Failed to print table: %m") + +#define table_log_sort_error(r) \ + log_error_errno(r, "Failed to sort table: %m") diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 954e5080ea..c58a19a099 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_print_error(r); return 0; } diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 96be78746d..eaac3b3e35 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_print_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_print_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_print_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"); + return table_log_print_error(r); return 0; } diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 382a1cc9e4..c973ee9c01 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_print_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_print_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_print_error(r); } return ret;