]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor comments & refactoring
authorYann Collet <cyan@fb.com>
Tue, 15 Oct 2019 23:09:18 +0000 (16:09 -0700)
committerYann Collet <cyan@fb.com>
Tue, 15 Oct 2019 23:09:18 +0000 (16:09 -0700)
programs/benchzstd.c
programs/benchzstd.h

index 263dc08887f7c812bdcbf34722b860e2031c5154..7439677c7f3ecb375495d09793b16ac645a4da15 100644 (file)
@@ -88,7 +88,7 @@ static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
 #endif
 #define DEBUGOUTPUT(...) { if (DEBUG) DISPLAY(__VA_ARGS__); }
 
-#define EXM_THROW_INT(errorNum, ...)  {               \
+#define RETURN_ERROR_INT(errorNum, ...)  {               \
     DEBUGOUTPUT("%s: %i: \n", __FILE__, __LINE__);    \
     DISPLAYLEVEL(1, "Error %i : ", errorNum);         \
     DISPLAYLEVEL(1, __VA_ARGS__);                     \
@@ -401,9 +401,9 @@ BMK_benchMemAdvancedNoAlloc(
         BMK_initCCtxArgs cctxprep;
         BMK_initDCtxArgs dctxprep;
 
-        cbp.benchFn = local_defaultCompress;
+        cbp.benchFn = local_defaultCompress;   /* ZSTD_compress2 */
         cbp.benchPayload = cctx;
-        cbp.initFn = local_initCCtx;
+        cbp.initFn = local_initCCtx;   /* BMK_initCCtx */
         cbp.initPayload = &cctxprep;
         cbp.errorFn = ZSTD_isError;
         cbp.blockCount = nbBlocks;
@@ -534,8 +534,8 @@ BMK_benchMemAdvancedNoAlloc(
                     if (u==srcSize-1) {  /* should never happen */
                         DISPLAY("no difference detected\n");
                     }
-                }
-            }
+                }   /* for (u=0; u<srcSize; u++) */
+            }   /* if ((adv->mode == BMK_both) && (crcOrig!=crcCheck)) */
         }   /* CRC Checking */
 
         if (displayLevel == 1) {   /* hidden display mode -q, used by python speed benchmark */
@@ -754,8 +754,7 @@ static int BMK_loadFiles(void* buffer, size_t bufferSize,
     size_t pos = 0, totalSize = 0;
     unsigned n;
     for (n=0; n<nbFiles; n++) {
-        FILE* f;
-        U64 fileSize = UTIL_getFileSize(fileNamesTable[n]);
+        U64 fileSize = UTIL_getFileSize(fileNamesTable[n]);  /* last file may be shortened */
         if (UTIL_isDirectory(fileNamesTable[n])) {
             DISPLAYLEVEL(2, "Ignoring %s directory...       \n", fileNamesTable[n]);
             fileSizes[n] = 0;
@@ -766,20 +765,20 @@ static int BMK_loadFiles(void* buffer, size_t bufferSize,
             fileSizes[n] = 0;
             continue;
         }
-        f = fopen(fileNamesTable[n], "rb");
-        if (f==NULL) EXM_THROW_INT(10, "impossible to open file %s", fileNamesTable[n]);
-        DISPLAYUPDATE(2, "Loading %s...       \r", fileNamesTable[n]);
-        if (fileSize > bufferSize-pos) fileSize = bufferSize-pos, nbFiles=n;   /* buffer too small - stop after this file */
-        {   size_t const readSize = fread(((char*)buffer)+pos, 1, (size_t)fileSize, f);
-            if (readSize != (size_t)fileSize) EXM_THROW_INT(11, "could not read %s", fileNamesTable[n]);
-            pos += readSize;
-        }
-        fileSizes[n] = (size_t)fileSize;
-        totalSize += (size_t)fileSize;
-        fclose(f);
-    }
+        {   FILE* const f = fopen(fileNamesTable[n], "rb");
+            if (f==NULL) RETURN_ERROR_INT(10, "impossible to open file %s", fileNamesTable[n]);
+            DISPLAYUPDATE(2, "Loading %s...       \r", fileNamesTable[n]);
+            if (fileSize > bufferSize-pos) fileSize = bufferSize-pos, nbFiles=n;   /* buffer too small - stop after this file */
+            {   size_t const readSize = fread(((char*)buffer)+pos, 1, (size_t)fileSize, f);
+                if (readSize != (size_t)fileSize) RETURN_ERROR_INT(11, "could not read %s", fileNamesTable[n]);
+                pos += readSize;
+            }
+            fileSizes[n] = (size_t)fileSize;
+            totalSize += (size_t)fileSize;
+            fclose(f);
+    }   }
 
-    if (totalSize == 0) EXM_THROW_INT(12, "no data to bench");
+    if (totalSize == 0) RETURN_ERROR_INT(12, "no data to bench");
     return 0;
 }
 
index 2c7627713ee49ebb8a419d3723ab86ceb3affe50..ef7d9fb11145b2cd23670ac2c180c605bbcc0abf 100644 (file)
@@ -205,7 +205,6 @@ BMK_benchOutcome_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize,
 
 
 
-
 #endif   /* BENCH_ZSTD_H_3242387 */
 
 #if defined (__cplusplus)