From d836018a73bc0cc9c1525aea0706e56213589a70 Mon Sep 17 00:00:00 2001 From: fangxiuning Date: Tue, 7 Jul 2020 10:13:13 +0800 Subject: table add table_log_show_error() --- src/busctl/busctl.c | 2 +- src/home/homectl.c | 2 +- src/login/inhibit.c | 2 +- src/login/loginctl.c | 2 +- src/machine/machinectl.c | 2 +- src/portable/portablectl.c | 2 +- src/shared/format-table.h | 3 +++ src/systemctl/systemctl.c | 2 +- src/timedate/timedatectl.c | 8 ++++---- src/userdb/userdbctl.c | 6 +++--- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 3ab90de63e..f634588817 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 149f960f76..b5ad9d53d0 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 a1602031b4..d82aba8ec3 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 ee617929ff..78dfab7071 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 f41cf464b1..ace6439c79 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 46bb0e5437..d4de823345 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 20b4ebd39b..c828105f2c 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 954e5080ea..3933011c92 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 96be78746d..102ffece63 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 382a1cc9e4..55984518d0 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; -- cgit v1.2.1 From df83eb546b55222ef5cd30eb8d7c915f5be85878 Mon Sep 17 00:00:00 2001 From: fangxiuning Date: Tue, 7 Jul 2020 10:29:14 +0800 Subject: table add table_log_sort_error() --- src/home/homectl.c | 2 +- src/login/inhibit.c | 2 +- src/login/loginctl.c | 2 +- src/machine/machinectl.c | 2 +- src/portable/portablectl.c | 2 +- src/shared/format-table.h | 3 +++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/home/homectl.c b/src/home/homectl.c index b5ad9d53d0..888e77bc4e 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); diff --git a/src/login/inhibit.c b/src/login/inhibit.c index d82aba8ec3..d5f37d8dd8 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -132,7 +132,7 @@ 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); diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 78dfab7071..dd47ec381a 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); diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index ace6439c79..7c3eaad842 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); diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index d4de823345..889e240ea7 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -744,7 +744,7 @@ 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); diff --git a/src/shared/format-table.h b/src/shared/format-table.h index c828105f2c..d2fee3dbdd 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -133,3 +133,6 @@ int table_print_json(Table *t, FILE *f, JsonFormatFlags json_flags); #define table_log_show_error(r) \ log_error_errno(r, "Failed to show table: %m") + +#define table_log_sort_error(r) \ + log_error_errno(r, "Failed to sort table: %m") -- cgit v1.2.1 From 4b6607d94933ff297b6893e4eb5cdc622cc97504 Mon Sep 17 00:00:00 2001 From: fangxiuning Date: Wed, 8 Jul 2020 15:16:52 +0800 Subject: table use table_log_print_error() instead of table_log_show_error --- src/busctl/busctl.c | 2 +- src/home/homectl.c | 2 +- src/id128/id128.c | 2 +- src/login/inhibit.c | 2 +- src/login/loginctl.c | 2 +- src/machine/machinectl.c | 2 +- src/mount/mount-tool.c | 2 +- src/network/networkctl.c | 10 +++++----- src/portable/portablectl.c | 2 +- src/resolve/resolvectl.c | 6 +++--- src/shared/format-table.h | 4 ++-- src/systemctl/systemctl.c | 2 +- src/timedate/timedatectl.c | 8 ++++---- src/userdb/userdbctl.c | 6 +++--- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index f634588817..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 table_log_show_error(r); + return table_log_print_error(r); return 0; } diff --git a/src/home/homectl.c b/src/home/homectl.c index 888e77bc4e..33e262706d 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 table_log_show_error(r); + 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 d5f37d8dd8..e3866eee55 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 table_log_show_error(r); + return table_log_print_error(r); } if (arg_legend) { diff --git a/src/login/loginctl.c b/src/login/loginctl.c index dd47ec381a..2b48a9acb7 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 table_log_show_error(r); + return table_log_print_error(r); } if (arg_legend) { diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 7c3eaad842..26fa48d870 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 table_log_show_error(r); + 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 889e240ea7..aa6369864a 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 table_log_show_error(r); + 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 d2fee3dbdd..1851f1d14a 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -131,8 +131,8 @@ 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") +#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 3933011c92..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 table_log_show_error(r); + return table_log_print_error(r); return 0; } diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 102ffece63..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 table_log_show_error(r); + 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 table_log_show_error(r); + 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 table_log_show_error(r); + 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) - table_log_show_error(r); + return table_log_print_error(r); return 0; } diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 55984518d0..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 table_log_show_error(r); + 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 table_log_show_error(r); + 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 table_log_show_error(r); + return table_log_print_error(r); } return ret; -- cgit v1.2.1