Prefer function-like macros when the result is a struct

This commit is contained in:
Christopher Haster
2023-09-14 13:35:49 -05:00
parent 518e9634e7
commit d44f9bdcd0
3 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -4350,7 +4350,7 @@ typedef struct lfsr_btree_traversal {
lfsr_rbyd_t branch;
} lfsr_btree_traversal_t;
#define LFSR_BTREE_TRAVERSAL \
#define LFSR_BTREE_TRAVERSAL() \
((lfsr_btree_traversal_t){ \
.bid=0, \
.rid=0, \
@@ -4504,7 +4504,7 @@ static int lfsr_btree_traversal_next(lfs_t *lfs, const lfsr_btree_t *btree,
/// Metadata pair operations ///
// the mroot anchor, mdir 0x{0,1} is the entry point into the filesystem
#define LFSR_MBLOCKS_MROOTANCHOR ((const lfs_block_t[2]){0, 1})
#define LFSR_MBLOCKS_MROOTANCHOR() ((const lfs_block_t[2]){0, 1})
static inline int lfsr_mblocks_cmp(
const lfs_block_t a[static 2],
@@ -4767,8 +4767,8 @@ static int lfsr_mtree_parent(lfs_t *lfs, const lfs_block_t blocks[static 2],
// scan list of mroots for our requested pair
lfs_block_t blocks_[2] = {
LFSR_MBLOCKS_MROOTANCHOR[0],
LFSR_MBLOCKS_MROOTANCHOR[1]};
LFSR_MBLOCKS_MROOTANCHOR()[0],
LFSR_MBLOCKS_MROOTANCHOR()[1]};
while (true) {
// fetch next possible superblock
lfsr_mdir_t mdir;
@@ -5978,7 +5978,7 @@ static int lfsr_mtree_traversal_next(lfs_t *lfs,
if (traversal->mdir.u.m.trunk == 0) {
// fetch the first mroot 0x{0,1}
int err = lfsr_mdir_fetch(lfs, &traversal->mdir,
-1, LFSR_MBLOCKS_MROOTANCHOR);
-1, LFSR_MBLOCKS_MROOTANCHOR());
if (err) {
return err;
}
@@ -6084,7 +6084,7 @@ static int lfsr_mtree_traversal_next(lfs_t *lfs,
}
// initialize our mtree traversal
traversal->u.b.traversal = LFSR_BTREE_TRAVERSAL;
traversal->u.b.traversal = LFSR_BTREE_TRAVERSAL();
}
}
+2 -2
View File
@@ -4226,7 +4226,7 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8);
lfsr_btree_traversal_t traversal = LFSR_BTREE_TRAVERSAL;
lfsr_btree_traversal_t traversal = LFSR_BTREE_TRAVERSAL();
for (lfs_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops
@@ -4374,7 +4374,7 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8);
lfsr_btree_traversal_t traversal = LFSR_BTREE_TRAVERSAL;
lfsr_btree_traversal_t traversal = LFSR_BTREE_TRAVERSAL();
for (lfs_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops
+1 -1
View File
@@ -4246,7 +4246,7 @@ code = '''
uint8_t buf[LFSR_MDIR_DSIZE];
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1,
MROOT, 0, FROMMBLOCKS(&lfs, LFSR_MBLOCKS_MROOTANCHOR,
MROOT, 0, FROMMBLOCKS(&lfs, LFSR_MBLOCKS_MROOTANCHOR(),
buf)))) => 0;
// technically, cycle detection only needs to work when we're validating