Handle seq wrap.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Feb 2008 14:27:32 +0000 (14:27 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Feb 2008 14:27:32 +0000 (14:27 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1093 38d2e660-2303-0410-9eaa-f027e97ec537

fs/battfs.c

index 8289e91d245ee717f5dd9fd0a49398f4ae355e98..422ce9e69c5bd79ed42717cf66331b1f8ef77460 100644 (file)
@@ -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];