Fixed issue with aggressively rounding down lookahead configuration

The littlefs allows buffers to be passed statically in the case
that a system does not have a heap. Unfortunately, this means we
can't round up in the case of an unaligned lookahead buffer.

Double unfortunately, rounding down after clamping to the block device
size could result in a lookahead of zero for block devices < 32 blocks
large.

The assert in littlefs does catch this case, but rounding down prevents
support for < 32 block devices.

The solution is to simply require a 32-bit aligned buffer with an
assert. This avoids runtime problems while allowing a user to pass
in the correct buffer for < 32 block devices. Rounding up can be
handled at higher API levels.
This commit is contained in:
Christopher Haster
2017-11-09 19:10:08 -06:00
parent db51a395ba
commit f4aeb8331a
3 changed files with 12 additions and 13 deletions

1
lfs.h
View File

@@ -236,7 +236,6 @@ typedef struct lfs_superblock {
} lfs_superblock_t;
typedef struct lfs_free {
lfs_size_t lookahead;
lfs_block_t begin;
lfs_block_t end;
lfs_block_t off;