From add7b85717f9086edb353f87f0ff5f5ffb58cb2c Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Wed, 23 Mar 2022 23:52:21 +0800 Subject: [PATCH] lib: zstd: Revise the warning fix at zstd_reset_cstream() Subsequent to 15f1b5e137 {"lib: zstd: Fix a warning in zstd_reset_cstream()"} - As referenced by Nick Terrelln ~ the ZSTD maintainer in the linux kernel [1], making zstd_reset_cstream() functionally identical to ZSTD_resetCStream() would be the perfect way to fix the warning without touching any core functions or breaking other parts of the code. [1]: https://github.com/facebook/zstd/pull/3088#discussion_r822064161 Suggested-by: Nick Terrell Signed-off-by: Cyber Knight --- lib/zstd/zstd_compress_module.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/zstd/zstd_compress_module.c b/lib/zstd/zstd_compress_module.c index 1f07078e053f..04e1b5c01d9b 100644 --- a/lib/zstd/zstd_compress_module.c +++ b/lib/zstd/zstd_compress_module.c @@ -133,7 +133,11 @@ EXPORT_SYMBOL(zstd_init_cstream); size_t zstd_reset_cstream(zstd_cstream *cstream, unsigned long long pledged_src_size) { - return ZSTD_CCtx_reset(cstream, pledged_src_size); + if (pledged_src_size == 0) + pledged_src_size = ZSTD_CONTENTSIZE_UNKNOWN; + ZSTD_FORWARD_IF_ERR( ZSTD_CCtx_reset(cstream, ZSTD_reset_session_only) ); + ZSTD_FORWARD_IF_ERR( ZSTD_CCtx_setPledgedSrcSize(cstream, pledged_src_size) ); + return 0; } EXPORT_SYMBOL(zstd_reset_cstream);