From c2bc4467f774f430a6d536d9c0e70687dbd2301c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 17 Aug 2020 10:26:01 +0200 Subject: [PATCH] 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 --- src/network/access/qdecompresshelper.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/network/access/qdecompresshelper.cpp b/src/network/access/qdecompresshelper.cpp index 25e87bbc43..66ac70fec5 100644 --- a/src/network/access/qdecompresshelper.cpp +++ b/src/network/access/qdecompresshelper.cpp @@ -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