Skip to content

Commit 359f8c4

Browse files
committed
~Tidy up
1 parent ed3b0dc commit 359f8c4

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/fdb_tsdb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -973,16 +973,16 @@ fdb_err_t fdb_tsdb_init(fdb_tsdb_t db, const char *name, const char *path, fdb_g
973973

974974
/* check all sector header */
975975
sector_iterator(db, &sector, FDB_SECTOR_STORE_UNUSED, &check_sec_arg, NULL, check_sec_hdr_cb, true);
976-
if (db->parent.not_formatable && check_sec_arg.failed_count > 0) {
977-
result = FDB_READ_ERR;
978-
goto __exit;
979-
}
980-
/* all sector header check failed */
981-
if (check_sec_arg.failed_count == SECTOR_NUM) {
982-
FDB_INFO("All sector header is incorrect. Set it to default.\n");
983-
tsl_format_all(db);
984-
}
985-
else {
976+
/* format all sector when check failed */
977+
if ((check_sec_arg.failed_count > 0) &&
978+
((db->parent.format_bad_sec_only == false) || (db->parent.not_formatable))) {
979+
if (db->parent.not_formatable) {
980+
result = FDB_READ_ERR;
981+
goto __exit;
982+
} else {
983+
tsl_format_all(db);
984+
}
985+
} else {
986986
uint32_t latest_addr;
987987
if (check_sec_arg.empty_num > 0) {
988988
latest_addr = check_sec_arg.empty_addr;

0 commit comments

Comments
 (0)