Moved ckprogs behind LFS_CKPROGS ifdef

So just like ckreads, ckprogs is now opt-in, requiring both 1. defining
LFS_CKPROGS at compile-time, and 2. passing the LFS_M_CKPROGS flag
during lfsr_mount.

_Unlike_ ckreads, ckprogs is actually a very lightweight feature. So the
difference between compiling with/without ckprogs is really quite small:

                code          stack
  before:      36480           2680
  yes-ckprogs: 36480 (+0.0%)   2680 (+0.0%)
  no-ckprogs:  36428 (-0.1%)   2680 (+0.0%)

It's almost not worth putting behind an ifdef if not for consistency
with ckreads.
This commit is contained in:
Christopher Haster
2024-08-12 20:01:47 -05:00
parent e536300606
commit 10feccf18c
7 changed files with 212 additions and 99 deletions
+9 -3
View File
@@ -295,7 +295,9 @@ static int lfsr_bd_read(lfs_t *lfs,
}
// needed in lfsr_bd_prog_ for prog validation
#ifdef LFS_CKPROGS
static inline bool lfsr_m_isckprogs(uint32_t flags);
#endif
static lfs_scmp_t lfsr_bd_cmp(lfs_t *lfs,
lfs_block_t block, lfs_size_t off, lfs_size_t hint,
const void *buffer, lfs_size_t size);
@@ -314,6 +316,7 @@ static int lfsr_bd_prog_(lfs_t *lfs, lfs_block_t block, lfs_size_t off,
return err;
}
#ifdef LFS_CKPROGS
// check progs?
if (lfsr_m_isckprogs(lfs->flags)) {
// pcache should have been dropped at this point
@@ -335,6 +338,7 @@ static int lfsr_bd_prog_(lfs_t *lfs, lfs_block_t block, lfs_size_t off,
return LFS_ERR_CORRUPT;
}
}
#endif
// update rcache if we can
if (block == lfs->rcache.block
@@ -6681,9 +6685,11 @@ static inline bool lfsr_m_isrdonly(uint32_t flags) {
return flags & LFS_M_RDONLY;
}
#ifdef LFS_CKPROGS
static inline bool lfsr_m_isckprogs(uint32_t flags) {
return flags & LFS_M_CKPROGS;
}
#endif
#ifdef LFS_CKREADS
static inline bool lfsr_m_isckreads(uint32_t flags) {
@@ -13345,7 +13351,7 @@ int lfsr_mount(lfs_t *lfs, uint32_t flags,
LFS_ASSERT((flags & ~(
LFS_M_RDWR
| LFS_M_RDONLY
| LFS_M_CKPROGS
| LFS_IFDEF_CKPROGS(LFS_M_CKPROGS, 0)
| LFS_IFDEF_CKREADS(LFS_M_CKREADS, 0)
| LFS_M_FLUSH
| LFS_M_SYNC
@@ -13501,7 +13507,7 @@ int lfsr_format(lfs_t *lfs, uint32_t flags,
// unknown flags?
LFS_ASSERT((flags & ~(
LFS_F_RDWR
| LFS_F_CKPROGS
| LFS_IFDEF_CKPROGS(LFS_F_CKPROGS, 0)
| LFS_IFDEF_CKREADS(LFS_F_CKREADS, 0)
| LFS_F_MTREEONLY
| LFS_F_COMPACT
@@ -13566,7 +13572,7 @@ int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
// return various filesystem flags
fsinfo->flags = lfs->flags & (
LFS_I_RDONLY
| LFS_I_CKPROGS
| LFS_IFDEF_CKPROGS(LFS_I_CKPROGS, 0)
| LFS_IFDEF_CKREADS(LFS_I_CKREADS, 0)
| LFS_I_FLUSH
| LFS_I_SYNC