QDecompressHelper: Fix warnings in zstd code

One warning about unused variable (dataLeftover), which was at some
point replaced by the class variable 'decoderHasData'.

The second warning was a fault of logic: checking that the unsigned
value retValue was greater than or equal to zero. Which only came about
because they initially did different things but the branches got merged
and the logic became flawed.

Change-Id: Ia3a04516c1b7b5f962226998bf3f4d101dd38148
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Mårten Nordheim 2020-08-17 10:26:01 +02:00
parent 8c9482cd30
commit c2bc4467f7

View File

@ -652,16 +652,13 @@ qsizetype QDecompressHelper::readZstandard(char *data, const qsizetype maxSize)
ZSTD_outBuffer outBuf { data, size_t(maxSize), 0 };
bool dataLeftover = false;
qsizetype bytesDecoded = 0;
while (outBuf.pos < outBuf.size && (inBuf.pos < inBuf.size || decoderHasData)) {
dataLeftover = false;
size_t retValue = ZSTD_decompressStream(zstdStream, &outBuf, &inBuf);
if (ZSTD_isError(retValue)) {
qWarning("ZStandard error: %s", ZSTD_getErrorName(retValue));
return -1;
} else if (retValue >= 0) {
} else {
decoderHasData = false;
bytesDecoded = outBuf.pos;
// if pos == size then there may be data left over in internal buffers