tree-wide: drop flush&check step after table printing

Almost all callers of table_print() specify stdout or NULL (equivalent
to stdout) as the output stream. Simplify things by not requiring the
the stream to be specified.

In almost all cases, the printing of the table is surrounded by normal
printfs() that don't do explicit flushing and for which we don't check
the output stream status. Let's simplify most callers and skip this
step. The reason is not so much to avoid the extra step itself, but
instead to avoid the _handling_ of the potential failure. We generally
only want to print an error message for ENOMEM and other "internal"
errors, so strictly speaking we should filter out the errors from the
stream. By skipping the flush&check step we implicitly do this.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-03 13:04:40 +02:00
parent 16a43412b9
commit 0ce5a8fb4e
44 changed files with 67 additions and 60 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
output_waiting_jobs(bus, table, j->id, "GetJobBefore", "\twaiting for job");
}
r = table_print(table, NULL);
r = table_print(table);
if (r < 0)
return log_error_errno(r, "Failed to print the table: %m");
+1 -1
View File
@@ -919,7 +919,7 @@ int output_table(Table *table) {
if (OUTPUT_MODE_IS_JSON(arg_output))
r = table_print_json(table, NULL, output_mode_to_json_format_flags(arg_output) | SD_JSON_FORMAT_COLOR_AUTO);
else
r = table_print(table, NULL);
r = table_print(table);
if (r < 0)
return table_log_print_error(r);