fixed minor Visual conversion warnings
authorYann Collet <cyan@fb.com>
Sat, 13 Apr 2019 00:03:28 +0000 (17:03 -0700)
committerYann Collet <cyan@fb.com>
Sat, 13 Apr 2019 00:03:28 +0000 (17:03 -0700)
programs/util.h
tests/fullbench.c

index 4aba6a3..1385620 100644 (file)
@@ -391,11 +391,11 @@ UTIL_STATIC void* UTIL_realloc(void* ptr, size_t size)
 UTIL_STATIC int UTIL_prepareFileList(const char* dirName, char** bufStart, size_t* pos, char** bufEnd)
 {
     char* path;
-    int dirLength, nbFiles = 0;
+    size_t dirLength, nbFiles = 0;
     WIN32_FIND_DATAA cFile;
     HANDLE hFile;
 
-    dirLength = (int)strlen(dirName);
+    dirLength = strlen(dirName);
     path = (char*) malloc(dirLength + 3);
     if (!path) return 0;
 
@@ -412,7 +412,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char* dirName, char** bufStart, size_
     free(path);
 
     do {
-        int pathLength;
+        size_t pathLength;
         int const fnameLength = (int)strlen(cFile.cFileName);
         path = (char*) malloc(dirLength + fnameLength + 2);
         if (!path) { FindClose(hFile); return 0; }
@@ -553,15 +553,15 @@ UTIL_createFileList(const char** inputNames, unsigned inputNamesNb, char** alloc
             }
         } else {
             char* bufend = buf + bufSize;
-            nbFiles += UTIL_prepareFileList(inputNames[i], &buf, &pos, &bufend);
+            nbFiles += (unsigned)UTIL_prepareFileList(inputNames[i], &buf, &pos, &bufend);
             if (buf == NULL) return NULL;
             assert(bufend > buf);
-            bufSize = bufend - buf;
+            bufSize = (size_t)(bufend - buf);
     }   }
 
     if (nbFiles == 0) { free(buf); return NULL; }
 
-    fileTable = (const char**)malloc((nbFiles+1) * sizeof(const char*));
+    fileTable = (const char**)malloc(((size_t)nbFiles+1) * sizeof(const char*));
     if (!fileTable) { free(buf); return NULL; }
 
     for (i=0, pos=0; i<nbFiles; i++) {
index 456c916..1a52aab 100644 (file)
@@ -389,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);