Added assertions on inline size to btree inline code
This was missed when moving to use lfsr_data_t more. This is interesting conflict between implicit truncation in lfsr_data_read and strict assertions that inlined btree don't lose data. Found in the btree tests when, you guessed it, inlined btrees lost data. An alternative route would be to make btrees uninline when faced with an entry too big to inlined. This may be valuable future work, but probably depends on the file implementation to know if such a feature is useful.
This commit is contained in:
@@ -3543,6 +3543,7 @@ static lfs_ssize_t lfsr_btree_todisk(lfs_t *lfs, const lfsr_rbyd_t *btree,
|
||||
static int lfsr_data_readbtreeinlined(lfs_t *lfs, lfsr_data_t *data,
|
||||
lfsr_tag_t tag, lfs_size_t weight,
|
||||
lfsr_btree_t *btree) {
|
||||
LFS_ASSERT(lfsr_data_size(data) <= LFSR_BTREE_INLINESIZE);
|
||||
// mark as inlined
|
||||
btree->u.i.weight = lfsr_btree_setinlined(weight);
|
||||
btree->u.i.tag = tag;
|
||||
@@ -3794,6 +3795,8 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,
|
||||
// update our inlined tag, make sure to strip wide/grow bits
|
||||
if (lfsr_tag_suptype(lfsr_tag_key(attrs[i].tag))
|
||||
== LFSR_TAG_STRUCT) {
|
||||
LFS_ASSERT(lfsr_data_size(&attrs[i].data)
|
||||
<= LFSR_BTREE_INLINESIZE);
|
||||
btree->u.i.tag = lfsr_tag_key(attrs[i].tag);
|
||||
|
||||
lfsr_data_t data_ = attrs[i].data;
|
||||
|
||||
Reference in New Issue
Block a user