From b339efff2bc9d11ce091bca62328c1884a38b5f3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 19 Dec 2024 09:45:28 -0800 Subject: [PATCH] add dedicated error code for special case ZSTD_compressSequencesAndLiterals() cannot produce an uncompressed block --- doc/zstd_manual.html | 1 - lib/common/error_private.c | 1 + lib/compress/zstd_compress.c | 2 +- lib/zstd_errors.h | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html index a50dd3c5d..30908e0aa 100644 --- a/doc/zstd_manual.html +++ b/doc/zstd_manual.html @@ -1431,7 +1431,6 @@ ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx, but it also features the following limitations: - Only supports explicit delimiter mode - Not compatible with frame checksum, which must disabled - - Does not write the content size in frame header - If any block is incompressible, will fail and return an error - @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error. - the buffer @literals must be larger than @litSize by at least 8 bytes. diff --git a/lib/common/error_private.c b/lib/common/error_private.c index 075fc5ef4..7e7f24f67 100644 --- a/lib/common/error_private.c +++ b/lib/common/error_private.c @@ -40,6 +40,7 @@ const char* ERR_getErrorString(ERR_enum code) case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported"; case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large"; case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small"; + case PREFIX(cannotProduce_uncompressedBlock): return "This mode cannot generate an uncompressed block"; case PREFIX(stabilityCondition_notRespected): return "pledged buffer stability condition is not respected"; case PREFIX(dictionary_corrupted): return "Dictionary is corrupted"; case PREFIX(dictionary_wrong): return "Dictionary mismatch"; diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 655adf34b..d5adeb68e 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -7254,7 +7254,7 @@ ZSTD_compressSequencesAndLiterals_internal(ZSTD_CCtx* cctx, * but it's complex, and memory hungry, killing the purpose of this variant. * Current outcome: generate an error code. */ - RETURN_ERROR(dstSize_tooSmall, "Data is not compressible"); /* note: error code could be clearer */ + RETURN_ERROR(cannotProduce_uncompressedBlock, "ZSTD_compressSequencesAndLiterals cannot generate an uncompressed block"); } else { U32 cBlockHeader; assert(compressedSeqsSize > 1); /* no RLE */ diff --git a/lib/zstd_errors.h b/lib/zstd_errors.h index 20e488f15..8ebc95cbb 100644 --- a/lib/zstd_errors.h +++ b/lib/zstd_errors.h @@ -76,6 +76,7 @@ typedef enum { ZSTD_error_tableLog_tooLarge = 44, ZSTD_error_maxSymbolValue_tooLarge = 46, ZSTD_error_maxSymbolValue_tooSmall = 48, + ZSTD_error_cannotProduce_uncompressedBlock = 49, ZSTD_error_stabilityCondition_notRespected = 50, ZSTD_error_stage_wrong = 60, ZSTD_error_init_missing = 62,