POSIX / fread():
The file position indicator for the stream (if defined) shall be advanced by the
number of bytes successfully read. If an error occurs, the resulting value of
the file position indicator for the stream is unspecified. If a partial element
is read, its value is unspecified.
goto done;
}
- ssize_t cnt;
+ assert(ret == 0);
+ size_t cnt;
while ((cnt = fread(buf, sizeof(*buf), BUFSIZE, from)) != 0 &&
- (ret = (fwrite(buf, sizeof(*buf), cnt, file) == cnt))) {
+ (ret = (fwrite(buf, sizeof(*buf), cnt, file) == cnt)) &&
+ (feof(from) | ferror(from)) == 0) {
}
ret = !ret || ferror(from);