Skip to content

Commit

Permalink
Assert on NULL IO functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdongustc committed Dec 9, 2024
1 parent 2fcecc8 commit 32d9fcd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4236,6 +4236,14 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4))
<= lfs->cfg->block_size);

// check that the user has provided io functions correctly.
LFS_ASSERT(lfs->cfg->read != NULL);
#ifndef LFS_READONLY
LFS_ASSERT(lfs->cfg->prog != NULL);
LFS_ASSERT(lfs->cfg->erase != NULL);
LFS_ASSERT(lfs->cfg->sync != NULL);
#endif

// block_cycles = 0 is no longer supported.
//
// block_cycles is the number of erase cycles before littlefs evicts
Expand Down

0 comments on commit 32d9fcd

Please sign in to comment.