Skip to content

Commit 775b245

Browse files
MarekPietacarlescufi
authored andcommitted
settings_fcb: Fix storing the data
Change fixes storing the data by adding missing write retry after the last compression. Without the change error was returned instead of retrying. Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
1 parent bfb56c5 commit 775b245

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

subsys/settings/src/settings_fcb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,16 @@ static int settings_fcb_save_priv(struct settings_store *cs, const char *name,
317317
wbs = cf->cf_fcb.f_align;
318318
len = settings_line_len_calc(name, val_len);
319319

320-
for (i = 0; i < cf->cf_fcb.f_sector_cnt - 1; i++) {
320+
for (i = 0; i < cf->cf_fcb.f_sector_cnt; i++) {
321321
rc = fcb_append(&cf->cf_fcb, len, &loc.loc);
322322
if (rc != -ENOSPC) {
323323
break;
324324
}
325-
settings_fcb_compress(cf);
325+
326+
/* FCB can compress up to cf->cf_fcb.f_sector_cnt - 1 times. */
327+
if (i < (cf->cf_fcb.f_sector_cnt - 1)) {
328+
settings_fcb_compress(cf);
329+
}
326330
}
327331
if (rc) {
328332
return -EINVAL;

0 commit comments

Comments
 (0)