From c36d4b6e73fd7e760f1a99fd2d87d7083fd87933 Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 19 Sep 2008 16:32:15 +0000 Subject: [PATCH] Refactor countFileSize to return the size directly. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1816 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/fs/battfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bertos/fs/battfs.c b/bertos/fs/battfs.c index d8fdfc3f..a817d0be 100644 --- a/bertos/fs/battfs.c +++ b/bertos/fs/battfs.c @@ -621,19 +621,19 @@ bool battfs_fileExists(BattFsSuper *disk, inode_t inode) * in disk->page_array. Size is written in \a size. * \return true if all s ok, false on disk read errors. */ -static bool countFileSize(BattFsSuper *disk, pgcnt_t *start, inode_t inode, file_size_t *size) +static file_size_t countFileSize(BattFsSuper *disk, pgcnt_t *start, inode_t inode) { - *size = 0; + file_size_t size = 0; BattFsPageHeader hdr; for (;;) { if (!battfs_readHeader(disk, *start++, &hdr)) - return false; + return EOF; if (hdr.fcs == computeFcs(&hdr) && hdr.inode == inode) - *size += hdr.fill; + size += hdr.fill; else - return true; + return size; } } @@ -666,7 +666,7 @@ bool battfs_fileopen(BattFsSuper *disk, BattFs *fd, inode_t inode, filemode_t mo } /* Fill file size */ - if (!countFileSize(disk, fd->start, inode, &fd->fd.size)) + if ((fd->fd.size = countFileSize(disk, fd->start, inode)) == EOF) return false; /* Reset seek position */ -- 2.25.1