for loop declaration not allowed

This commit is contained in:
Paul Cruz 2017-06-19 16:38:51 -07:00
parent 791352ad0e
commit 147ef05f12

View File

@ -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);
}
}