]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix more merge conflicts
authorSen Huang <senhuang96@fb.com>
Tue, 5 Nov 2019 20:54:05 +0000 (15:54 -0500)
committerSen Huang <senhuang96@fb.com>
Tue, 5 Nov 2019 20:54:05 +0000 (15:54 -0500)
lib/compress/zstd_compress_superblock.c
tests/fuzz/dictionary_round_trip.c
tests/fuzz/simple_round_trip.c
tests/fuzz/zstd_helpers.c

index cb6b6c26b517f880331b1bfcd426b92178c8ca20..3dfb16dee3b58dda15708218ec833b732a9cca5c 100644 (file)
@@ -651,12 +651,15 @@ static size_t ZSTD_compressSubBlock_multi(const seqStore_t* seqStorePtr,
     litSize = 0;
     seqCount = 0;
     while (sp + seqCount < send) {
-        // TODO this is crude estimate for now...
-        // Ask Yann, Nick for feedback.
         const seqDef* const sequence = sp + seqCount;
         const U32 lastSequence = sequence+1 == send;
         litSize = (sequence == send) ? (size_t)(lend-lp) : litSize + sequence->litLength;
         seqCount++;
+        /* I think there is an optimization opportunity here.
+         * Calling ZSTD_estimateSubBlockSize for every sequence can be wasteful
+         * since it recalculates estimate from scratch.
+         * For example, it would recount literal distribution and symbol codes everytime. 
+         */
         cBlockSizeEstimate = ZSTD_estimateSubBlockSize(lp, litSize, ofCodePtr, llCodePtr, mlCodePtr, seqCount,
                                                        entropy, entropyMetadata,
                                                        workspace, wkspSize, writeEntropy);
index 9411b50a74ebeb6134f84aa5b2b1fcc4442e72e9..4a32b82be7808bb3bb12ea86a0358b7e7a11f10c 100644 (file)
@@ -73,7 +73,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
 
     size_t const rBufSize = size;
     void* rBuf = malloc(rBufSize);
-    size_t cBufSize = ZSTD_compressBound(size);
+    size_t cBufSize = ZSTD_compressBound(size) * 2;
     void *cBuf;
     /* Half of the time fuzz with a 1 byte smaller output size.
      * This will still succeed because we force the checksum to be disabled,
index 2d1d0598a14bf7bbd4bb7bba1da39bba0fd7aaa3..6a65b19087ef9b27e24580d2c447c765c97aad67 100644 (file)
@@ -48,7 +48,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
 {
     size_t const rBufSize = size;
     void* rBuf = malloc(rBufSize);
-    size_t cBufSize = ZSTD_compressBound(size);
+    size_t cBufSize = ZSTD_compressBound(size) * 2;
     void* cBuf;
 
     /* Give a random portion of src data to the producer, to use for
index 90bf1a1567873db150b31c692c26dd30dd377e8e..41de2202096a6d243459a696e48edc5297b92ec1 100644 (file)
@@ -96,6 +96,9 @@ void FUZZ_setRandomParameters(ZSTD_CCtx *cctx, size_t srcSize, FUZZ_dataProducer
     if (FUZZ_dataProducer_uint32Range(producer, 0, 1) == 0) {
       setRand(cctx, ZSTD_c_srcSizeHint, ZSTD_SRCSIZEHINT_MIN, 2 * srcSize, producer);
     }
+    if (FUZZ_rand32(producer, 0, 1)) {
+        setRand(cctx, ZSTD_c_targetCBlockSize, ZSTD_TARGETCBLOCKSIZE_MIN, ZSTD_TARGETCBLOCKSIZE_MAX, producer);
+    }
 }
 
 FUZZ_dict_t FUZZ_train(void const* src, size_t srcSize, FUZZ_dataProducer_t *producer)