summaryrefslogtreecommitdiffstats
path: root/tests/fullbench.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fullbench.c')
-rw-r--r--tests/fullbench.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/fullbench.c b/tests/fullbench.c
index fd1202d..1a52aab 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -42,6 +42,7 @@
#include <string.h> /* strcmp */
#include <time.h> /* clock_t, clock(), CLOCKS_PER_SEC */
+#define LZ4_DISABLE_DEPRECATE_WARNINGS /* LZ4_decompress_fast */
#include "lz4.h"
#include "lz4hc.h"
#include "lz4frame.h"
@@ -160,12 +161,14 @@ static size_t BMK_findMaxMem(U64 requiredMem)
static LZ4_stream_t LZ4_stream;
static void local_LZ4_resetDictT(void)
{
- LZ4_resetStream(&LZ4_stream);
+ void* const r = LZ4_initStream(&LZ4_stream, sizeof(LZ4_stream));
+ assert(r != NULL);
}
static void local_LZ4_createStream(void)
{
- LZ4_resetStream(&LZ4_stream);
+ void* const r = LZ4_initStream(&LZ4_stream, sizeof(LZ4_stream));
+ assert(r != NULL);
}
static int local_LZ4_saveDict(const char* in, char* out, int inSize)
@@ -242,7 +245,7 @@ static int local_LZ4_compress_forceDict(const char* in, char* out, int inSize)
LZ4_streamHC_t LZ4_streamHC;
static void local_LZ4_resetStreamHC(void)
{
- LZ4_resetStreamHC(&LZ4_streamHC, 0);
+ LZ4_initStreamHC(&LZ4_streamHC, sizeof(LZ4_streamHC));
}
static int local_LZ4_saveDictHC(const char* in, char* out, int inSize)
@@ -326,16 +329,19 @@ static int local_LZ4_decompress_safe_partial(const char* in, char* out, int inSi
/* frame functions */
static int local_LZ4F_compressFrame(const char* in, char* out, int inSize)
{
- return (int)LZ4F_compressFrame(out, LZ4F_compressFrameBound(inSize, NULL), in, inSize, NULL);
+ assert(inSize >= 0);
+ return (int)LZ4F_compressFrame(out, LZ4F_compressFrameBound((size_t)inSize, NULL), in, (size_t)inSize, NULL);
}
static LZ4F_decompressionContext_t g_dCtx;
static int local_LZ4F_decompress(const char* in, char* out, int inSize, int outSize)
{
- size_t srcSize = inSize;
- size_t dstSize = outSize;
+ size_t srcSize = (size_t)inSize;
+ size_t dstSize = (size_t)outSize;
size_t result;
+ assert(inSize >= 0);
+ assert(outSize >= 0);
result = LZ4F_decompress(g_dCtx, out, &dstSize, in, &srcSize, NULL);
if (result!=0) { DISPLAY("Error decompressing frame : unfinished frame\n"); exit(8); }
if (srcSize != (size_t)inSize) { DISPLAY("Error decompressing frame : read size incorrect\n"); exit(9); }
@@ -367,7 +373,6 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
size_t readSize;
int compressedBuffSize;
U32 crcOriginal;
- size_t errorCode;
/* Check file existence */
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
@@ -384,7 +389,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
/* Allocation */
chunkP = (struct chunkParameters*) malloc(((benchedSize / (size_t)g_chunkSize)+1) * sizeof(struct chunkParameters));
orig_buff = (char*) malloc(benchedSize);
- nbChunks = (int) ((benchedSize + (g_chunkSize-1)) / g_chunkSize);
+ nbChunks = (int) ((benchedSize + (size_t)g_chunkSize - 1) / (size_t)g_chunkSize);
maxCompressedChunkSize = LZ4_compressBound(g_chunkSize);
compressedBuffSize = nbChunks * maxCompressedChunkSize;
compressed_buff = (char*)malloc((size_t)compressedBuffSize);
@@ -439,7 +444,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
char* out = compressed_buff;
nbChunks = (int) (((int)benchedSize + (g_chunkSize-1))/ g_chunkSize);
for (i=0; i<nbChunks; i++) {
- chunkP[i].id = i;
+ chunkP[i].id = (U32)i;
chunkP[i].origBuffer = in; in += g_chunkSize;
if ((int)remaining > g_chunkSize) { chunkP[i].origSize = g_chunkSize; remaining -= g_chunkSize; } else { chunkP[i].origSize = (int)remaining; remaining = 0; }
chunkP[i].compressedBuffer = out; out += maxCompressedChunkSize;
@@ -561,7 +566,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break;
#endif
case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress";
- errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL);
+ { size_t const errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL);
if (LZ4F_isError(errorCode)) {
DISPLAY("Error while preparing compressed frame\n");
free(orig_buff);
@@ -573,6 +578,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
chunkP[0].compressedSize = (int)errorCode;
nbChunks = 1;
break;
+ }
default :
continue; /* skip if unknown ID */
}
@@ -610,7 +616,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
PROGRESS("%2i-%-34.34s :%10i -> %7.1f MB/s\r", loopNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000000);
/* CRC Checking */
- crcDecoded = XXH32(orig_buff, (int)benchedSize, 0);
+ crcDecoded = XXH32(orig_buff, benchedSize, 0);
if (checkResult && (crcOriginal!=crcDecoded)) {
DISPLAY("\n!!! WARNING !!! %14s : Invalid Checksum : %x != %x\n",
inFileName, (unsigned)crcOriginal, (unsigned)crcDecoded);