From 981ca46472cea3525828a899d83c9f3a1ed9c497 Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 12 Sep 2008 10:39:57 +0000 Subject: [PATCH] Fix docs; optimization. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1804 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/fs/battfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bertos/fs/battfs.c b/bertos/fs/battfs.c index 74c5ac5f..aeacb9cd 100644 --- a/bertos/fs/battfs.c +++ b/bertos/fs/battfs.c @@ -143,7 +143,6 @@ static fcs_t computeFcsFree(struct BattFsPageHeader *hdr) /** * Read header of page \a page. * \return true on success, false otherwise. - * \note \a hdr is dirtyed even on errors. */ static bool battfs_readHeader(struct BattFsSuper *disk, pgcnt_t page, struct BattFsPageHeader *hdr) { @@ -169,7 +168,6 @@ static bool battfs_readHeader(struct BattFsSuper *disk, pgcnt_t page, struct Bat /** * Write header of page \a page. * \return true on success, false otherwise. - * \note \a hdr is dirtyed even on errors. */ static bool battfs_writeHeader(struct BattFsSuper *disk, pgcnt_t page, struct BattFsPageHeader *hdr) { @@ -380,6 +378,9 @@ static bool countDiskFilePages(struct BattFsSuper *disk, pgoff_t *filelen_table) if (!battfs_readHeader(disk, page, &hdr)) return false; + /* Increase free space */ + disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN; + /* Check header FCS */ if (hdr.fcs == computeFcs(&hdr)) { @@ -391,13 +392,10 @@ static bool countDiskFilePages(struct BattFsSuper *disk, pgoff_t *filelen_table) filelen_table[hdr.inode]++; /* Keep trace of free space */ - disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN - hdr.fill; + disk->free_bytes -= hdr.fill; } else { - /* Increase free space */ - disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN; - /* Check if page is marked free */ if (hdr.fcs_free == computeFcsFree(&hdr)) { -- 2.25.1