Merge pull request #16385 from JackFangXN/master

table add table_log_xx_error()
This commit is contained in:
Lennart Poettering
2020-07-08 12:12:29 +02:00
committed by GitHub
14 changed files with 35 additions and 29 deletions
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -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) {
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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) {
+2 -2
View File
@@ -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) {
+2 -2
View File
@@ -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) {
+1 -1
View File
@@ -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;
}
+5 -5
View File
@@ -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);
+2 -2
View File
@@ -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) {
+3 -3
View File
@@ -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;
+6
View File
@@ -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")
+1 -1
View File
@@ -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;
}
+4 -4
View File
@@ -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;
}
+3 -3
View File
@@ -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;