More bug fixes in MFS.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11020 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2017-11-16 15:09:53 +00:00
parent 6ff9fd4af9
commit 7d16de81a0
3 changed files with 13 additions and 8 deletions

View File

@ -196,6 +196,7 @@ static mfs_error_t mfs_flash_write(MFSDriver *mfsp,
return MFS_ERR_FLASH_FAILURE;
}
n -= chunk;
offset += (flash_offset_t)chunk;
wp += chunk;
}
#endif

View File

@ -534,14 +534,16 @@ remaining = (size_t)flashGetSectorOffset(mfscfg1.flashp, mfscfg1.bank0_start) +
(size_t)mfscfg1.bank_size - (size_t)mfs1.next_offset;
test_assert(remaining >= sizeof (mfs_data_header_t), "not enough space");
if (remaining > sizeof (mfs_data_header_t) * 2U) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS - 1U,
remaining - (sizeof (mfs_data_header_t) * 2U),
if (remaining > sizeof (mfs_data_header_t) * 2) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS,
remaining - (sizeof (mfs_data_header_t) * 2),
pattern512);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
}
else {
if (remaining == sizeof (mfs_data_header_t) * 2U) {
if (remaining == sizeof (mfs_data_header_t) * 2) {
err = mfsEraseRecord(&mfs1, 2);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
}

View File

@ -452,14 +452,16 @@ static void mfs_test_001_005_execute(void) {
(size_t)mfscfg1.bank_size - (size_t)mfs1.next_offset;
test_assert(remaining >= sizeof (mfs_data_header_t), "not enough space");
if (remaining > sizeof (mfs_data_header_t) * 2U) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS - 1U,
remaining - (sizeof (mfs_data_header_t) * 2U),
if (remaining > sizeof (mfs_data_header_t) * 2) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS,
remaining - (sizeof (mfs_data_header_t) * 2),
pattern512);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
}
else {
if (remaining == sizeof (mfs_data_header_t) * 2U) {
if (remaining == sizeof (mfs_data_header_t) * 2) {
err = mfsEraseRecord(&mfs1, 2);
test_assert(err == MFS_NO_ERROR, "error filling remaining space");
}