From fd5c9f1259d0191af57b20f06dda35e62acb6275 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 13 Jun 2023 23:44:19 +0200 Subject: Overhaul sqfs_istream_t/sqfs_ostream_t error handling Report an error number from the implementations, change the users to forward that error number (which also means libtar write header/link now returns an error code) and all subsequent binaries to use sqfs_perror() instead of relying on the function to print an error internally. Also, make sure to preserve errno/GetLastError() in the implementations and print out a stringified error in sqfs_perror() if the error code indicates an I/O error. Signed-off-by: David Oberhollenzer --- bin/sqfs2tar/src/sqfs2tar.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin/sqfs2tar/src/sqfs2tar.c') diff --git a/bin/sqfs2tar/src/sqfs2tar.c b/bin/sqfs2tar/src/sqfs2tar.c index e90aa56..714f6db 100644 --- a/bin/sqfs2tar/src/sqfs2tar.c +++ b/bin/sqfs2tar/src/sqfs2tar.c @@ -117,9 +117,9 @@ int main(int argc, char **argv) process_args(argc, argv); - out_file = ostream_open_stdout(); - if (out_file == NULL) { - perror("changing stdout to binary mode"); + ret = ostream_open_stdout(&out_file); + if (ret) { + sqfs_perror("stdout", "creating stream wrapper", ret); goto out; } @@ -253,8 +253,11 @@ int main(int argc, char **argv) if (terminate_archive()) goto out; - if (out_file->flush(out_file)) + ret = out_file->flush(out_file); + if (ret) { + sqfs_perror(out_file->get_filename(out_file), NULL, ret); goto out; + } status = EXIT_SUCCESS; out: -- cgit v1.2.3