aboutsummaryrefslogtreecommitdiff
path: root/lib/lz4frame.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-01-13 22:39:39 -0800
committerYann Collet <cyan@fb.com>2018-01-13 22:39:39 -0800
commit4d61ebc9c8738fc79301d8ef7e27920d4b300913 (patch)
tree5d25289da91205dc0d42a8a1b1823ff1200a17a3 /lib/lz4frame.c
parent8e69328d6198783cde1d9fa8c18b7cdb900bbae3 (diff)
downloadlz4-4d61ebc9c8738fc79301d8ef7e27920d4b300913.tar.gz
modified formulation for LZ4F_compressBound()
previous version used an intentional overflow, which is defined since it uses unsigned type, but static analyzer complain about it.
Diffstat (limited to 'lib/lz4frame.c')
-rw-r--r--lib/lz4frame.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 488ab75e..62e7010c 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -281,7 +281,7 @@ static size_t LZ4F_compressBound_internal(size_t srcSize,
size_t const bufferedSize = MIN(alreadyBuffered, maxBuffered);
size_t const maxSrcSize = srcSize + bufferedSize;
unsigned const nbFullBlocks = (unsigned)(maxSrcSize / blockSize);
- size_t const partialBlockSize = (srcSize - (srcSize==0)) & (blockSize-1); /* 0 => -1 == MAX => blockSize-1 */
+ size_t const partialBlockSize = maxSrcSize & (blockSize-1);
size_t const lastBlockSize = flush ? partialBlockSize : 0;
unsigned const nbBlocks = nbFullBlocks + (lastBlockSize>0);
@@ -604,10 +604,10 @@ size_t LZ4F_compressBegin(LZ4F_cctx* cctxPtr,
}
-/* LZ4F_compressBound() :
- * @ return size of Dst buffer given a srcSize to handle worst case situations.
- * The LZ4F_frameInfo_t structure is optional : if NULL, preferences will be set to cover worst case situations.
- * This function cannot fail.
+/* LZ4F_compressBound() :
+ * @return minimum capacity of dstBuffer for a given srcSize to handle worst case scenario.
+ * LZ4F_preferences_t structure is optional : if NULL, preferences will be set to cover worst case scenario.
+ * This function cannot fail.
*/
size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr)
{