fixed minor cppcheck warnings in lib

This commit is contained in:
Yann Collet 2018-09-18 15:51:26 -07:00
parent c3397520a1
commit 8bea19d57c
3 changed files with 213 additions and 212 deletions

View File

@ -1414,14 +1414,16 @@ LZ4_decompress_generic(
const size_t dictSize /* note : = 0 if noDict */
)
{
const BYTE* ip = (const BYTE*) src;
if (src == NULL) return -1;
{ const BYTE* ip = (const BYTE*) src;
const BYTE* const iend = ip + srcSize;
BYTE* op = (BYTE*) dst;
BYTE* const oend = op + outputSize;
BYTE* cpy;
const BYTE* const dictEnd = (const BYTE*)dictStart + dictSize;
const BYTE* const dictEnd = (dictStart == NULL) ? NULL : dictStart + dictSize;
const unsigned inc32table[8] = {0, 1, 2, 1, 0, 4, 4, 4};
const int dec64table[8] = {0, 0, 0, -1, -4, 1, 2, 3};
@ -1436,7 +1438,6 @@ LZ4_decompress_generic(
/* Special cases */
assert(lowPrefix <= op);
assert(src != NULL);
if ((endOnInput) && (unlikely(outputSize==0))) return ((srcSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */
if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0 ? 1 : -1);
if ((endOnInput) && unlikely(srcSize==0)) return -1;
@ -1643,6 +1644,7 @@ _copy_match:
_output_error:
return (int) (-(((const char*)ip)-src))-1;
}
}
/*===== Instantiate the API decoding functions. =====*/

View File

@ -635,7 +635,7 @@ size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctxPtr,
} }
cctxPtr->tmpIn = cctxPtr->tmpBuff;
cctxPtr->tmpInSize = 0;
XXH32_reset(&(cctxPtr->xxh), 0);
(void)XXH32_reset(&(cctxPtr->xxh), 0);
/* context init */
cctxPtr->cdict = cdict;
@ -887,7 +887,7 @@ size_t LZ4F_compressUpdate(LZ4F_cctx* cctxPtr,
}
if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
(void)XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
cctxPtr->totalInSize += srcSize;
return dstPtr - dstStart;
@ -1366,7 +1366,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
break;
case dstage_init:
if (dctx->frameInfo.contentChecksumFlag) XXH32_reset(&(dctx->xxh), 0);
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);
@ -1431,7 +1431,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
/* next block is uncompressed */
dctx->tmpInTarget = nextCBlockSize;
if (dctx->frameInfo.blockChecksumFlag) {
XXH32_reset(&dctx->blockChecksum, 0);
(void)XXH32_reset(&dctx->blockChecksum, 0);
}
dctx->dStage = dstage_copyDirect;
break;
@ -1451,10 +1451,10 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
size_t const sizeToCopy = MIN(dctx->tmpInTarget, minBuffSize);
memcpy(dstPtr, srcPtr, sizeToCopy);
if (dctx->frameInfo.blockChecksumFlag) {
XXH32_update(&dctx->blockChecksum, srcPtr, sizeToCopy);
(void)XXH32_update(&dctx->blockChecksum, srcPtr, sizeToCopy);
}
if (dctx->frameInfo.contentChecksumFlag)
XXH32_update(&dctx->xxh, srcPtr, sizeToCopy);
(void)XXH32_update(&dctx->xxh, srcPtr, sizeToCopy);
if (dctx->frameInfo.contentSize)
dctx->frameRemainingSize -= sizeToCopy;

View File

@ -231,7 +231,6 @@ LZ4HC_InsertAndGetWiderMatch (
int matchChainPos = 0;
U32 const pattern = LZ4_read32(ip);
U32 matchIndex;
U32 dictMatchIndex;
repeat_state_e repeat = rep_untested;
size_t srcPatternLength = 0;
@ -349,8 +348,8 @@ LZ4HC_InsertAndGetWiderMatch (
if (dict == usingDictCtx && nbAttempts && ipIndex - lowestMatchIndex < MAX_DISTANCE) {
size_t const dictEndOffset = dictCtx->end - dictCtx->base;
U32 dictMatchIndex = dictCtx->hashTable[LZ4HC_hashPtr(ip)];
assert(dictEndOffset <= 1 GB);
dictMatchIndex = dictCtx->hashTable[LZ4HC_hashPtr(ip)];
matchIndex = dictMatchIndex + lowestMatchIndex - (U32)dictEndOffset;
while (ipIndex - matchIndex <= MAX_DISTANCE && nbAttempts--) {
const BYTE* const matchPtr = dictCtx->base + dictMatchIndex;