From 931442a784a3e7403adc098aaf71fd78c4f52012 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 25 Jun 2017 17:23:40 -0500 Subject: [PATCH] Adopted redundant cache read in lfs_file_relocate Previously had some custom logic that could be reduced --- lfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lfs.c b/lfs.c index c88b03aa356..e29afc3102b 100644 --- a/lfs.c +++ b/lfs.c @@ -1207,14 +1207,10 @@ static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) { // either read from dirty cache or disk for (lfs_off_t i = 0; i < file->off; i++) { uint8_t data; - if (file->cache.block == file->block && i >= file->cache.off) { - data = file->cache.buffer[i - file->cache.off]; - } else { - // just read from disk - err = lfs_bd_read(lfs, file->block, i, &data, 1); - if (err) { - return err; - } + err = lfs_cache_read(lfs, &lfs->rcache, &file->cache, + file->block, i, &data, 1); + if (err) { + return err; } err = lfs_cache_prog(lfs, &lfs->pcache, &lfs->rcache,