Static analyze fix

This commit is contained in:
Sen Huang 2019-10-02 15:30:24 -04:00
parent b93f1b2a30
commit c763457e0a
3 changed files with 6 additions and 7 deletions

View File

@ -122,7 +122,7 @@ int UTIL_checkFilenameCollisions(char** dstFilenameTable, unsigned nbFiles) {
}
void UTIL_createDestinationDirTable(char** dstFilenameTable, const char** filenameTable,
const unsigned nbFiles, const char* outDirName, const int compressing)
const unsigned nbFiles, const char* outDirName)
{
unsigned u;
const char* c;
@ -147,11 +147,10 @@ void UTIL_createDestinationDirTable(char** dstFilenameTable, const char** filena
}
finalPathLen += strlen(filename);
dstFilenameTable[u] = compressing ?
(char*) malloc((finalPathLen+6) * sizeof(char)) /* 4 more bytes for .zst suffix */
: (char*) malloc((finalPathLen+2) * sizeof(char));
dstFilenameTable[u] = (char*) malloc((finalPathLen+2) * sizeof(char));
if (!dstFilenameTable[u]) {
UTIL_DISPLAYLEVEL(1, "Unable to allocate space for file destination str\n");
free(filename);
continue;
}

View File

@ -133,7 +133,7 @@ int UTIL_compareStr(const void *p1, const void *p2);
int UTIL_checkFilenameCollisions(char** dstFilenameTable, unsigned nbFiles);
/* Populates dstFilenameTable using outDirName concatenated with entries from filenameTable */
void UTIL_createDestinationDirTable(char** dstFilenameTable, const char** filenameTable, const unsigned nbFiles,
const char* outDirName, const int compressing);
const char* outDirName);
void UTIL_freeDestinationFilenameTable(char** dstDirTable, unsigned nbFiles);
U32 UTIL_isLink(const char* infilename);

View File

@ -1179,7 +1179,7 @@ int main(int argCount, const char* argv[])
if (UTIL_isDirectory(outDirName)) {
DISPLAY("Output of files will be in directory: %s\n", outDirName);
dstFilenameTable = (char**)malloc(filenameIdx * sizeof(char*));
UTIL_createDestinationDirTable(dstFilenameTable, filenameTable, filenameIdx, outDirName, 1);
UTIL_createDestinationDirTable(dstFilenameTable, filenameTable, filenameIdx, outDirName);
} else {
DISPLAY("%s is not a directory!\n", outDirName);
CLEAN_RETURN(1);
@ -1211,7 +1211,7 @@ int main(int argCount, const char* argv[])
if (UTIL_isDirectory(outDirName)) {
DISPLAY("Output of files will be in directory: %s\n", outDirName);
dstFilenameTable = (char**)malloc(filenameIdx * sizeof(char*));
UTIL_createDestinationDirTable(dstFilenameTable, filenameTable, filenameIdx, outDirName, 1);
UTIL_createDestinationDirTable(dstFilenameTable, filenameTable, filenameIdx, outDirName);
} else {
DISPLAY("%s is not a directory!\n", outDirName);
CLEAN_RETURN(1);