Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <geky@geky.net>2023-04-26 10:41:44 +0300
committerGitHub <noreply@github.com>2023-04-26 10:41:44 +0300
commit92298c749d868cbc248f00eabd644e5b08e0c8df (patch)
tree9c87b00255c0a38646c0b3179962a2e5a5e22bab
parent50b394ca36c54f657b92ce9d9ee97f45d811a81d (diff)
parentb0a4a44e5b2e6baeba7255b5abd32fee018b3aa7 (diff)
Merge pull request #802 from littlefs-project/assert-minimum-block-size
Add explicit assert for minimum block size of 128 bytes
-rw-r--r--lfs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lfs.c b/lfs.c
index 7dae2f4..9906bd1 100644
--- a/lfs.c
+++ b/lfs.c
@@ -4040,7 +4040,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);