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 --- extras/mknastyfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'extras/mknastyfs.c') diff --git a/extras/mknastyfs.c b/extras/mknastyfs.c index 7ec3ee0..daadf37 100644 --- a/extras/mknastyfs.c +++ b/extras/mknastyfs.c @@ -46,9 +46,9 @@ static sqfs_inode_generic_t *create_file_inode(sqfs_id_table_t *idtbl, int main(void) { sqfs_meta_writer_t *inode_m, *dir_m; + int ret, status = EXIT_FAILURE; sqfs_compressor_config_t cfg; sqfs_inode_generic_t *inode; - int status = EXIT_FAILURE; sqfs_dir_writer_t *dirwr; sqfs_compressor_t *cmp; sqfs_id_table_t *idtbl; @@ -77,9 +77,9 @@ int main(void) sqfs_compressor_config_init(&cfg, super.compression_id, super.block_size, 0); - cmp = sqfs_compressor_create(&cfg); - if (cmp == NULL) { - fputs("Error creating compressor.\n", stderr); + ret = sqfs_compressor_create(&cfg, &cmp); + if (ret != 0) { + fprintf(stderr, "Error creating compressor: %d.\n", ret); goto out_file; } -- cgit v1.2.3