Skip to content

Commit 7c73965

Browse files
nvlsianpunashif
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. This is manual back-port of zephyrproject-rtos#25518 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 355ba2a commit 7c73965

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
@@ -260,12 +260,16 @@ static int settings_fcb_save(struct settings_store *cs, const char *name,
260260
wbs = cf->cf_fcb.f_align;
261261
len = settings_line_len_calc(name, val_len);
262262

263-
for (i = 0; i < cf->cf_fcb.f_sector_cnt - 1; i++) {
263+
for (i = 0; i < cf->cf_fcb.f_sector_cnt; i++) {
264264
rc = fcb_append(&cf->cf_fcb, len, &loc.loc);
265265
if (rc != FCB_ERR_NOSPACE) {
266266
break;
267267
}
268-
settings_fcb_compress(cf);
268+
269+
/* FCB can compress up to cf->cf_fcb.f_sector_cnt - 1 times. */
270+
if (i < (cf->cf_fcb.f_sector_cnt - 1)) {
271+
settings_fcb_compress(cf);
272+
}
269273
}
270274
if (rc) {
271275
return -EINVAL;

0 commit comments

Comments
 (0)