mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Fixed #153, reported by @thatsafunnyname
This commit is contained in:
@ -215,19 +215,19 @@ test-zbuff: zbufftest
|
|||||||
test-zbuff32: zbufftest32
|
test-zbuff32: zbufftest32
|
||||||
./zbufftest32 $(ZBUFFTEST)
|
./zbufftest32 $(ZBUFFTEST)
|
||||||
|
|
||||||
|
valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
|
||||||
valgrindTest: zstd datagen fuzzer fullbench zbufftest
|
valgrindTest: zstd datagen fuzzer fullbench zbufftest
|
||||||
@echo "\n ---- valgrind tests : memory analyzer ----"
|
@echo "\n ---- valgrind tests : memory analyzer ----"
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./datagen -g50M > $(VOID)
|
$(VALGRIND) ./datagen -g50M > $(VOID)
|
||||||
./datagen -g16KB > tmp
|
$(VALGRIND) ./zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp -o $(VOID)
|
./datagen -g80 | $(VALGRIND) ./zstd - -c > $(VOID)
|
||||||
./datagen -g2930KB > tmp
|
./datagen -g16KB | $(VALGRIND) ./zstd -vf - -o $(VOID)
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./zstd -5 -vf tmp -o tmp2
|
./datagen -g2930KB | $(VALGRIND) ./zstd -5 -vf - -o tmp
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vdf tmp2 -o $(VOID)
|
$(VALGRIND) ./zstd -vdf tmp -o $(VOID)
|
||||||
./datagen -g64MB > tmp
|
./datagen -g64MB | $(VALGRIND) ./zstd -vf - -o $(VOID)
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp -o $(VOID)
|
|
||||||
@rm tmp
|
@rm tmp
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -T1mn -t1
|
$(VALGRIND) ./fuzzer -T1mn -t1
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1
|
$(VALGRIND) ./fullbench -i1
|
||||||
valgrind --leak-check=yes --error-exitcode=1 ./zbufftest -T1mn
|
$(VALGRIND) ./zbufftest -T1mn
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -167,6 +167,8 @@ static void waitEnter(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define CLEAN_RETURN(i) { operationResult = (i); goto _end; }
|
||||||
|
|
||||||
int main(int argCount, const char** argv)
|
int main(int argCount, const char** argv)
|
||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
@ -211,8 +213,8 @@ int main(int argCount, const char** argv)
|
|||||||
/* long commands (--long-word) */
|
/* long commands (--long-word) */
|
||||||
if (!strcmp(argument, "--decompress")) { decode=1; continue; }
|
if (!strcmp(argument, "--decompress")) { decode=1; continue; }
|
||||||
if (!strcmp(argument, "--force")) { FIO_overwriteMode(); continue; }
|
if (!strcmp(argument, "--force")) { FIO_overwriteMode(); continue; }
|
||||||
if (!strcmp(argument, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); return 0; }
|
if (!strcmp(argument, "--version")) { displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); }
|
||||||
if (!strcmp(argument, "--help")) { displayOut=stdout; return usage_advanced(programName); }
|
if (!strcmp(argument, "--help")) { displayOut=stdout; CLEAN_RETURN(usage_advanced(programName)); }
|
||||||
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
if (!strcmp(argument, "--verbose")) { displayLevel=4; continue; }
|
||||||
if (!strcmp(argument, "--quiet")) { displayLevel--; continue; }
|
if (!strcmp(argument, "--quiet")) { displayLevel--; continue; }
|
||||||
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; displayLevel=1; continue; }
|
if (!strcmp(argument, "--stdout")) { forceStdout=1; outFileName=stdoutmark; displayLevel=1; continue; }
|
||||||
@ -244,16 +246,16 @@ int main(int argCount, const char** argv)
|
|||||||
}
|
}
|
||||||
dictCLevel = cLevel;
|
dictCLevel = cLevel;
|
||||||
if (dictCLevel > ZSTD_maxCLevel())
|
if (dictCLevel > ZSTD_maxCLevel())
|
||||||
return badusage(programName);
|
CLEAN_RETURN(badusage(programName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(argument[0])
|
switch(argument[0])
|
||||||
{
|
{
|
||||||
/* Display help */
|
/* Display help */
|
||||||
case 'V': displayOut=stdout; DISPLAY(WELCOME_MESSAGE); return 0; /* Version Only */
|
case 'V': displayOut=stdout; DISPLAY(WELCOME_MESSAGE); CLEAN_RETURN(0); /* Version Only */
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'h': displayOut=stdout; return usage_advanced(programName);
|
case 'h': displayOut=stdout; CLEAN_RETURN(usage_advanced(programName));
|
||||||
|
|
||||||
/* Decoding */
|
/* Decoding */
|
||||||
case 'd': decode=1; argument++; break;
|
case 'd': decode=1; argument++; break;
|
||||||
@ -288,8 +290,7 @@ int main(int argCount, const char** argv)
|
|||||||
|
|
||||||
/* Modify Nb Iterations (benchmark only) */
|
/* Modify Nb Iterations (benchmark only) */
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{ U32 iters= 0;
|
||||||
int iters= 0;
|
|
||||||
argument++;
|
argument++;
|
||||||
while ((*argument >='0') && (*argument <='9'))
|
while ((*argument >='0') && (*argument <='9'))
|
||||||
iters *= 10, iters += *argument++ - '0';
|
iters *= 10, iters += *argument++ - '0';
|
||||||
@ -299,8 +300,7 @@ int main(int argCount, const char** argv)
|
|||||||
|
|
||||||
/* cut input into blocks (benchmark only) */
|
/* cut input into blocks (benchmark only) */
|
||||||
case 'B':
|
case 'B':
|
||||||
{
|
{ size_t bSize = 0;
|
||||||
size_t bSize = 0;
|
|
||||||
argument++;
|
argument++;
|
||||||
while ((*argument >='0') && (*argument <='9'))
|
while ((*argument >='0') && (*argument <='9'))
|
||||||
bSize *= 10, bSize += *argument++ - '0';
|
bSize *= 10, bSize += *argument++ - '0';
|
||||||
@ -329,11 +329,11 @@ int main(int argCount, const char** argv)
|
|||||||
case 'p': main_pause=1; argument++; break;
|
case 'p': main_pause=1; argument++; break;
|
||||||
|
|
||||||
/* unknown command */
|
/* unknown command */
|
||||||
default : return badusage(programName);
|
default : CLEAN_RETURN(badusage(programName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
} /* if (argument[0]=='-') */
|
||||||
|
|
||||||
if (nextEntryIsDictionary) {
|
if (nextEntryIsDictionary) {
|
||||||
nextEntryIsDictionary = 0;
|
nextEntryIsDictionary = 0;
|
||||||
@ -389,17 +389,17 @@ int main(int argCount, const char** argv)
|
|||||||
if(!filenameIdx) filenameIdx=1, filenameTable[0]=stdinmark, outFileName=stdoutmark;
|
if(!filenameIdx) filenameIdx=1, filenameTable[0]=stdinmark, outFileName=stdoutmark;
|
||||||
|
|
||||||
/* Check if input/output defined as console; trigger an error in this case */
|
/* Check if input/output defined as console; trigger an error in this case */
|
||||||
if (!strcmp(filenameTable[0], stdinmark) && IS_CONSOLE(stdin) ) return badusage(programName);
|
if (!strcmp(filenameTable[0], stdinmark) && IS_CONSOLE(stdin) ) CLEAN_RETURN(badusage(programName));
|
||||||
if (outFileName && !strcmp(outFileName, stdoutmark) && IS_CONSOLE(stdout) && !forceStdout) return badusage(programName);
|
if (outFileName && !strcmp(outFileName, stdoutmark) && IS_CONSOLE(stdout) && !forceStdout) CLEAN_RETURN(badusage(programName));
|
||||||
|
|
||||||
/* user-selected output filename, only possible with a single file */
|
/* user-selected output filename, only possible with a single file */
|
||||||
if (outFileName && strcmp(outFileName,stdoutmark) && strcmp(outFileName,nulmark) && (filenameIdx>1)) {
|
if (outFileName && strcmp(outFileName,stdoutmark) && strcmp(outFileName,nulmark) && (filenameIdx>1)) {
|
||||||
DISPLAY("Too many files (%u) on the command line. \n", filenameIdx);
|
DISPLAY("Too many files (%u) on the command line. \n", filenameIdx);
|
||||||
return filenameIdx;
|
CLEAN_RETURN(filenameIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No warning message in pipe mode (stdin + stdout) or multiple mode */
|
/* No warning message in pipe mode (stdin + stdout) or multiple mode */
|
||||||
if (!strcmp(filenameTable[0], stdinmark) && !strcmp(outFileName,stdoutmark) && (displayLevel==2)) displayLevel=1;
|
if (!strcmp(filenameTable[0], stdinmark) && outFileName && !strcmp(outFileName,stdoutmark) && (displayLevel==2)) displayLevel=1;
|
||||||
if ((filenameIdx>1) && (displayLevel==2)) displayLevel=1;
|
if ((filenameIdx>1) && (displayLevel==2)) displayLevel=1;
|
||||||
|
|
||||||
/* IO Stream/File */
|
/* IO Stream/File */
|
||||||
|
Reference in New Issue
Block a user