mirror of
https://github.com/facebook/zstd.git
synced 2025-08-10 04:43:07 +03:00
Merge pull request #1907 from selavy/check-fread-r1895
Check for fread failure
This commit is contained in:
@@ -1769,7 +1769,7 @@ static int FIO_passThrough(const FIO_prefs_t* const prefs,
|
|||||||
size_t alreadyLoaded)
|
size_t alreadyLoaded)
|
||||||
{
|
{
|
||||||
size_t const blockSize = MIN(64 KB, bufferSize);
|
size_t const blockSize = MIN(64 KB, bufferSize);
|
||||||
size_t readFromInput = 1;
|
size_t readFromInput;
|
||||||
unsigned storedSkips = 0;
|
unsigned storedSkips = 0;
|
||||||
|
|
||||||
/* assumption : ress->srcBufferLoaded bytes already loaded and stored within buffer */
|
/* assumption : ress->srcBufferLoaded bytes already loaded and stored within buffer */
|
||||||
@@ -1779,10 +1779,15 @@ static int FIO_passThrough(const FIO_prefs_t* const prefs,
|
|||||||
return 1;
|
return 1;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
while (readFromInput) {
|
do {
|
||||||
readFromInput = fread(buffer, 1, blockSize, finput);
|
readFromInput = fread(buffer, 1, blockSize, finput);
|
||||||
storedSkips = FIO_fwriteSparse(prefs, foutput, buffer, readFromInput, storedSkips);
|
storedSkips = FIO_fwriteSparse(prefs, foutput, buffer, readFromInput, storedSkips);
|
||||||
|
} while (readFromInput == blockSize);
|
||||||
|
if (ferror(finput)) {
|
||||||
|
DISPLAYLEVEL(1, "Pass-through read error : %s\n", strerror(errno));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
assert(feof(finput));
|
||||||
|
|
||||||
FIO_fwriteSparseEnd(prefs, foutput, storedSkips);
|
FIO_fwriteSparseEnd(prefs, foutput, storedSkips);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user