summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarko Kiiskila <marko@runtime.io>2016-07-27 13:15:09 -0700
committerMarko Kiiskila <marko@runtime.io>2016-07-27 13:15:09 -0700
commit4240de7eabe00822cb3c5cf679b7131c1d9670c9 (patch)
treeb9026b5a985274269d520445a73aa929ed5c7819 /sys
parent140c373a6b001abda5f49e8f7550e39c2914d571 (diff)
fcb; calling fcb_rotate() when there is only one flash sector in FCB
was not wiping out the contents of that sector.
Diffstat (limited to 'sys')
-rw-r--r--sys/fcb/src/fcb_rotate.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/fcb/src/fcb_rotate.c b/sys/fcb/src/fcb_rotate.c
index 73724a95..7b6df585 100644
--- a/sys/fcb/src/fcb_rotate.c
+++ b/sys/fcb/src/fcb_rotate.c
@@ -31,6 +31,11 @@ fcb_rotate(struct fcb *fcb)
return FCB_ERR_ARGS;
}
+ rc = flash_area_erase(fcb->f_oldest, 0, fcb->f_oldest->fa_size);
+ if (rc) {
+ rc = FCB_ERR_FLASH;
+ goto out;
+ }
if (fcb->f_oldest == fcb->f_active.fe_area) {
/*
* Need to create a new active area, as we're wiping the current.
@@ -44,11 +49,6 @@ fcb_rotate(struct fcb *fcb)
fcb->f_active.fe_elem_off = sizeof(struct fcb_disk_area);
fcb->f_active_id++;
}
- rc = flash_area_erase(fcb->f_oldest, 0, fcb->f_oldest->fa_size);
- if (rc) {
- rc = FCB_ERR_FLASH;
- goto out;
- }
fcb->f_oldest = fcb_getnext_area(fcb, fcb->f_oldest);
out:
os_mutex_release(&fcb->f_mtx);