From: batt Date: Fri, 19 Sep 2008 16:32:15 +0000 (+0000) Subject: Refactor countFileSize to return the size directly. X-Git-Tag: 2.0.0~118 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=c36d4b6e73fd7e760f1a99fd2d87d7083fd87933;p=bertos.git Refactor countFileSize to return the size directly. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1816 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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 */