From 3445acda6d4d4a0e8514a91edecae394c253c01b Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Fri, 24 Feb 2023 00:43:35 +0800 Subject: [PATCH] lib: zstd: Fix a warning in `zstd_reset_dstream()` - ZSTD_resetDstream() is deprecated hence it is wise to make zstd_reset_dstream() functionally identical to ZSTD_resetDstream() as we have done for the compression stream in [1]. - Also make ZSTD_startingInputLength() visible for the decompression driver to be able to use it. - This fixes the below warning: ../lib/zstd/zstd_decompress_module.c: In function 'zstd_reset_dstream': ../lib/zstd/zstd_decompress_module.c:80:9: warning: 'ZSTD_resetDStream' is deprecated [-Wdeprecated-declarations] 80 | return ZSTD_resetDStream(dstream); | ^~~~~~ In file included from ../include/linux/zstd.h:26, from ../lib/zstd/zstd_decompress_module.c:15: ../include/linux/zstd_lib.h:2569:27: note: declared here 2569 | ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); | ^~~~~~~~~~~~~~~~~ [1]: https://github.com/facebook/zstd/pull/3088 Signed-off-by: Cyber Knight Change-Id: I4d9916dd279f3b0508ecb69754540f635ba7c5bc Signed-off-by: TogoFire --- include/linux/zstd_lib.h | 2 ++ lib/zstd/decompress/zstd_decompress.c | 2 +- lib/zstd/zstd_decompress_module.c | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/zstd_lib.h b/include/linux/zstd_lib.h index 778b73f830f58..626189722f895 100644 --- a/include/linux/zstd_lib.h +++ b/include/linux/zstd_lib.h @@ -2938,5 +2938,7 @@ ZSTD_registerSequenceProducer( ZSTD_sequenceProducer_F* sequenceProducer ); +ZSTDLIB_API size_t ZSTD_startingInputLength(ZSTD_format_e format); + #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ diff --git a/lib/zstd/decompress/zstd_decompress.c b/lib/zstd/decompress/zstd_decompress.c index 3edebf4a9df00..3a0e877e79e01 100644 --- a/lib/zstd/decompress/zstd_decompress.c +++ b/lib/zstd/decompress/zstd_decompress.c @@ -222,7 +222,7 @@ size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx) size_t ZSTD_estimateDCtxSize(void) { return sizeof(ZSTD_DCtx); } -static size_t ZSTD_startingInputLength(ZSTD_format_e format) +size_t ZSTD_startingInputLength(ZSTD_format_e format) { size_t const startingInputLength = ZSTD_FRAMEHEADERSIZE_PREFIX(format); /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */ diff --git a/lib/zstd/zstd_decompress_module.c b/lib/zstd/zstd_decompress_module.c index eb1c49e69722f..d7eda23d385c1 100644 --- a/lib/zstd/zstd_decompress_module.c +++ b/lib/zstd/zstd_decompress_module.c @@ -15,6 +15,8 @@ #include #include "common/zstd_deps.h" +#include "common/error_private.h" /* error codes and messages */ +#include "decompress/zstd_decompress_internal.h" /* ZSTD_DCtx */ /* Common symbols. zstd_compress must depend on zstd_decompress. */ @@ -77,7 +79,8 @@ EXPORT_SYMBOL(zstd_init_dstream); size_t zstd_reset_dstream(zstd_dstream *dstream) { - return ZSTD_resetDStream(dstream); + FORWARD_IF_ERROR(ZSTD_DCtx_reset(dstream, ZSTD_reset_session_only), ""); + return ZSTD_startingInputLength(dstream->format); } EXPORT_SYMBOL(zstd_reset_dstream);