aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--difftool/sqfsdiff.c10
-rw-r--r--extras/browse.c9
-rw-r--r--extras/list_files.c9
-rw-r--r--extras/mk42sqfs.c8
-rw-r--r--extras/mknastyfs.c8
-rw-r--r--include/common.h3
-rw-r--r--include/sqfs/compressor.h14
-rw-r--r--lib/common/comp_lzo.c17
-rw-r--r--lib/common/writer.c8
-rw-r--r--lib/sqfs/comp/compressor.c23
-rw-r--r--lib/sqfs/comp/gzip.c16
-rw-r--r--lib/sqfs/comp/internal.h15
-rw-r--r--lib/sqfs/comp/lz4.c11
-rw-r--r--lib/sqfs/comp/lzma.c11
-rw-r--r--lib/sqfs/comp/xz.c13
-rw-r--r--lib/sqfs/comp/zstd.c15
-rw-r--r--tar/sqfs2tar.c10
-rw-r--r--unpack/rdsquashfs.c10
18 files changed, 124 insertions, 86 deletions
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index c5d2bf2..6415165 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -39,15 +39,15 @@ static int open_sfqs(sqfs_state_t *state, const char *path)
state->super.block_size,
SQFS_COMP_FLAG_UNCOMPRESS);
- state->cmp = sqfs_compressor_create(&state->cfg);
+ ret = sqfs_compressor_create(&state->cfg, &state->cmp);
#ifdef WITH_LZO
- if (state->super.compression_id == SQFS_COMP_LZO && state->cmp == NULL)
- state->cmp = lzo_compressor_create(&state->cfg);
+ if (state->super.compression_id == SQFS_COMP_LZO && ret != 0)
+ ret = lzo_compressor_create(&state->cfg, &state->cmp);
#endif
- if (state->cmp == NULL) {
- fprintf(stderr, "%s: error creating compressor.\n", path);
+ if (ret != 0) {
+ sqfs_perror(path, "creating compressor", ret);
goto fail_file;
}
diff --git a/extras/browse.c b/extras/browse.c
index 5b27dc6..9dd735a 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -477,10 +477,10 @@ static const struct {
int main(int argc, char **argv)
{
char *cmd, *arg, *buffer = NULL;
+ int ret, status = EXIT_FAILURE;
sqfs_compressor_config_t cfg;
sqfs_compressor_t *cmp;
sqfs_file_t *file;
- int status = EXIT_FAILURE;
size_t i;
/* open the SquashFS file we want to read */
@@ -511,9 +511,10 @@ int main(int argc, char **argv)
super.block_size,
SQFS_COMP_FLAG_UNCOMPRESS);
- cmp = sqfs_compressor_create(&cfg);
- if (cmp == NULL) {
- fprintf(stderr, "%s: error creating compressor.\n", argv[1]);
+ ret = sqfs_compressor_create(&cfg, &cmp);
+ if (ret != 0) {
+ fprintf(stderr, "%s: error creating compressor: %d.\n",
+ argv[1], ret);
goto out_fd;
}
diff --git a/extras/list_files.c b/extras/list_files.c
index 5e181f2..eba4fff 100644
--- a/extras/list_files.c
+++ b/extras/list_files.c
@@ -47,6 +47,7 @@ static void write_tree_dfs(const sqfs_tree_node_t *n)
int main(int argc, char **argv)
{
+ int ret, status = EXIT_FAILURE;
sqfs_compressor_config_t cfg;
sqfs_compressor_t *cmp;
sqfs_tree_node_t *root = NULL;
@@ -54,7 +55,6 @@ int main(int argc, char **argv)
sqfs_dir_reader_t *dr;
sqfs_file_t *file;
sqfs_super_t super;
- int status = EXIT_FAILURE;
/* open the SquashFS file we want to read */
if (argc != 2) {
@@ -84,9 +84,10 @@ int main(int argc, char **argv)
super.block_size,
SQFS_COMP_FLAG_UNCOMPRESS);
- cmp = sqfs_compressor_create(&cfg);
- if (cmp == NULL) {
- fprintf(stderr, "%s: error creating compressor.\n", argv[1]);
+ ret = sqfs_compressor_create(&cfg, &cmp);
+ if (ret != 0) {
+ fprintf(stderr, "%s: error creating compressor: %d.\n",
+ argv[1], ret);
goto out_fd;
}
diff --git a/extras/mk42sqfs.c b/extras/mk42sqfs.c
index e7c5357..92323e0 100644
--- a/extras/mk42sqfs.c
+++ b/extras/mk42sqfs.c
@@ -50,10 +50,10 @@ 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;
unsigned int i, inode_num;
- int status = EXIT_FAILURE;
sqfs_dir_writer_t *dirwr;
sqfs_compressor_t *cmp;
sqfs_id_table_t *idtbl;
@@ -88,9 +88,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;
}
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;
}
diff --git a/include/common.h b/include/common.h
index bbdf81d..2ecea42 100644
--- a/include/common.h
+++ b/include/common.h
@@ -148,7 +148,8 @@ void print_version(const char *progname);
XXX: This must be in libcommon instead of libsquashfs for legal reasons.
*/
-sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg);
+int lzo_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
/*
Parse a number optionally followed by a KMG suffix (case insensitive). Prints
diff --git a/include/sqfs/compressor.h b/include/sqfs/compressor.h
index fd5d7e8..1a36c82 100644
--- a/include/sqfs/compressor.h
+++ b/include/sqfs/compressor.h
@@ -351,13 +351,19 @@ SQFS_API bool sqfs_compressor_exists(SQFS_COMPRESSOR id);
/**
* @brief Create an instance of a compressor implementation.
*
+ * If this function returns @ref SQFS_ERROR_UNSUPPORTED, it can mean that
+ * either the compressor is not supported at all by the version of libsquashfs
+ * you are using, or that the specific configuration that has been requested
+ * is not supported (e.g. unknown flags, or the local version can only
+ * uncompress, but not compress).
+ *
* @param cfg A pointer to a compressor configuration.
+ * @param out Returns a pointer to the compressor on success.
*
- * @return A pointer to a compressor object on success, NULL on allocation
- * failure or if initializing the compressor failed.
+ * @return Zero on success, an SQFS_ERROR code on failure.
*/
-SQFS_API
-sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg);
+SQFS_API int sqfs_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
/**
* @brief Get the name of a compressor backend from its ID.
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index 24f4009..0956e0e 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -217,25 +217,26 @@ static void lzo_destroy(sqfs_object_t *base)
free(base);
}
-sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
+int lzo_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
sqfs_compressor_t *base;
lzo_compressor_t *lzo;
size_t scratch_size;
if (cfg->flags & ~SQFS_COMP_FLAG_GENERIC_ALL)
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
if (cfg->opt.lzo.algorithm >= LZO_NUM_ALGS ||
lzo_algs[cfg->opt.lzo.algorithm].compress == NULL) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
if (cfg->opt.lzo.algorithm == SQFS_LZO1X_999) {
if (cfg->opt.lzo.level > SQFS_LZO_MAX_LEVEL)
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
} else if (cfg->opt.lzo.level != 0) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
/* XXX: liblzo does not do bounds checking internally,
@@ -257,7 +258,7 @@ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
base = (sqfs_compressor_t *)lzo;
if (lzo == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
lzo->block_size = cfg->block_size;
lzo->algorithm = cfg->opt.lzo.algorithm;
@@ -272,5 +273,7 @@ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
base->read_options = lzo_read_options;
((sqfs_object_t *)base)->copy = lzo_create_copy;
((sqfs_object_t *)base)->destroy = lzo_destroy;
- return base;
+
+ *out = base;
+ return 0;
}
diff --git a/lib/common/writer.c b/lib/common/writer.c
index 4762b82..84a98a5 100644
--- a/lib/common/writer.c
+++ b/lib/common/writer.c
@@ -85,19 +85,19 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
if (fstree_init(&sqfs->fs, wrcfg->fs_defaults))
goto fail_file;
- sqfs->cmp = sqfs_compressor_create(&cfg);
+ ret = sqfs_compressor_create(&cfg, &sqfs->cmp);
#ifdef WITH_LZO
if (cfg.id == SQFS_COMP_LZO) {
if (sqfs->cmp != NULL)
sqfs_destroy(sqfs->cmp);
- sqfs->cmp = lzo_compressor_create(&cfg);
+ ret = lzo_compressor_create(&cfg, &sqfs->cmp);
}
#endif
- if (sqfs->cmp == NULL) {
- fputs("Error creating compressor\n", stderr);
+ if (ret != 0) {
+ sqfs_perror(wrcfg->filename, "creating compressor", ret);
goto fail_fs;
}
diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c
index 28de2c5..3b48030 100644
--- a/lib/sqfs/comp/compressor.c
+++ b/lib/sqfs/comp/compressor.c
@@ -12,8 +12,8 @@
#include "internal.h"
-typedef sqfs_compressor_t *(*compressor_fun_t)
- (const sqfs_compressor_config_t *cfg);
+typedef int (*compressor_fun_t)(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
static compressor_fun_t compressors[SQFS_COMP_MAX + 1] = {
#ifdef WITH_GZIP
@@ -81,17 +81,24 @@ bool sqfs_compressor_exists(SQFS_COMPRESSOR id)
return (compressors[id] != NULL);
}
-sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg)
+int sqfs_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
sqfs_u8 padd0[sizeof(cfg->opt)];
int ret;
- if (cfg == NULL || cfg->id < SQFS_COMP_MIN || cfg->id > SQFS_COMP_MAX)
- return NULL;
+ /* check compressor ID */
+ if (cfg == NULL)
+ return SQFS_ERROR_ARG_INVALID;
+
+ if (cfg->id < SQFS_COMP_MIN || cfg->id > SQFS_COMP_MAX)
+ return SQFS_ERROR_UNSUPPORTED;
if (compressors[cfg->id] == NULL)
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
+ /* make sure the padding bytes are cleared, so we could theoretically
+ turn them into option fields in the future and remain compatible */
memset(padd0, 0, sizeof(padd0));
switch (cfg->id) {
@@ -117,9 +124,9 @@ sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg)
}
if (ret != 0)
- return NULL;
+ return SQFS_ERROR_ARG_INVALID;
- return compressors[cfg->id](cfg);
+ return compressors[cfg->id](cfg, out);
}
const char *sqfs_compressor_name_from_id(SQFS_COMPRESSOR id)
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 351d733..d702da1 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -247,7 +247,8 @@ static sqfs_object_t *gzip_create_copy(const sqfs_object_t *cmp)
return (sqfs_object_t *)gzip;
}
-sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg)
+int gzip_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
gzip_compressor_t *gzip;
sqfs_compressor_t *base;
@@ -255,24 +256,24 @@ sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg)
if (cfg->flags & ~(SQFS_COMP_FLAG_GZIP_ALL |
SQFS_COMP_FLAG_GENERIC_ALL)) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
if (cfg->opt.gzip.level < SQFS_GZIP_MIN_LEVEL ||
cfg->opt.gzip.level > SQFS_GZIP_MAX_LEVEL) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
if (cfg->opt.gzip.window_size < SQFS_GZIP_MIN_WINDOW ||
cfg->opt.gzip.window_size > SQFS_GZIP_MAX_WINDOW) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
gzip = calloc(1, sizeof(*gzip));
base = (sqfs_compressor_t *)gzip;
if (gzip == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
gzip->opt.level = cfg->opt.gzip.level;
gzip->opt.window = cfg->opt.gzip.window_size;
@@ -296,8 +297,9 @@ sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg)
if (ret != Z_OK) {
free(gzip);
- return NULL;
+ return SQFS_ERROR_COMPRESSOR;
}
- return base;
+ *out = base;
+ return 0;
}
diff --git a/lib/sqfs/comp/internal.h b/lib/sqfs/comp/internal.h
index 7518f56..0566683 100644
--- a/lib/sqfs/comp/internal.h
+++ b/lib/sqfs/comp/internal.h
@@ -24,18 +24,23 @@ SQFS_INTERNAL
int sqfs_generic_read_options(sqfs_file_t *file, void *data, size_t size);
SQFS_INTERNAL
-sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg);
+int xz_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
SQFS_INTERNAL
-sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg);
+int gzip_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
SQFS_INTERNAL
-sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg);
+int lz4_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
SQFS_INTERNAL
-sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg);
+int zstd_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
SQFS_INTERNAL
-sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg);
+int lzma_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out);
#endif /* INTERNAL_H */
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index 460ac44..4791746 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -132,20 +132,21 @@ static void lz4_destroy(sqfs_object_t *base)
free(base);
}
-sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg)
+int lz4_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
sqfs_compressor_t *base;
lz4_compressor_t *lz4;
if (cfg->flags & ~(SQFS_COMP_FLAG_LZ4_ALL |
SQFS_COMP_FLAG_GENERIC_ALL)) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
lz4 = calloc(1, sizeof(*lz4));
base = (sqfs_compressor_t *)lz4;
if (lz4 == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
lz4->high_compression = (cfg->flags & SQFS_COMP_FLAG_LZ4_HC) != 0;
lz4->block_size = cfg->block_size;
@@ -157,5 +158,7 @@ sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg)
base->read_options = lz4_read_options;
((sqfs_object_t *)base)->copy = lz4_create_copy;
((sqfs_object_t *)base)->destroy = lz4_destroy;
- return base;
+
+ *out = base;
+ return 0;
}
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 51afe65..2a6cd1f 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -171,18 +171,19 @@ static void lzma_destroy(sqfs_object_t *base)
free(base);
}
-sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg)
+int lzma_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
sqfs_compressor_t *base;
lzma_compressor_t *lzma;
if (cfg->flags & ~SQFS_COMP_FLAG_GENERIC_ALL)
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
lzma = calloc(1, sizeof(*lzma));
base = (sqfs_compressor_t *)lzma;
if (lzma == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
lzma->block_size = cfg->block_size;
@@ -196,5 +197,7 @@ sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg)
base->read_options = lzma_read_options;
((sqfs_object_t *)base)->copy = lzma_create_copy;
((sqfs_object_t *)base)->destroy = lzma_destroy;
- return base;
+
+ *out = base;
+ return 0;
}
diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c
index 423604b..32fb032 100644
--- a/lib/sqfs/comp/xz.c
+++ b/lib/sqfs/comp/xz.c
@@ -227,23 +227,24 @@ static void xz_destroy(sqfs_object_t *base)
free(base);
}
-sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg)
+int xz_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
sqfs_compressor_t *base;
xz_compressor_t *xz;
if (cfg->flags & ~(SQFS_COMP_FLAG_GENERIC_ALL |
SQFS_COMP_FLAG_XZ_ALL)) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
if (!is_dict_size_valid(cfg->opt.xz.dict_size))
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
xz = calloc(1, sizeof(*xz));
base = (sqfs_compressor_t *)xz;
if (xz == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
xz->flags = cfg->flags;
xz->dict_size = cfg->opt.xz.dict_size;
@@ -255,5 +256,7 @@ sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg)
base->read_options = xz_read_options;
((sqfs_object_t *)base)->copy = xz_create_copy;
((sqfs_object_t *)base)->destroy = xz_destroy;
- return base;
+
+ *out = base;
+ return 0;
}
diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c
index 12ddfdb..986c669 100644
--- a/lib/sqfs/comp/zstd.c
+++ b/lib/sqfs/comp/zstd.c
@@ -134,29 +134,30 @@ static void zstd_destroy(sqfs_object_t *base)
free(zstd);
}
-sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg)
+int zstd_compressor_create(const sqfs_compressor_config_t *cfg,
+ sqfs_compressor_t **out)
{
zstd_compressor_t *zstd;
sqfs_compressor_t *base;
if (cfg->flags & ~SQFS_COMP_FLAG_GENERIC_ALL)
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
if (cfg->opt.zstd.level < 1 ||
cfg->opt.zstd.level > ZSTD_maxCLevel()) {
- return NULL;
+ return SQFS_ERROR_UNSUPPORTED;
}
zstd = calloc(1, sizeof(*zstd));
base = (sqfs_compressor_t *)zstd;
if (zstd == NULL)
- return NULL;
+ return SQFS_ERROR_ALLOC;
zstd->block_size = cfg->block_size;
zstd->zctx = ZSTD_createCCtx();
if (zstd->zctx == NULL) {
free(zstd);
- return NULL;
+ return SQFS_ERROR_COMPRESSOR;
}
base->get_configuration = zstd_get_configuration;
@@ -166,5 +167,7 @@ sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg)
base->read_options = zstd_read_options;
((sqfs_object_t *)base)->copy = zstd_create_copy;
((sqfs_object_t *)base)->destroy = zstd_destroy;
- return base;
+
+ *out = base;
+ return 0;
}
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index 2e4d0ef..2b013d6 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -556,15 +556,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(filename, "creating compressor", ret);
goto out_fd;
}
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;
}