Skip to content

Commit b35d761

Browse files
committed
Removed words variable from lfs struct
1 parent 63b52c9 commit b35d761

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lfs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,12 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
859859
/// File index list operations ///
860860
static int lfs_index(lfs_t *lfs, lfs_off_t *off) {
861861
lfs_off_t i = 0;
862+
lfs_size_t words = lfs->cfg->block_size / 4;
862863

863864
while (*off >= lfs->cfg->block_size) {
864865
i += 1;
865866
*off -= lfs->cfg->block_size;
866-
*off += 4*lfs_min(lfs_ctz(i)+1, lfs->words-1);
867+
*off += 4*lfs_min(lfs_ctz(i)+1, words-1);
867868
}
868869

869870
return i;
@@ -881,11 +882,12 @@ static int lfs_index_find(lfs_t *lfs,
881882

882883
lfs_off_t current = lfs_index(lfs, &(lfs_off_t){size-1});
883884
lfs_off_t target = lfs_index(lfs, &pos);
885+
lfs_size_t words = lfs->cfg->block_size / 4;
884886

885887
while (current > target) {
886888
lfs_size_t skip = lfs_min(
887889
lfs_npw2(current-target+1) - 1,
888-
lfs_min(lfs_ctz(current)+1, lfs->words-1) - 1);
890+
lfs_min(lfs_ctz(current)+1, words-1) - 1);
889891

890892
int err = lfs_cache_read(lfs, rcache, pcache, head, 4*skip, &head, 4);
891893
if (err) {
@@ -945,7 +947,8 @@ static int lfs_index_extend(lfs_t *lfs,
945947

946948
// append block
947949
index += 1;
948-
lfs_size_t skips = lfs_min(lfs_ctz(index)+1, lfs->words-1);
950+
lfs_size_t words = lfs->cfg->block_size / 4;
951+
lfs_size_t skips = lfs_min(lfs_ctz(index)+1, words-1);
949952

950953
for (lfs_off_t i = 0; i < skips; i++) {
951954
int err = lfs_cache_prog(lfs, pcache, *block, 4*i, &head, 4);
@@ -1538,7 +1541,6 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
15381541
/// Filesystem operations ///
15391542
static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
15401543
lfs->cfg = cfg;
1541-
lfs->words = lfs->cfg->block_size / sizeof(uint32_t);
15421544

15431545
// setup read cache
15441546
lfs->rcache.block = 0xffffffff;

lfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ typedef struct lfs_free {
210210
// littlefs type
211211
typedef struct lfs {
212212
const struct lfs_config *cfg;
213-
lfs_size_t words; // number of 32-bit words that can fit in a block
214213

215214
lfs_block_t root[2];
216215
lfs_dir_t *scratch;

0 commit comments

Comments
 (0)