X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=fs%2Fbattfs.c;fp=fs%2Fbattfs.c;h=1b8bf92336f0f340a8c851765119cb93c5e97968;hb=781d5135a61025caea65ef66b5c6bde2ef950e40;hp=752ec3c61981a582e581b0ea8a7ecdd1ab33bcb0;hpb=dc256a92515659a4e96c13bf080e31101cd52a9d;p=bertos.git diff --git a/fs/battfs.c b/fs/battfs.c index 752ec3c6..1b8bf923 100644 --- a/fs/battfs.c +++ b/fs/battfs.c @@ -339,8 +339,9 @@ bool battfs_init(struct BattFsSuper *disk) pgcnt_t new_page, old_page; fill_t old_fill; - #warning fix seq wraparound! - if (hdr.seq > hdr_old.seq) + /* Fancy check to handle seq wraparound */ + #define HALF_SEQ ((1 << (sizeof(seq_t) * CPU_BITS_PER_CHAR)) / 2) + if ((hdr.seq - hdr_old.seq) < HALF_SEQ) { /* Actual header is newer than the previuos one */ old_page = disk->page_array[array_pos];