Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2019-05-22 01:21:52 +0300
committerChristopher Haster <chaster@utexas.edu>2019-05-24 00:42:47 +0300
commit9899c7fe486d4a581fb84ecf832a574896d411b7 (patch)
treeeb1fdf66049a6ac6cf93034319bbd6824b032ec3
parentbc7bed740b211fec03bc3202f778f0dfa71a54a3 (diff)
Fixed read cache amount based on hint and offset
Found by apmorton
-rw-r--r--lfs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lfs.c b/lfs.c
index 7692d09..b0e6819 100644
--- a/lfs.c
+++ b/lfs.c
@@ -84,9 +84,12 @@ static int lfs_bd_read(lfs_t *lfs,
LFS_ASSERT(block < lfs->cfg->block_count);
rcache->block = block;
rcache->off = lfs_aligndown(off, lfs->cfg->read_size);
- rcache->size = lfs_min(lfs_alignup(off+hint, lfs->cfg->read_size),
- lfs_min(lfs->cfg->block_size - rcache->off,
- lfs->cfg->cache_size));
+ rcache->size = lfs_min(
+ lfs_min(
+ lfs_alignup(off+hint, lfs->cfg->read_size),
+ lfs->cfg->block_size)
+ - rcache->off,
+ lfs->cfg->cache_size);
int err = lfs->cfg->read(lfs->cfg, rcache->block,
rcache->off, rcache->buffer, rcache->size);
if (err) {