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:
@@ -1321,11 +1321,7 @@ static int verb_show_statistics(int argc, char *argv[], uintptr_t _data, void *u
|
||||
if (r < 0)
|
||||
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);
|
||||
}
|
||||
|
||||
static int verb_reset_statistics(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
@@ -1890,9 +1886,9 @@ static int print_configuration(DNSConfiguration *configuration, StatusMode mode,
|
||||
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 (empty_line)
|
||||
*empty_line = true;
|
||||
@@ -3097,11 +3093,7 @@ static int dump_server_state(sd_json_variant *server) {
|
||||
if (r < 0)
|
||||
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);
|
||||
}
|
||||
|
||||
static int verb_show_server_state(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
|
||||
Reference in New Issue
Block a user