diff --git a/lfs3.c b/lfs3.c index 53adcad1..31b2ad82 100644 --- a/lfs3.c +++ b/lfs3.c @@ -9682,16 +9682,15 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t, // scan for blocks/btrees in our opened file list case LFS3_TSTATE_OMDIRS:; // reached end of opened files? return to mdir traversal - if (LFS3_IFDEF_RDONLY( - // we don't need to traverse these if rdonly - true, - !t->ot)) { + // + // note we can skip checking opened files if mounted rdonly, + // this saves a bit of code when compiled rdonly + if (lfs3_m_isrdonly(lfs3->flags) || !t->ot) { t->b.o.mdir.mid += 1; lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_MDIR); continue; } - #ifndef LFS3_RDONLY // skip unrelated files, we only care about unsync reg files // associated with the current mid // @@ -9721,7 +9720,6 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t, *bptr = file->leaf.bptr; return 0; } - #endif continue; @@ -9754,15 +9752,12 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t, lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS); continue; // end of opened btree? go to next opened file - } else if (LFS3_IFDEF_RDONLY( - false, - lfs3_t_tstate(t->b.o.flags) - == LFS3_TSTATE_OBTREE)) { - #ifndef LFS3_RDONLY + } else if (lfs3_m_isrdonly(lfs3->flags) + || lfs3_t_tstate(t->b.o.flags) + == LFS3_TSTATE_OBTREE) { t->ot = t->ot->next; lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS); continue; - #endif } else { LFS3_UNREACHABLE(); }