Compare commits

...

5 Commits

Author SHA1 Message Date
Lennart Poettering 24e2494407
Merge pull request #16385 from JackFangXN/master
table add table_log_xx_error()
2020-07-08 12:12:29 +02:00
Yu Watanabe 43b24a0716 sd-device: use log_device_debug_errno() 2020-07-08 12:11:19 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
15 changed files with 36 additions and 30 deletions

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;
}

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) {

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;

View File

@ -1586,7 +1586,7 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd
/* this is a child device, skipping */
return 0;
if (errno != ENOENT) {
log_debug_errno(errno, "Failed to stat %s, ignoring subdir: %m", p);
log_device_debug_errno(device, errno, "sd-device: Failed to stat %s, ignoring subdir: %m", p);
return 0;
}

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) {

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) {

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) {

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;
}

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);

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) {

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;

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")

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;
}

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;
}

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;