Skip to content

Conversation

blocksebastian
Copy link
Contributor

fcb2_sector_find_last does not return or break while loop if an error occured during read

}
loc->fe_entry_num++;
} while (1);
} while (rc == 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endless loop was supposed to handle cases where FCB2 had corrupted entries (most likely CRC for broken writes).
I guess then in your case, due to some flash read error, loop would not finish.
FCB2 sector starts with header fcb2_disk_area; data is stored in flash after the header starting from the beginning while entries holding CRC and data position and length are stored starting from the end of the sector.
When read error occurs fe_entry_num should be increased like it is right now but some sanity check should be performed to see if probably entry does not reach to occupied space or header if read error persist.
I guess similar check is done when new data is being written to FCB and there is not space for data+entry.
Proposed solution does not cover case where there are some errors in flash that could be recovered.

last_valid = loc->fe_entry_num;
}
if (rc == FCB2_ERR_NOVAR) {
else if (rc == FCB2_ERR_NOVAR) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else should be in previous line to keep coding style presistant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants