forked from Imagelibrary/littlefs
Compare commits
1 Commits
assert-min
...
assert-boo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aae897ffd0 |
11
lfs.c
11
lfs.c
@@ -3905,6 +3905,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
|
||||
lfs->cfg = cfg;
|
||||
int err = 0;
|
||||
|
||||
// check that bool is a truthy-preserving type
|
||||
//
|
||||
// note the most common reason for this failure is a before-c99 compiler,
|
||||
// which littlefs currently does not support
|
||||
LFS_ASSERT((bool)0x80000000);
|
||||
|
||||
// validate that the lfs-cfg sizes were initiated properly before
|
||||
// performing any arithmetic logics with them
|
||||
LFS_ASSERT(lfs->cfg->read_size != 0);
|
||||
@@ -3917,10 +3923,7 @@ 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 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
|
||||
// check that the block size is large enough to fit ctz pointers
|
||||
LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4))
|
||||
<= lfs->cfg->block_size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user