From: yann.collet.73@gmail.com Date: Fri, 26 Oct 2012 12:35:31 +0000 (+0000) Subject: Corrected Issue 34 (restrict) X-Git-Tag: upstream/1.9.3~301 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7185dc04a6fa3b3cb59c9897c0865465daa14118;p=platform%2Fupstream%2Flz4.git Corrected Issue 34 (restrict) minor macro renaming (fuzzer.c) git-svn-id: https://lz4.googlecode.com/svn/trunk@80 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- diff --git a/fuzzer.c b/fuzzer.c index 2f75923..9fea8fd 100644 --- a/fuzzer.c +++ b/fuzzer.c @@ -97,11 +97,10 @@ int main() { unsigned long long bytes = 0; unsigned long long cbytes = 0; unsigned char buf[LEN]; -# undef max -# define max LZ4_compressBound(LEN) -# define avail ROUND_PAGE(max) - const int off_full = avail - max; - unsigned char cbuf[avail + PAGE_SIZE]; +# define FUZ_max LZ4_compressBound(LEN) +# define FUZ_avail ROUND_PAGE(FUZ_max) + const int off_full = FUZ_avail - FUZ_max; + unsigned char cbuf[FUZ_avail + PAGE_SIZE]; unsigned int seed, cur_seq, seeds[NUM_SEQ], timestamp=FUZ_GetMilliStart(); int i, j, k, ret, len; char userInput[30] = {0}; @@ -117,7 +116,7 @@ int main() { printf("Seed = %u\n", seed); for (i = 0; i < 2048; i++) - cbuf[avail + i] = cbuf[avail + 2048 + i] = FUZ_rand(&seed) >> 16; + cbuf[FUZ_avail + i] = cbuf[FUZ_avail + 2048 + i] = FUZ_rand(&seed) >> 16; for (i = 0; i < NB_ATTEMPTS; i++) { printf("\r%7i /%7i\r", i, NB_ATTEMPTS); @@ -137,24 +136,18 @@ int main() { } buf[j] = FUZ_rand(&cur_seq) >> 16; } - ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[off_full], LEN, max); + ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[off_full], LEN, FUZ_max); len = ret; // Test compression with output size being exactly what's necessary - ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[avail-len], LEN, len); - if (!test_canary(&cbuf[avail])) { printf("compression overran output buffer: seed %u, len %d, olen %d\n", seed, LEN, len); return 1; } + ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[FUZ_avail-len], LEN, len); + if (!test_canary(&cbuf[FUZ_avail])) { printf("compression overran output buffer: seed %u, len %d, olen %d\n", seed, LEN, len); return 1; } if (ret == 0) { printf("compression failed despite sufficient space: seed %u, len %d\n", seed, LEN); return 1; } - // Test compression with just one missing byte into output buffer => should fail - ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[avail-(len-1)], LEN, len-1); + // Test compression with just one missing byte into output buffer => must fail + ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[FUZ_avail-(len-1)], LEN, len-1); if (ret) { printf("compression overran output buffer: seed %u, len %d, olen %d => ret %d", seed, LEN, len-1, ret); return 1; } - if (!test_canary(&cbuf[avail])) { printf("compression overran output buffer: seed %u, len %d, olen %d", seed, LEN, len-1); return 1; } - - /* No longer useful - // Test compression with not enough output size - ret = LZ4_compress_limitedOutput((const char*)buf, (char*)&cbuf[avail-len/2], LEN, len/2); - if (!test_canary(&cbuf[avail])) { printf("compression overran output buffer: seed %u, len %d, olen %d", seed, LEN, len/2); return 1; } - */ + if (!test_canary(&cbuf[FUZ_avail])) { printf("compression overran output buffer: seed %u, len %d, olen %d", seed, LEN, len-1); return 1; } bytes += LEN; cbytes += len; diff --git a/lz4.c b/lz4.c index 17c4a04..18c4604 100644 --- a/lz4.c +++ b/lz4.c @@ -696,9 +696,9 @@ int LZ4_uncompress(const char* source, { // Local Variables const BYTE* restrict ip = (const BYTE*) source; - const BYTE* restrict ref; + const BYTE* ref; - BYTE* restrict op = (BYTE*) dest; + BYTE* op = (BYTE*) dest; BYTE* const oend = op + osize; BYTE* cpy; @@ -782,9 +782,9 @@ int LZ4_uncompress_unknownOutputSize( // Local Variables const BYTE* restrict ip = (const BYTE*) source; const BYTE* const iend = ip + isize; - const BYTE* restrict ref; + const BYTE* ref; - BYTE* restrict op = (BYTE*) dest; + BYTE* op = (BYTE*) dest; BYTE* const oend = op + maxOutputSize; BYTE* cpy;