From 480cdd9f815d1d78caf98f22ed94ef4f58e46d0c Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 14 Nov 2020 09:32:34 -0600 Subject: [PATCH] Fixed incorrect modulus in lfs_alloc_reset Modulus of the offset by block_size was clearly a typo, and should be block_count. Interesting to note that later moduluses during alloc calculations prevents this from breaking anything, but as gtaska notes it could skew the wear-leveling distribution. Found by guiserle and gtaska --- lfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index eb832fa..7f99ccb 100644 --- a/lfs.c +++ b/lfs.c @@ -459,7 +459,7 @@ static void lfs_alloc_ack(lfs_t *lfs) { // Invalidate the lookahead buffer. This is done during mounting and // failed traversals static void lfs_alloc_reset(lfs_t *lfs) { - lfs->free.off = lfs->seed % lfs->cfg->block_size; + lfs->free.off = lfs->seed % lfs->cfg->block_count; lfs->free.size = 0; lfs->free.i = 0; lfs_alloc_ack(lfs);