diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-05-12 13:06:24 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-05-12 13:06:24 -0700 |
commit | d0090d423bdd0476451aef8ae5c1b21adc714aec (patch) | |
tree | 0809e1114b773c4abe5294e3c7586bbd8ab684fa | |
parent | bc953857b46ea7455a639740d751d4ae5569f789 (diff) | |
download | klibc-d0090d423bdd0476451aef8ae5c1b21adc714aec.tar.gz |
[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>
-rw-r--r-- | usr/klibc/stdio/fseek.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr/klibc/stdio/fseek.c b/usr/klibc/stdio/fseek.c index b437b346ac160..f282ce4c82f25 100644 --- a/usr/klibc/stdio/fseek.c +++ b/usr/klibc/stdio/fseek.c @@ -10,7 +10,8 @@ __extern int fseek(FILE *file, off_t where, int whence) 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 @@ __extern int fseek(FILE *file, off_t where, int whence) } 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; |