From e470c940f6cb6cfff4b27d595ec651a3c1c2cc15 Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Mon, 7 Mar 2022 11:55:33 +0800 Subject: [PATCH 1/3] [contrib][linux] Fix a warning in zstd_reset_cstream() - This fixes the below warning: ../lib/zstd/zstd_compress_module.c: In function 'zstd_reset_cstream': ../lib/zstd/zstd_compress_module.c:136:9: warning: 'ZSTD_resetCStream' is deprecated [-Wdeprecated-declarations] 136 | return ZSTD_resetCStream(cstream, pledged_src_size); | ^~~~~~ In file included from ../include/linux/zstd.h:26, from ../lib/zstd/zstd_compress_module.c:15: ../include/linux/zstd_lib.h:2277:8: note: declared here 2277 | size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); | ^~~~~~~~~~~~~~~~~ ZSTD_resetCstream is deprecated and zstd_CCtx_reset is suggested to use hence let's switch to it. Signed-off-by: Cyber Knight --- contrib/linux-kernel/zstd_compress_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/linux-kernel/zstd_compress_module.c b/contrib/linux-kernel/zstd_compress_module.c index 65548a4bb..7b25be6e3 100644 --- a/contrib/linux-kernel/zstd_compress_module.c +++ b/contrib/linux-kernel/zstd_compress_module.c @@ -133,7 +133,7 @@ EXPORT_SYMBOL(zstd_init_cstream); size_t zstd_reset_cstream(zstd_cstream *cstream, unsigned long long pledged_src_size) { - return ZSTD_resetCStream(cstream, pledged_src_size); + return ZSTD_CCtx_reset(cstream, pledged_src_size); } EXPORT_SYMBOL(zstd_reset_cstream); From 8ff20c25f38f62cd1e898cf81173e280f42327f5 Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Tue, 8 Mar 2022 13:38:06 +0800 Subject: [PATCH 2/3] [contrib][linux] Use ZSTD_CCtx_setPledgedSrcSize() instead of ZSTD_CCtx_reset() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The previous patch throws the following warning: ../linux/lib/zstd/zstd_compress_module.c: In function ‘zstd_reset_cstream’: ../linux/lib/zstd/zstd_compress_module.c:136:34: error: enum conversion when passing argument 2 of ‘ZSTD_CCtx_reset’ is invalid in C++ [-Werror=c++-compat] 136 | return ZSTD_CCtx_reset(cstream, pledged_src_size); | ^~~~~~~~~~~~~~~~ In file included from ../linux/include/linux/zstd.h:26, from ../linux/lib/zstd/zstd_compress_module.c:15: ../linux/include/linux/zstd_lib.h:501:20: note: expected ‘ZSTD_ResetDirective’ {aka ‘enum ’} but argument is of type ‘long long unsigned int’ 501 | ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset); | ^~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Since we have a choice to either use ZSTD_CCtx_reset or ZSTD_CCtx_setPledgedSrcSize instead of ZSTD_resetCStream, let's switch to ZSTD_CCtx_setPledgedSrcSize to not have any unnecessary warns alongside the kernel build and CI test build. Signed-off-by: Cyber Knight --- contrib/linux-kernel/zstd_compress_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/linux-kernel/zstd_compress_module.c b/contrib/linux-kernel/zstd_compress_module.c index 7b25be6e3..8b4c764d4 100644 --- a/contrib/linux-kernel/zstd_compress_module.c +++ b/contrib/linux-kernel/zstd_compress_module.c @@ -131,9 +131,9 @@ zstd_cstream *zstd_init_cstream(const zstd_parameters *parameters, EXPORT_SYMBOL(zstd_init_cstream); size_t zstd_reset_cstream(zstd_cstream *cstream, - unsigned long long pledged_src_size) + unsigned long long pledgedSrcSize) { - return ZSTD_CCtx_reset(cstream, pledged_src_size); + return ZSTD_CCtx_setPledgedSrcSize(cstream, pledgedSrcSize); } EXPORT_SYMBOL(zstd_reset_cstream); From 498ac8238d98cc5f7153fa58a5e0a5222ffd88be Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Thu, 10 Mar 2022 15:32:13 +0800 Subject: [PATCH 3/3] [contrib][linux] Make zstd_reset_cstream() functionally identical to ZSTD_resetCStream() - As referenced by Nick Terrelln ~ the ZSTD maintainer in the linux kernel, 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. Suggested-by: Nick Terrell Signed-off-by: Cyber Knight --- contrib/linux-kernel/zstd_compress_module.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/linux-kernel/zstd_compress_module.c b/contrib/linux-kernel/zstd_compress_module.c index 8b4c764d4..04e1b5c01 100644 --- a/contrib/linux-kernel/zstd_compress_module.c +++ b/contrib/linux-kernel/zstd_compress_module.c @@ -131,9 +131,13 @@ zstd_cstream *zstd_init_cstream(const zstd_parameters *parameters, EXPORT_SYMBOL(zstd_init_cstream); size_t zstd_reset_cstream(zstd_cstream *cstream, - unsigned long long pledgedSrcSize) + unsigned long long pledged_src_size) { - return ZSTD_CCtx_setPledgedSrcSize(cstream, pledgedSrcSize); + 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);