summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dfd3fe1)
According to http://pubs.opengroup.org/onlinepubs/
7908799/xsh/fread.html
fread() returns a size_t, not ssize_t, and returns a value of 0 on
both eof and an error. Therefore, check both feof() and ferror() to
determine whether the call succeeded.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
struct iolog_compress ic;
z_stream stream;
struct stat sb;
struct iolog_compress ic;
z_stream stream;
struct stat sb;
size_t total;
void *buf;
FILE *f;
size_t total;
void *buf;
FILE *f;
ic.seq = 1;
ret = fread(ic.buf, ic.len, 1, f);
ic.seq = 1;
ret = fread(ic.buf, ic.len, 1, f);
+ if (ret == 0 && ferror(f)) {
perror("fread");
fclose(f);
free(buf);
return 1;
perror("fread");
fclose(f);
free(buf);
return 1;
+ } else if (ferror(f) || (!feof(f) && ret != 1)) {
log_err("fio: short read on reading log\n");
fclose(f);
free(buf);
log_err("fio: short read on reading log\n");
fclose(f);
free(buf);