summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-04-12 08:42:58 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-04-12 08:42:58 (GMT)
commit8a610004f6ac5bf5966b8a16da5a240d289b538b (patch)
treea8d6a8db3c1734375092794f3dd35c637b89c638
parent138673df5e1f42d098a55d23fe84228726e9739d (diff)
downloadlz4-8a610004f6ac5bf5966b8a16da5a240d289b538b.zip
lz4-8a610004f6ac5bf5966b8a16da5a240d289b538b.tar.gz
lz4-8a610004f6ac5bf5966b8a16da5a240d289b538b.tar.bz2
Fixed a few coverity warnings
-rw-r--r--programs/bench.c3
-rw-r--r--programs/fullbench.c1
2 files changed, 3 insertions, 1 deletions
diff --git a/programs/bench.c b/programs/bench.c
index 8921f09..d3b060c 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -287,7 +287,7 @@ int BMK_benchFiles(const char** fileNamesTable, int nbFiles, int cLevel)
inFileSize = BMK_GetFileSize(inFileName);
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); return 11; }
benchedSize = (size_t) BMK_findMaxMem(inFileSize * 2) / 2;
- if (benchedSize==0) { DISPLAY( "not enough memory\n"); return 11; }
+ if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); return 11; }
if ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
if (benchedSize < inFileSize)
{
@@ -376,6 +376,7 @@ int BMK_benchFiles(const char** fileNamesTable, int nbFiles, int cLevel)
}
milliTime = BMK_GetMilliSpan(milliTime);
+ nbLoops += !nbLoops; /* avoid division by zero */
if ((double)milliTime < fastestC*nbLoops) fastestC = (double)milliTime/nbLoops;
cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += chunkP[chunkNb].compressedSize;
ratio = (double)cSize/(double)benchedSize*100.;
diff --git a/programs/fullbench.c b/programs/fullbench.c
index 51e0e9a..40d95e5 100644
--- a/programs/fullbench.c
+++ b/programs/fullbench.c
@@ -693,6 +693,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
}
milliTime = BMK_GetMilliSpan(milliTime);
+ nb_loops += !nb_loops; /* avoid division by zero */
averageTime = (double)milliTime / nb_loops;
if (averageTime < bestTime) bestTime = averageTime;
cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += chunkP[chunkNb].compressedSize;