From 469c863c18b99bf17470e1c066252d43bfaa3e14 Mon Sep 17 00:00:00 2001 From: Dong Wang Date: Tue, 10 Dec 2024 00:17:43 +0800 Subject: [PATCH] Assert on NULL IO function --- lfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lfs.c b/lfs.c index 9e7fff7f..e92381ae 100644 --- a/lfs.c +++ b/lfs.c @@ -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);