From: batt Date: Tue, 5 Feb 2008 14:27:32 +0000 (+0000) Subject: Handle seq wrap. X-Git-Tag: 1.0.0~159 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=95653ebdc7081ad0c989e971fe4cab9bc8d1f945;hp=4c1f7cd0bcf77994d03cacf2f3cbb5d529cc1ff8;p=bertos.git Handle seq wrap. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1093 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/fs/battfs.c b/fs/battfs.c index 8289e91d..422ce9e6 100644 --- a/fs/battfs.c +++ b/fs/battfs.c @@ -418,9 +418,8 @@ bool battfs_init(struct BattFsSuper *disk) pgcnt_t new_page, old_page; fill_t old_fill; - /* Fancy check to handle seq wraparound */ - #define HALF_SEQ (1 << ((sizeof(seq_t) * CPU_BITS_PER_CHAR) - 1)) - if ((hdr.seq - hdr_old.seq) < HALF_SEQ) + /* Fancy check to handle seq wraparound (2 bits only) */ + if (((hdr.seq - hdr_old.seq) & 0x03) < 2) { /* Current header is newer than the previuos one */ old_page = disk->page_array[array_pos];