Skip to content

Commit

Permalink
lib: zstd: Fix a warning in zstd_reset_dstream()
Browse files Browse the repository at this point in the history
- 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]: facebook/zstd#3088

Signed-off-by: Cyber Knight <[email protected]>
  • Loading branch information
cyberknight777 authored and J1yann committed Jan 15, 2025
1 parent 8004ffa commit 5ff51f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/linux/zstd_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2984,5 +2984,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_
ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /*< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */

ZSTDLIB_API size_t ZSTD_startingInputLength(ZSTD_format_e format);

#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */

2 changes: 1 addition & 1 deletion lib/zstd/decompress/zstd_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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 */
Expand Down
5 changes: 4 additions & 1 deletion lib/zstd/zstd_decompress_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <linux/zstd.h>

#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. */

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5ff51f9

Please sign in to comment.