From 95653ebdc7081ad0c989e971fe4cab9bc8d1f945 Mon Sep 17 00:00:00 2001 From: batt Date: Tue, 5 Feb 2008 14:27:32 +0000 Subject: [PATCH] Handle seq wrap. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1093 38d2e660-2303-0410-9eaa-f027e97ec537 --- fs/battfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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]; -- 2.25.1