diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-05-12 15:26:35 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-05-12 15:26:35 -0700 |
commit | 0ba9a8316ad201053e32dbdbbd68da5edfe5230d (patch) | |
tree | 02b3f8fd6e92edb96bfbb147dd61509bcd66c9f1 | |
parent | 370c309d8fc0ad9c919e2689c283ef618d7b5754 (diff) | |
download | klibc-0ba9a8316ad201053e32dbdbbd68da5edfe5230d.tar.gz |
[klibc] stdio: fix the handling of the eof and error flags on fseek
For fseek, a successful seek clears the eof flag; a failed seek sets
the error flag. This means we don't need to clear the eof flag in
rewind().
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | usr/klibc/stdio/fseek.c | 2 | ||||
-rw-r--r-- | usr/klibc/stdio/rewind.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/usr/klibc/stdio/fseek.c b/usr/klibc/stdio/fseek.c index f282ce4c82f25..f848844ef500b 100644 --- a/usr/klibc/stdio/fseek.c +++ b/usr/klibc/stdio/fseek.c @@ -21,10 +21,12 @@ __extern int fseek(FILE *file, off_t where, int whence) rv = lseek(f->pub._io_fileno, where, whence); if (__likely(rv != (off_t)-1)) { f->pub._io_filepos = rv; + f->pub._io_eof = false; f->ibytes = 0; f->obytes = 0; return 0; } else { + f->pub._io_error = true; return -1; } } diff --git a/usr/klibc/stdio/rewind.c b/usr/klibc/stdio/rewind.c index f5d39fb4f8d9e..67bd35749f361 100644 --- a/usr/klibc/stdio/rewind.c +++ b/usr/klibc/stdio/rewind.c @@ -1,7 +1,8 @@ #include <stdio.h> +#include <stdbool.h> void rewind(FILE *f) { if (!fseek(f, 0, SEEK_SET)) - clearerr(f); + f->_io_error = false; } |