Skip to content

Commit

Permalink
Assert on NULL IO function
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdongustc committed Dec 10, 2024
1 parent 2fcecc8 commit 469c863
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 @@ -4217,6 +4217,14 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
// which littlefs currently does not support
LFS_ASSERT((bool)0x80000000);

// check that the required io functions are provided
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

// validate that the lfs-cfg sizes were initiated properly before
// performing any arithmetic logics with them
LFS_ASSERT(lfs->cfg->read_size != 0);
Expand Down

0 comments on commit 469c863

Please sign in to comment.