From 8b7e743921455bed93fa0dccdffd43c2ea9bd933 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Fri, 15 Aug 2008 22:38:43 +0000 Subject: [PATCH] Enforce the number of pages in a sector to be a power of two. --- core/cfs/cfs-coffee.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index d2f64c7e1..30798c0f3 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -53,6 +53,11 @@ #define PRINTF(...) #endif +#if COFFEE_PAGES_PER_SECTOR & (COFFEE_PAGES_PER_SECTOR - 1) +#error COFFEE_PAGES_PER_SECTOR must be a power of two. +#error Change COFFEE_PAGES_PER_SECTOR in cfs-coffee-arch.h. +#endif + #define kb * 1024UL #define Mb * (1024 kb) @@ -322,6 +327,7 @@ find_contiguous_pages(unsigned wanted) return start; } } + /* Jump to the next sector. */ page = (page + COFFEE_PAGES_PER_SECTOR) & ~(COFFEE_PAGES_PER_SECTOR - 1); } else { start = -1; @@ -378,7 +384,7 @@ remove_by_page(uint16_t page, int remove_log, int close_fds) struct file_header hdr; int i; uint16_t log_page; - + if(page >= COFFEE_PAGE_COUNT) { return -1; }