summaryrefslogtreecommitdiff
path: root/blktrace.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-05-08 07:13:39 +0200
committerJens Axboe <axboe@suse.de>2006-05-08 07:13:39 +0200
commit1452478f2d1b27916c7cba6e3976ed2129533c73 (patch)
treeacce8634d28a1721ed3355ce4f746e88fceb512a /blktrace.c
parent6a6d3f0f61a8325b4d986e25bb0a61a82ca79e57 (diff)
downloadblktrace-1452478f2d1b27916c7cba6e3976ed2129533c73.tar.gz
blktrace-1452478f2d1b27916c7cba6e3976ed2129533c73.tar.bz2
[PATCH] fread/fwrite error handling
Need to check ferror(), not return value. Thanks to Alex Polvi.
Diffstat (limited to 'blktrace.c')
-rw-r--r--blktrace.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/blktrace.c b/blktrace.c
index cf67e7e..e345888 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -836,15 +836,11 @@ static int write_data(struct thread_information *tip, void *buf,
if (!buf_len)
return 0;
- while (1) {
- ret = fwrite(buf, buf_len, 1, tip->ofile);
- if (ret == 1)
- break;
-
- if (ret < 0) {
- perror("write");
- return 1;
- }
+ ret = fwrite(buf, buf_len, 1, tip->ofile);
+ if (ferror(tip->ofile) || ret != 1) {
+ perror("fwrite");
+ clearerr(tip->ofile);
+ return 1;
}
if (tip->ofile_stdout)