[klibc] fseek: report error on fflush() failure
fseek(): if flushing output fails, report an error rather than
proceeding with the seek.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/usr/klibc/stdio/fseek.c b/usr/klibc/stdio/fseek.c
index b437b34..f282ce4 100644
--- a/usr/klibc/stdio/fseek.c
+++ b/usr/klibc/stdio/fseek.c
@@ -10,7 +10,8 @@
off_t rv;
if (f->obytes)
- __fflush(f);
+ if (__fflush(f))
+ return -1;
if (whence == SEEK_CUR) {
where += f->pub._io_filepos;
@@ -18,11 +19,10 @@
}
rv = lseek(f->pub._io_fileno, where, whence);
- if (rv != -1) {
+ if (__likely(rv != (off_t)-1)) {
f->pub._io_filepos = rv;
f->ibytes = 0;
f->obytes = 0;
- f->data = f->buf + _IO_UNGET_SLOP;
return 0;
} else {
return -1;