Skip to content
Permalink
Browse files

fs/nvs: skip deletion on non existing entry

No need to write deletion entry for non-existing entry.
Furthermore such a write to filled up storage will make another
writes impossible as it occupied delete nvs_ate space, but it
does not remove anything.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
  • Loading branch information...
nvlsianpu authored and carlescufi committed Aug 2, 2019
1 parent 369510a commit d1bd2490f371b99f45db04515464ed4e39ab6ef5
Showing with 8 additions and 0 deletions.
  1. +8 −0 subsys/fs/nvs/nvs.c
@@ -797,6 +797,9 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
if (len == 0) {
/* do not try to compare with empty data */
if (wlk_ate.len == 0U) {
/* skip delete entry as it is already the
* last one
*/
return 0;
}
} else {
@@ -806,6 +809,11 @@ ssize_t nvs_write(struct nvs_fs *fs, u16_t id, const void *data, size_t len)
return rc;
}
}
} else {
/* skip delete entry for non-existing entry */
if (len == 0) {
return 0;
}
}

/* calculate required space if the entry contains data */

0 comments on commit d1bd249

Please sign in to comment.
You can’t perform that action at this time.