From: W. Felix Handte Date: Wed, 9 May 2018 17:14:20 +0000 (-0400) Subject: Respond to PR Comments; Formatting/Style/Lint Fixes X-Git-Tag: v1.3.5~3^2~44^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae4fcf781613255b76dbf3da55f452bbc5537065;p=thirdparty%2Fzstd.git Respond to PR Comments; Formatting/Style/Lint Fixes --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index b877a7fb2..f0576f081 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -2152,11 +2152,14 @@ ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMo ZSTD_compressBlock_fast_dictMatchState, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* unimplemented as of yet */ } }; + ZSTD_blockCompressor selectedCompressor; ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1); assert((U32)strat >= (U32)ZSTD_fast); assert((U32)strat <= (U32)ZSTD_btultra); - return blockCompressor[(int)dictMode][(U32)strat]; + selectedCompressor = blockCompressor[(int)dictMode][(U32)strat]; + assert(selectedCompressor != NULL); + return selectedCompressor; } static void ZSTD_storeLastLiterals(seqStore_t* seqStorePtr, diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 32bbe08b8..913497e7f 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -515,12 +515,16 @@ MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window) /** * ZSTD_matchState_dictMode(): - * Does what the label says. + * Inspects the provided matchState and figures out what dictMode should be + * passed to the compressor. */ MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms) { - return ms->dictMatchState != NULL ? ZSTD_dictMatchState : - ZSTD_window_hasExtDict(ms->window) ? ZSTD_extDict : ZSTD_noDict; + return ms->dictMatchState != NULL ? + ZSTD_dictMatchState : + ZSTD_window_hasExtDict(ms->window) ? + ZSTD_extDict : + ZSTD_noDict; } /** diff --git a/lib/compress/zstd_fast.c b/lib/compress/zstd_fast.c index d4eaeb6d4..60c88e571 100644 --- a/lib/compress/zstd_fast.c +++ b/lib/compress/zstd_fast.c @@ -72,7 +72,7 @@ size_t ZSTD_compressBlock_fast_generic( const BYTE* const dictEnd = hasDict == ZSTD_dictMatchState ? dms->window.nextSrc : NULL; const U32 dictIndexDelta = hasDict == ZSTD_dictMatchState ? - localLowestIndex - (dictEnd - dictBase) : + localLowestIndex - (U32)(dictEnd - dictBase) : 0; ptrdiff_t dictLowestLocalIndex = hasDict == ZSTD_dictMatchState ? lowestDictIndex + dictIndexDelta :