From: batt Date: Mon, 8 Jun 2009 13:00:31 +0000 (+0000) Subject: Fix seek return value; Clear structure on init; add DB to _type. X-Git-Tag: 2.2.0~261 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=8bbccfe43a27ce0f8d46b8262201c3e611bedf46;p=bertos.git Fix seek return value; Clear structure on init; add DB to _type. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2707 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/emul/kfile_posix.c b/bertos/emul/kfile_posix.c index 593571d4..1f09aaff 100644 --- a/bertos/emul/kfile_posix.c +++ b/bertos/emul/kfile_posix.c @@ -37,6 +37,7 @@ */ #include +#include static size_t kfile_posix_read(struct KFile *_fd, void *buf, size_t size) { @@ -67,9 +68,13 @@ static kfile_off_t kfile_posix_seek(struct KFile *_fd, kfile_off_t offset, KSeek break; default: ASSERT(0); + return EOF; } + int err = fseek(fd->fp, offset, std_whence); + if (err) + return err; - return fseek(fd->fp, offset, std_whence); + return ftell(fd->fp); } static int kfile_posix_close(struct KFile *_fd) @@ -86,7 +91,8 @@ static int kfile_posix_flush(struct KFile *_fd) FILE *kfile_posix_init(KFilePosix *file, const char *filename, const char *mode) { - file->fd._type = KFT_KFILEPOSIX; + memset(file, 0, sizeof(*file)); + DB(file->fd._type = KFT_KFILEPOSIX); file->fd.read = kfile_posix_read; file->fd.write = kfile_posix_write; file->fd.close = kfile_posix_close;