From b7c2b3fc3ad2f6db72fff39aec149c54ed090c03 Mon Sep 17 00:00:00 2001 From: Julien D'Ascenzio Date: Thu, 19 Jan 2023 13:55:59 +0100 Subject: [PATCH] nvs: NVS cache always rebuild on successful NVS initialization During the NVS initialization, if gc had to be done, the NVS cache rebuild wasn't called. Signed-off-by: Julien D'Ascenzio --- subsys/fs/nvs/nvs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/subsys/fs/nvs/nvs.c b/subsys/fs/nvs/nvs.c index c78153e22e0..095ac9cf837 100644 --- a/subsys/fs/nvs/nvs.c +++ b/subsys/fs/nvs/nvs.c @@ -887,11 +887,13 @@ static int nvs_startup(struct nvs_fs *fs) fs->data_wra = fs->ate_wra & ADDR_SECT_MASK; } -#ifdef CONFIG_NVS_LOOKUP_CACHE - rc = nvs_lookup_cache_rebuild(fs); -#endif - end: + +#ifdef CONFIG_NVS_LOOKUP_CACHE + if (!rc) { + rc = nvs_lookup_cache_rebuild(fs); + } +#endif /* If the sector is empty add a gc done ate to avoid having insufficient * space when doing gc. */