From 85e36aab1258d8d9ec7b61ce013f167ef8e03ae0 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 5 Mar 2020 22:38:15 +0100 Subject: Change the signature of sqfs_compressor_create to return an error code Make sure the function has a way of telling the caller *why* it failed. This way, the function can convey whether it had an internal error, an allocation failure, whether the arguments are totaly nonsensical, or simply that the compressor *or specific configuration* is not supported. Signed-off-by: David Oberhollenzer --- unpack/rdsquashfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'unpack') diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c index 7b3bddf..5ca9de4 100644 --- a/unpack/rdsquashfs.c +++ b/unpack/rdsquashfs.c @@ -52,15 +52,15 @@ int main(int argc, char **argv) super.block_size, SQFS_COMP_FLAG_UNCOMPRESS); - cmp = sqfs_compressor_create(&cfg); + ret = sqfs_compressor_create(&cfg, &cmp); #ifdef WITH_LZO - if (super.compression_id == SQFS_COMP_LZO && cmp == NULL) - cmp = lzo_compressor_create(&cfg); + if (super.compression_id == SQFS_COMP_LZO && ret != 0) + ret = lzo_compressor_create(&cfg, &cmp); #endif - if (cmp == NULL) { - fputs("Error creating compressor.\n", stderr); + if (ret != 0) { + sqfs_perror(opt.image_name, "creating compressor", ret); goto out_file; } -- cgit v1.2.3