diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2019-04-13 21:15:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-13 21:15:48 (GMT) |
commit | cffde7eeb98304c490c4d235672452324e71fbc1 (patch) | |
tree | 98b8914e2f1b20faaf5bb096e5be04e94771bed4 /lib | |
parent | 31763c59fca9a38bc697cd37f591d6ba385f7614 (diff) | |
parent | 63bfb64b80a6b9b310961c04cadd5242c81df0c8 (diff) | |
download | lz4-cffde7eeb98304c490c4d235672452324e71fbc1.zip lz4-cffde7eeb98304c490c4d235672452324e71fbc1.tar.gz lz4-cffde7eeb98304c490c4d235672452324e71fbc1.tar.bz2 |
Merge pull request #668 from lz4/visual
Fix some Visual conversion warnings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4.c | 4 | ||||
-rw-r--r-- | lib/lz4frame.c | 24 | ||||
-rw-r--r-- | lib/lz4hc.c | 4 |
3 files changed, 16 insertions, 16 deletions
@@ -983,7 +983,7 @@ _next_match: assert(dictEnd > match); if (limit > matchlimit) limit = matchlimit; matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit); - ip += MINMATCH + matchCode; + ip += (size_t)matchCode + MINMATCH; if (ip==limit) { unsigned const more = LZ4_count(limit, (const BYTE*)source, matchlimit); matchCode += more; @@ -992,7 +992,7 @@ _next_match: DEBUGLOG(6, " with matchLength=%u starting in extDict", matchCode+MINMATCH); } else { matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit); - ip += MINMATCH + matchCode; + ip += (size_t)matchCode + MINMATCH; DEBUGLOG(6, " with matchLength=%u", matchCode+MINMATCH); } diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 2b31a0d..b6bc218 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -194,10 +194,10 @@ static void LZ4F_writeLE64 (void* dst, U64 value64) /*-************************************ * Constants **************************************/ -#ifndef LZ4_SRC_INCLUDED -#define KB *(1<<10) -#define MB *(1<<20) -#define GB *(1<<30) +#ifndef LZ4_SRC_INCLUDED /* avoid double definition */ +# define KB *(1<<10) +# define MB *(1<<20) +# define GB *(1<<30) #endif #define _1BIT 0x01 @@ -644,8 +644,8 @@ size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctxPtr, cctxPtr->maxBlockSize = LZ4F_getBlockSize(cctxPtr->prefs.frameInfo.blockSizeID); { size_t const requiredBuffSize = preferencesPtr->autoFlush ? - (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 64 KB : /* only needs windows size */ - cctxPtr->maxBlockSize + ((cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 128 KB); + ((cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 64 KB : 0) : /* only needs past data up to window size */ + cctxPtr->maxBlockSize + ((cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 128 KB : 0); if (cctxPtr->maxBufferSize < requiredBuffSize) { cctxPtr->maxBufferSize = 0; @@ -1146,7 +1146,7 @@ static size_t LZ4F_decodeHeader(LZ4F_dctx* dctx, const void* src, size_t srcSize } /* Frame Header Size */ - frameHeaderSize = minFHSize + (contentSizeFlag*8) + (dictIDFlag*4); + frameHeaderSize = minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0); if (srcSize < frameHeaderSize) { /* not enough input to fully decode frame header */ @@ -1215,7 +1215,7 @@ size_t LZ4F_headerSize(const void* src, size_t srcSize) { BYTE const FLG = ((const BYTE*)src)[4]; U32 const contentSizeFlag = (FLG>>3) & _1BIT; U32 const dictIDFlag = FLG & _1BIT; - return minFHSize + (contentSizeFlag*8) + (dictIDFlag*4); + return minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0); } } @@ -1421,11 +1421,11 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx, if (dctx->frameInfo.contentChecksumFlag) (void)XXH32_reset(&(dctx->xxh), 0); /* internal buffers allocation */ { size_t const bufferNeeded = dctx->maxBlockSize - + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); + + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) ? 128 KB : 0); if (bufferNeeded > dctx->maxBufferSize) { /* tmp buffers too small */ dctx->maxBufferSize = 0; /* ensure allocation will be re-attempted on next entry*/ FREEMEM(dctx->tmpIn); - dctx->tmpIn = (BYTE*)ALLOC(dctx->maxBlockSize + 4 /* block checksum */); + dctx->tmpIn = (BYTE*)ALLOC(dctx->maxBlockSize + BFSize /* block checksum */); if (dctx->tmpIn == NULL) return err0r(LZ4F_ERROR_allocation_failed); FREEMEM(dctx->tmpOutBuffer); @@ -1526,7 +1526,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx, } dctx->tmpInTarget -= sizeToCopy; /* need to copy more */ nextSrcSizeHint = dctx->tmpInTarget + - + dctx->frameInfo.blockChecksumFlag * 4 /* size for block checksum */ + +(dctx->frameInfo.blockChecksumFlag ? BFSize : 0) + BHSize /* next header size */; doAnotherStage = 0; break; @@ -1578,7 +1578,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx, srcPtr += sizeToCopy; if (dctx->tmpInSize < dctx->tmpInTarget) { /* need more input */ nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) - + dctx->frameInfo.blockChecksumFlag * 4 /* size for block checksum */ + + (dctx->frameInfo.blockChecksumFlag ? BFSize : 0) + BHSize /* next header size */; doAnotherStage = 0; break; diff --git a/lib/lz4hc.c b/lib/lz4hc.c index a6dc7a2..4e3573a 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -458,7 +458,7 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence ( /* Encode MatchLength */ assert(matchLength >= MINMATCH); - length = (size_t)(matchLength - MINMATCH); + length = (size_t)matchLength - MINMATCH; if ((limit) && (*op + (length / 255) + (1 + LASTLITERALS) > oend)) return 1; /* Check output limit */ if (length >= ML_MASK) { *token += ML_MASK; @@ -979,7 +979,7 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, DEBUGLOG(4, "LZ4_loadDictHC(%p, %p, %d)", LZ4_streamHCPtr, dictionary, dictSize); assert(LZ4_streamHCPtr != NULL); if (dictSize > 64 KB) { - dictionary += dictSize - 64 KB; + dictionary += (size_t)dictSize - 64 KB; dictSize = 64 KB; } /* need a full initialization, there are bad side-effects when using resetFast() */ |