Skip to content

Commit

Permalink
fs: littlefs: Fix cache and lookahead size checks
Browse files Browse the repository at this point in the history
This fixes an issue where wrong values were checked against block device
defaults. Kconfig values are used when no filesystem config values are
provided, and the buffers are sized according to the Kconfig values,
but the checks were only performed against filesystem config variables.

Signed-off-by: Djordje Nedic <[email protected]>
(cherry picked from commit 2750492)
  • Loading branch information
DNedic authored and github-actions[bot] committed Dec 16, 2024
1 parent d6ec225 commit c51a25e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions subsys/fs/littlefs_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,16 +846,16 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
lcp->read_size = block_size;
lcp->prog_size = block_size;

if (lcp->cache_size < new_cache_size) {
LOG_ERR("Configured cache size is too small: %d < %d", lcp->cache_size,
if (cache_size < new_cache_size) {
LOG_ERR("Configured cache size is too small: %d < %d", cache_size,
new_cache_size);
return -ENOMEM;
}
lcp->cache_size = new_cache_size;

if (lcp->lookahead_size < new_lookahead_size) {
if (lookahead_size < new_lookahead_size) {
LOG_ERR("Configured lookahead size is too small: %d < %d",
lcp->lookahead_size, new_lookahead_size);
lookahead_size, new_lookahead_size);
return -ENOMEM;

Check notice on line 859 in subsys/fs/littlefs_fs.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/fs/littlefs_fs.c:859 - LOG_ERR("Configured lookahead size is too small: %d < %d", - lookahead_size, new_lookahead_size); + LOG_ERR("Configured lookahead size is too small: %d < %d", lookahead_size, + new_lookahead_size);

Check notice on line 859 in subsys/fs/littlefs_fs.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/fs/littlefs_fs.c:859 - LOG_ERR("Configured lookahead size is too small: %d < %d", - lookahead_size, new_lookahead_size); + LOG_ERR("Configured lookahead size is too small: %d < %d", lookahead_size, + new_lookahead_size);
}
lcp->lookahead_size = new_lookahead_size;
Expand Down

0 comments on commit c51a25e

Please sign in to comment.