From: i-do-cpp <62053234+i-do-cpp@users.noreply.github.com> Date: Mon, 31 Aug 2020 07:25:43 +0000 (+0200) Subject: Fix setParameter not falling back to default compression level on 0 value X-Git-Tag: v1.4.7~84^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d514281e730a0798c8f386829e6d37632db6adef;p=thirdparty%2Fzstd.git Fix setParameter not falling back to default compression level on 0 value See documentation for `ZSTD_c_compressionLevel`: `Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT` --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index a5ffcf1ea..25160d0d9 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -540,7 +540,9 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams, case ZSTD_c_compressionLevel : { FORWARD_IF_ERROR(ZSTD_cParam_clampBounds(param, &value), ""); - if (value) { /* 0 : does not change current level */ + if (value == 0) + CCtxParams->compressionLevel = ZSTD_CLEVEL_DEFAULT; /* 0 == default */ + else CCtxParams->compressionLevel = value; } if (CCtxParams->compressionLevel >= 0) return (size_t)CCtxParams->compressionLevel;