tree-wide: print error if table_print() fails
We generally want to print an error message if table_print() fails. Add a helper function for this and use it consistently. This does one of the three things depending on the call site: - a no-change reformatting of the code - change from a custom message to the generic one - addition of the error message where previously none was printed In the third case, the actual use impact is very small, since the table formatting is very unlikely to fail. But if it did, we would often return an error without any message whatsoever, which we never want to do.
This commit is contained in:
@@ -82,11 +82,7 @@ static int dump_address_labels(sd_netlink *rtnl) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_print(table);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
|
||||
return 0;
|
||||
return table_print_or_warn(table);
|
||||
}
|
||||
|
||||
int verb_list_address_labels(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
|
||||
@@ -79,9 +79,9 @@ int verb_list_links(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = table_print(table);
|
||||
r = table_print_or_warn(table);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
return r;
|
||||
|
||||
if (arg_legend)
|
||||
printf("\n%i links listed.\n", c);
|
||||
|
||||
@@ -303,9 +303,9 @@ int verb_link_lldp_status(int argc, char *argv[], uintptr_t _data, void *userdat
|
||||
}
|
||||
}
|
||||
|
||||
r = table_print(table);
|
||||
r = table_print_or_warn(table);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
return r;
|
||||
|
||||
if (arg_legend) {
|
||||
lldp_capabilities_legend(all);
|
||||
|
||||
@@ -900,9 +900,9 @@ static int link_status_one(
|
||||
on_color_operational, glyph(GLYPH_BLACK_CIRCLE), off_color_operational,
|
||||
info->ifindex, info->name);
|
||||
|
||||
r = table_print(table);
|
||||
r = table_print_or_warn(table);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
return r;
|
||||
|
||||
return show_logs(info->ifindex, info->name);
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
|
||||
on_color_operational, glyph(GLYPH_BLACK_CIRCLE), off_color_operational,
|
||||
strna(netifs_joined));
|
||||
|
||||
r = table_print(table);
|
||||
r = table_print_or_warn(table);
|
||||
if (r < 0)
|
||||
return table_log_print_error(r);
|
||||
return r;
|
||||
|
||||
return show_logs(0, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user