diff options
author | Christopher Haster <chaster@utexas.edu> | 2019-09-19 18:02:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-19 18:02:54 +0300 |
commit | fd204ac2fb4e05ffce6db6d1be67e0342c267cd7 (patch) | |
tree | 5db758e9eb1ab3f3835d1a96e4c8da58b28c66de | |
parent | bd99402d9aaef2d965d8fbe085647eadc9db4c68 (diff) | |
parent | 0c77123eeeadae9e8a02461d1fb4d023fbf3aa47 (diff) |
Merge pull request #278 from roykuper13/validate-lfs-cfg-sizesv2.1.2
lfs: Validate lfs-cfg sizes before performing any arithmetic logics with them
-rw-r--r-- | lfs.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -3369,6 +3369,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { lfs->cfg = cfg; int err = 0; + // validate that the lfs-cfg sizes were initiated properly before + // performing any arithmetic logics with them + LFS_ASSERT(lfs->cfg->read_size != 0); + LFS_ASSERT(lfs->cfg->prog_size != 0); + LFS_ASSERT(lfs->cfg->cache_size != 0); + // check that block size is a multiple of cache size is a multiple // of prog and read sizes LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0); |