Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3917,7 +3917,10 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->prog_size == 0);
LFS_ASSERT(lfs->cfg->block_size % lfs->cfg->cache_size == 0);

// check that the block size is large enough to fit ctz pointers
// check that the block size is large enough to fit all ctz pointers
LFS_ASSERT(lfs->cfg->block_size >= 128);
// this is the exact calculation for all ctz pointers, if this fails
// and the simpler assert above does not, math must be broken
LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4))
<= lfs->cfg->block_size);

Expand Down