aboutsummaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-04 07:24:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-04 07:24:52 +0200
commitb6d0bcbf1fa9c8088578c959f442e219f590ebf9 (patch)
tree2aaffddd7c46e1850b651796797c8df18622b14e /lib/common
parent30597cc7c5d566f671c84c025de97cb1fc2d242e (diff)
Cleanup: Pull compression level parameter out into compressor config
Every compressor (except LC4) has a compression level parameter. This commit pulls the compression level field out into the generic configuration structure and applies some code clean ups as a result from this. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/comp_lzo.c8
-rw-r--r--lib/common/comp_opt.c21
2 files changed, 5 insertions, 24 deletions
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index 0956e0e..3452647 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -193,7 +193,7 @@ static void lzo_get_configuration(const sqfs_compressor_t *base,
cfg->block_size = lzo->block_size;
cfg->opt.lzo.algorithm = lzo->algorithm;
- cfg->opt.lzo.level = lzo->level;
+ cfg->level = lzo->level;
if (base->do_block == lzo_uncomp_block)
cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
@@ -233,9 +233,9 @@ int lzo_compressor_create(const sqfs_compressor_config_t *cfg,
}
if (cfg->opt.lzo.algorithm == SQFS_LZO1X_999) {
- if (cfg->opt.lzo.level > SQFS_LZO_MAX_LEVEL)
+ if (cfg->level > SQFS_LZO_MAX_LEVEL)
return SQFS_ERROR_UNSUPPORTED;
- } else if (cfg->opt.lzo.level != 0) {
+ } else if (cfg->level != 0) {
return SQFS_ERROR_UNSUPPORTED;
}
@@ -262,7 +262,7 @@ int lzo_compressor_create(const sqfs_compressor_config_t *cfg,
lzo->block_size = cfg->block_size;
lzo->algorithm = cfg->opt.lzo.algorithm;
- lzo->level = cfg->opt.lzo.level;
+ lzo->level = cfg->level;
lzo->buf_size = scratch_size;
lzo->work_size = lzo_algs[cfg->opt.lzo.algorithm].bufsize;
diff --git a/lib/common/comp_opt.c b/lib/common/comp_opt.c
index 8864a0e..5be4466 100644
--- a/lib/common/comp_opt.c
+++ b/lib/common/comp_opt.c
@@ -185,29 +185,10 @@ int compressor_cfg_init_options(sqfs_compressor_config_t *cfg,
goto fail_level;
level = atoi(value);
-
if (level < min_level || level > max_level)
goto fail_level;
- switch (cfg->id) {
- case SQFS_COMP_GZIP:
- cfg->opt.gzip.level = level;
- break;
- case SQFS_COMP_LZO:
- cfg->opt.lzo.level = level;
- break;
- case SQFS_COMP_ZSTD:
- cfg->opt.zstd.level = level;
- break;
- case SQFS_COMP_XZ:
- cfg->opt.xz.level = level;
- break;
- case SQFS_COMP_LZMA:
- cfg->opt.lzma.level = level;
- break;
- default:
- goto fail_opt;
- }
+ cfg->level = level;
break;
case OPT_ALG:
if (cfg->id != SQFS_COMP_LZO)