Adopted redundant cache read in lfs_file_relocate

Previously had some custom logic that could be reduced
This commit is contained in:
Christopher Haster 2017-06-25 17:23:40 -05:00
parent 0e1022a86c
commit 931442a784

12
lfs.c
View File

@ -1207,14 +1207,10 @@ relocate:
// 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,