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 --- lib/io/src/xfrm/istream.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/io/src/xfrm/istream.c') diff --git a/lib/io/src/xfrm/istream.c b/lib/io/src/xfrm/istream.c index c499f6c..ee4b5bd 100644 --- a/lib/io/src/xfrm/istream.c +++ b/lib/io/src/xfrm/istream.c @@ -6,6 +6,7 @@ */ #include "../internal.h" #include "sqfs/io.h" +#include "sqfs/error.h" typedef struct istream_xfrm_t { sqfs_istream_t base; @@ -52,11 +53,8 @@ static int precache(sqfs_istream_t *base) BUFSZ - out_off, &in_off, &out_off, mode); - if (ret == XFRM_STREAM_ERROR) { - fprintf(stderr, "%s: internal error in decompressor.\n", - base->get_filename(base)); - return -1; - } + if (ret == XFRM_STREAM_ERROR) + return SQFS_ERROR_COMPRESSOR; xfrm->buffer_used = out_off; xfrm->wrapped->advance_buffer(xfrm->wrapped, in_off); -- cgit v1.2.3