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
This commit is contained in:
Christopher Haster
2020-11-14 09:32:34 -06:00
parent 4c9146ea53
commit 480cdd9f81

2
lfs.c
View File

@@ -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);