
From: Chenghai Huang <huangchenghai2@huawei.com> 1.The windowsize is incorrectly calculated. For example, when the user input 28 to configure a 4 KB window size, *windowsize should be WD_COMP_WS_4KB. 2.When the caller sets level to -1, it mean that the default level(6) is set. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Qi Tao <taoqi10@huawei.com> --- include/wd_zlibwrapper.h | 2 +- wd_zlibwrapper.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h index 58ad503d..978d1ed2 100644 --- a/include/wd_zlibwrapper.h +++ b/include/wd_zlibwrapper.h @@ -39,7 +39,7 @@ extern "C" { #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) -#define Z_DEFLATED 0 +#define Z_DEFAULT_COMPRESSION (-1) #define MAX_WBITS 15 #define DEF_MEM_LEVEL 0 #define Z_DEFAULT_STRATEGY 0 diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 4aa070c2..4dc6c193 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -85,7 +85,7 @@ static int wd_zlib_analy_alg(int windowbits, int *alg, int *windowsize) static const int DEFLATE_MAX_WBITS = -8; static const int DEFLATE_MIN_WBITS = -15; static const int WBINS_ZLIB_4K = 12; - static const int WBINS_GZIP_4K = 27; + static const int WBINS_GZIP_4K = 28; static const int WBINS_DEFLATE_4K = 12; if ((windowbits >= ZLIB_MIN_WBITS) && (windowbits <= ZLIB_MAX_WBITS)) { @@ -120,7 +120,7 @@ static int wd_zlib_alloc_sess(z_streamp strm, int level, int windowbits, enum wd return ret; } - setup.comp_lv = level; + setup.comp_lv = level == Z_DEFAULT_COMPRESSION ? WD_COMP_L6 : level; setup.alg_type = alg; setup.win_sz = windowsize; setup.op_type = type; -- 2.33.0