From 147ef05f12b1b1f81039e548533e8723ec37eabe Mon Sep 17 00:00:00 2001 From: Paul Cruz Date: Mon, 19 Jun 2017 16:38:51 -0700 Subject: [PATCH] for loop declaration not allowed --- tests/decodecorpus.c | 85 +++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/tests/decodecorpus.c b/tests/decodecorpus.c index 4c6e4b27..42360d2c 100644 --- a/tests/decodecorpus.c +++ b/tests/decodecorpus.c @@ -1442,59 +1442,62 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const outputBuffer(fullDict, dictSize, outPath); /* generate random compressed/decompressed files */ - for (unsigned fnum = 0; fnum < numFiles; fnum++) { - frame_t fr; - DISPLAYUPDATE("\r%u/%u ", fnum, numFiles); - { - size_t dictContentSize = dictSize-dictSize/4; - BYTE* const dictContent = fullDict+dictSize/4; - dictInfo const info = initDictInfo(1, dictContentSize, dictContent, dictID); - seed = generateFrame(seed, &fr, info); - } - if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) { - DISPLAY("Error: path too long\n"); - errorDetected = 1; - goto dictCleanup; - } - outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath); - - if (origPath) { - if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) { + { + unsigned fnum; + for (fnum = 0; fnum < numFiles; fnum++) { + frame_t fr; + DISPLAYUPDATE("\r%u/%u ", fnum, numFiles); + { + size_t dictContentSize = dictSize-dictSize/4; + BYTE* const dictContent = fullDict+dictSize/4; + dictInfo const info = initDictInfo(1, dictContentSize, dictContent, dictID); + seed = generateFrame(seed, &fr, info); + } + if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) { DISPLAY("Error: path too long\n"); errorDetected = 1; goto dictCleanup; } - outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath); - } + outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath); - /* check the output to make sure that decompressed versions match official zstd */ - { - ZSTD_DCtx* const dctx = ZSTD_createDCtx(); - BYTE* const decompressedPtr = malloc(MAX_DECOMPRESSED_SIZE); - if (decompressedPtr == NULL) { - DISPLAY("Error: could not allocate memory for decompressed pointer\n"); - errorDetected = 1; - goto dictCleanup; - } - { - size_t const returnValue = ZSTD_decompress_usingDict(dctx, decompressedPtr, MAX_DECOMPRESSED_SIZE, - fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, - fullDict, dictSize); - if (ZSTD_isError(returnValue)) { - DISPLAY("Error: %s\n", ZSTD_getErrorName(returnValue)); + if (origPath) { + if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) { + DISPLAY("Error: path too long\n"); + errorDetected = 1; + goto dictCleanup; } + outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath); } - /* print differences if any */ + /* check the output to make sure that decompressed versions match official zstd */ { - size_t checkDiff = (BYTE*)fr.src - (BYTE*)fr.srcStart; - for (size_t i = 0; i < checkDiff; i++) { - if (*((BYTE*)(fr.srcStart + i)) != *((BYTE*)(decompressedPtr + i))) { - DISPLAY("i: %zu, fr: %u, decomp: %u\n", i, *((BYTE*)(fr.srcStart + i)), *((BYTE*)(decompressedPtr + i))); + ZSTD_DCtx* const dctx = ZSTD_createDCtx(); + BYTE* const decompressedPtr = malloc(MAX_DECOMPRESSED_SIZE); + if (decompressedPtr == NULL) { + DISPLAY("Error: could not allocate memory for decompressed pointer\n"); + errorDetected = 1; + goto dictCleanup; + } + { + size_t const returnValue = ZSTD_decompress_usingDict(dctx, decompressedPtr, MAX_DECOMPRESSED_SIZE, + fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, + fullDict, dictSize); + if (ZSTD_isError(returnValue)) { + DISPLAY("Error: %s\n", ZSTD_getErrorName(returnValue)); } } + + /* print differences if any */ + { + size_t checkDiff = (BYTE*)fr.src - (BYTE*)fr.srcStart; + for (size_t i = 0; i < checkDiff; i++) { + if (*((BYTE*)(fr.srcStart + i)) != *((BYTE*)(decompressedPtr + i))) { + DISPLAY("i: %zu, fr: %u, decomp: %u\n", i, *((BYTE*)(fr.srcStart + i)), *((BYTE*)(decompressedPtr + i))); + } + } + } + free(decompressedPtr); } - free(decompressedPtr); } }