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

View File

@@ -15,7 +15,7 @@ script:
- CFLAGS="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1" make test
- CFLAGS="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512" make test
- CFLAGS="-DLFS_BLOCK_COUNT=1023" make test
- CFLAGS="-DLFS_LOOKAHEAD=2047" make test
- CFLAGS="-DLFS_LOOKAHEAD=2048" make test
# self-host with littlefs-fuse for fuzz test
- make -C littlefs-fuse