Reverted no trailing underscore_ for unconditional out-pointers
Maybe it's just habit, but the trailing underscores_ felt far more useful serving only as a out-pointer/new/biproduct hint. Having trailing underscores_ serve dual purposes as both a new/biproduct hint and optional hint just muddies things and makes the hint much less useful. No code changes.
This commit is contained in:
@@ -5257,10 +5257,10 @@ static int lfsr_data_fetchbtree(lfs_t *lfs, lfsr_data_t *data,
|
||||
// lookup rbyd/rid containing a given bid
|
||||
static int lfsr_btree_lookupleaf(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
lfsr_bid_t bid,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd, lfsr_srid_t *rid_,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_,
|
||||
lfsr_tag_t *tag_, lfsr_bid_t *weight_, lfsr_data_t *data_) {
|
||||
// descend down the btree looking for our bid
|
||||
*rbyd = *btree;
|
||||
*rbyd_ = *btree;
|
||||
lfsr_srid_t rid = bid;
|
||||
while (true) {
|
||||
// each branch is a pair of optional name + on-disk structure
|
||||
@@ -5270,7 +5270,7 @@ static int lfsr_btree_lookupleaf(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
lfsr_tag_t tag__;
|
||||
lfsr_rid_t weight__;
|
||||
lfsr_data_t data__;
|
||||
int err = lfsr_rbyd_lookupnext(lfs, rbyd, rid, 0,
|
||||
int err = lfsr_rbyd_lookupnext(lfs, rbyd_, rid, 0,
|
||||
&rid__, &tag__, &weight__, &data__);
|
||||
if (err) {
|
||||
return err;
|
||||
@@ -5278,7 +5278,7 @@ static int lfsr_btree_lookupleaf(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
|
||||
// if we found a bname, lookup the branch
|
||||
if (tag__ == LFSR_TAG_BNAME) {
|
||||
err = lfsr_rbyd_lookup(lfs, rbyd, rid__, LFSR_TAG_BRANCH,
|
||||
err = lfsr_rbyd_lookup(lfs, rbyd_, rid__, LFSR_TAG_BRANCH,
|
||||
&tag__, &data__);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
@@ -5293,7 +5293,7 @@ static int lfsr_btree_lookupleaf(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
|
||||
// fetch the next branch
|
||||
err = lfsr_data_fetchbranch(lfs, &data__, weight__,
|
||||
rbyd);
|
||||
rbyd_);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
@@ -5362,13 +5362,13 @@ static int lfsr_btree_lookup(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
// TODO should lfsr_btree_lookupnext/lfsr_btree_parent be deduplicated?
|
||||
static int lfsr_btree_parent(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
lfsr_bid_t bid, const lfsr_rbyd_t *child,
|
||||
lfsr_rbyd_t *rbyd, lfsr_srid_t *rid_) {
|
||||
lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_) {
|
||||
// we should only call this when we actually have parents
|
||||
LFS_ASSERT(bid < (lfsr_bid_t)btree->weight);
|
||||
LFS_ASSERT(lfsr_rbyd_cmp(btree, child) != 0);
|
||||
|
||||
// descend down the btree looking for our rid
|
||||
*rbyd = *btree;
|
||||
*rbyd_ = *btree;
|
||||
lfsr_srid_t rid = bid;
|
||||
while (true) {
|
||||
// each branch is a pair of optional name + on-disk structure
|
||||
@@ -5376,7 +5376,7 @@ static int lfsr_btree_parent(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
lfsr_tag_t tag__;
|
||||
lfsr_rid_t weight__;
|
||||
lfsr_data_t data__;
|
||||
int err = lfsr_rbyd_lookupnext(lfs, rbyd, rid, 0,
|
||||
int err = lfsr_rbyd_lookupnext(lfs, rbyd_, rid, 0,
|
||||
&rid__, &tag__, &weight__, &data__);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
@@ -5385,7 +5385,7 @@ static int lfsr_btree_parent(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
|
||||
// if we found a bname, lookup the branch
|
||||
if (tag__ == LFSR_TAG_BNAME) {
|
||||
err = lfsr_rbyd_lookup(lfs, rbyd, rid__, LFSR_TAG_BRANCH,
|
||||
err = lfsr_rbyd_lookup(lfs, rbyd_, rid__, LFSR_TAG_BRANCH,
|
||||
&tag__, &data__);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
@@ -5417,7 +5417,7 @@ static int lfsr_btree_parent(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = lfsr_branch_fetch(lfs, rbyd,
|
||||
err = lfsr_branch_fetch(lfs, rbyd_,
|
||||
child_.blocks[0], child_.trunk, child_.weight,
|
||||
child_.cksum);
|
||||
if (err) {
|
||||
@@ -6128,7 +6128,7 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,
|
||||
static lfs_scmp_t lfsr_btree_namelookupleaf(lfs_t *lfs,
|
||||
const lfsr_btree_t *btree,
|
||||
lfsr_did_t did, const char *name, lfs_size_t name_len,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd, lfsr_srid_t *rid_,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_,
|
||||
lfsr_tag_t *tag_, lfsr_bid_t *weight_, lfsr_data_t *data_) {
|
||||
// an empty tree?
|
||||
if (btree->weight == 0) {
|
||||
@@ -6136,7 +6136,7 @@ static lfs_scmp_t lfsr_btree_namelookupleaf(lfs_t *lfs,
|
||||
}
|
||||
|
||||
// descend down the btree looking for our name
|
||||
*rbyd = *btree;
|
||||
*rbyd_ = *btree;
|
||||
lfsr_bid_t bid = 0;
|
||||
while (true) {
|
||||
// each branch is a pair of optional name + on-disk structure
|
||||
@@ -6146,7 +6146,7 @@ static lfs_scmp_t lfsr_btree_namelookupleaf(lfs_t *lfs,
|
||||
lfsr_tag_t tag__;
|
||||
lfsr_rid_t weight__;
|
||||
lfsr_data_t data__;
|
||||
lfs_scmp_t cmp = lfsr_rbyd_namelookup(lfs, rbyd,
|
||||
lfs_scmp_t cmp = lfsr_rbyd_namelookup(lfs, rbyd_,
|
||||
did, name, name_len,
|
||||
&rid__, &tag__, &weight__, &data__);
|
||||
if (cmp < 0) {
|
||||
@@ -6156,7 +6156,7 @@ static lfs_scmp_t lfsr_btree_namelookupleaf(lfs_t *lfs,
|
||||
|
||||
// if we found a bname, lookup the branch
|
||||
if (tag__ == LFSR_TAG_BNAME) {
|
||||
int err = lfsr_rbyd_lookup(lfs, rbyd, rid__,
|
||||
int err = lfsr_rbyd_lookup(lfs, rbyd_, rid__,
|
||||
LFSR_TAG_MASK8 | LFSR_TAG_STRUCT,
|
||||
&tag__, &data__);
|
||||
if (err < 0) {
|
||||
@@ -6172,7 +6172,7 @@ static lfs_scmp_t lfsr_btree_namelookupleaf(lfs_t *lfs,
|
||||
|
||||
// fetch the next branch
|
||||
int err = lfsr_data_fetchbranch(lfs, &data__, weight__,
|
||||
rbyd);
|
||||
rbyd_);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
@@ -6586,10 +6586,10 @@ static lfs_ssize_t lfsr_bshrub_estimate(lfs_t *lfs,
|
||||
// bshrub lookup functions
|
||||
static int lfsr_bshrub_lookupleaf(lfs_t *lfs, const lfsr_bshrub_t *bshrub,
|
||||
lfsr_bid_t bid,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd, lfsr_srid_t *rid_,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_,
|
||||
lfsr_tag_t *tag_, lfsr_bid_t *weight_, lfsr_data_t *data_) {
|
||||
return lfsr_btree_lookupleaf(lfs, &bshrub->shrub, bid,
|
||||
bid_, rbyd, rid_, tag_, weight_, data_);
|
||||
bid_, rbyd_, rid_, tag_, weight_, data_);
|
||||
}
|
||||
|
||||
static int lfsr_bshrub_lookupnext(lfs_t *lfs, const lfsr_bshrub_t *bshrub,
|
||||
@@ -7673,7 +7673,7 @@ static inline lfsr_mid_t lfsr_mtree_weight(lfs_t *lfs) {
|
||||
|
||||
// lookup mdir containing a given mid
|
||||
static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
|
||||
lfsr_mdir_t *mdir) {
|
||||
lfsr_mdir_t *mdir_) {
|
||||
// looking up mid=-1 is probably a mistake
|
||||
LFS_ASSERT(mid >= 0);
|
||||
|
||||
@@ -7685,8 +7685,8 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
|
||||
// looking up mroot?
|
||||
if (lfs->mtree.weight == 0) {
|
||||
// treat inlined mdir as mid=0
|
||||
mdir->mid = mid;
|
||||
lfsr_mdir_sync(mdir, &lfs->mroot);
|
||||
mdir_->mid = mid;
|
||||
lfsr_mdir_sync(mdir_, &lfs->mroot);
|
||||
return 0;
|
||||
|
||||
// look up mdir in actual mtree
|
||||
@@ -7697,7 +7697,7 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
|
||||
lfsr_bid_t weight;
|
||||
lfsr_data_t data;
|
||||
int err = lfsr_btree_lookupleaf(lfs, &lfs->mtree, mid,
|
||||
&bid, &mdir->rbyd, &rid, &tag, &weight, &data);
|
||||
&bid, &mdir_->rbyd, &rid, &tag, &weight, &data);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
return err;
|
||||
@@ -7709,7 +7709,7 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
|
||||
|
||||
// if we found an mname, lookup the mdir
|
||||
if (tag == LFSR_TAG_MNAME) {
|
||||
err = lfsr_rbyd_lookup(lfs, &mdir->rbyd, rid, LFSR_TAG_MDIR,
|
||||
err = lfsr_rbyd_lookup(lfs, &mdir_->rbyd, rid, LFSR_TAG_MDIR,
|
||||
NULL, &data);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
@@ -7719,7 +7719,7 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
|
||||
|
||||
// fetch mdir
|
||||
return lfsr_data_fetchmdir(lfs, &data, mid,
|
||||
mdir);
|
||||
mdir_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8468,7 +8468,7 @@ compact:;
|
||||
}
|
||||
|
||||
static int lfsr_mroot_parent(lfs_t *lfs, const lfs_block_t mptr[static 2],
|
||||
lfsr_mdir_t *mparent) {
|
||||
lfsr_mdir_t *mparent_) {
|
||||
// we only call this when we actually have parents
|
||||
LFS_ASSERT(!lfsr_mptr_ismrootanchor(mptr));
|
||||
|
||||
@@ -8501,7 +8501,7 @@ static int lfsr_mroot_parent(lfs_t *lfs, const lfs_block_t mptr[static 2],
|
||||
|
||||
// found our child?
|
||||
if (lfsr_mptr_cmp(mptr_, mptr) == 0) {
|
||||
*mparent = mdir;
|
||||
*mparent_ = mdir;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -9181,12 +9181,12 @@ static int lfsr_mdir_namelookup(lfs_t *lfs, const lfsr_mdir_t *mdir,
|
||||
// if not found, rid will be the best place to insert
|
||||
static int lfsr_mtree_namelookup(lfs_t *lfs,
|
||||
lfsr_did_t did, const char *name, lfs_size_t name_len,
|
||||
lfsr_mdir_t *mdir, lfsr_tag_t *tag_, lfsr_data_t *data_) {
|
||||
lfsr_mdir_t *mdir_, lfsr_tag_t *tag_, lfsr_data_t *data_) {
|
||||
// do we only have mroot?
|
||||
if (lfs->mtree.weight == 0) {
|
||||
// treat inlined mdir as mid=0
|
||||
mdir->mid = 0;
|
||||
lfsr_mdir_sync(mdir, &lfs->mroot);
|
||||
mdir_->mid = 0;
|
||||
lfsr_mdir_sync(mdir_, &lfs->mroot);
|
||||
|
||||
// lookup name in actual mtree
|
||||
} else {
|
||||
@@ -9197,7 +9197,7 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
|
||||
lfsr_data_t data;
|
||||
lfs_scmp_t cmp = lfsr_btree_namelookupleaf(lfs, &lfs->mtree,
|
||||
did, name, name_len,
|
||||
&bid, &mdir->rbyd, &rid, &tag, &weight, &data);
|
||||
&bid, &mdir_->rbyd, &rid, &tag, &weight, &data);
|
||||
if (cmp < 0) {
|
||||
LFS_ASSERT(cmp != LFS_ERR_NOENT);
|
||||
return cmp;
|
||||
@@ -9208,7 +9208,7 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
|
||||
|
||||
// if we found an mname, lookup the mdir
|
||||
if (tag == LFSR_TAG_MNAME) {
|
||||
int err = lfsr_rbyd_lookup(lfs, &mdir->rbyd, rid, LFSR_TAG_MDIR,
|
||||
int err = lfsr_rbyd_lookup(lfs, &mdir_->rbyd, rid, LFSR_TAG_MDIR,
|
||||
NULL, &data);
|
||||
if (err) {
|
||||
LFS_ASSERT(err != LFS_ERR_NOENT);
|
||||
@@ -9218,7 +9218,7 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
|
||||
|
||||
// fetch mdir
|
||||
int err = lfsr_data_fetchmdir(lfs, &data, bid-((1 << lfs->mbits)-1),
|
||||
mdir);
|
||||
mdir_);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
@@ -9226,14 +9226,14 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
|
||||
|
||||
// and lookup name in our mdir
|
||||
lfsr_smid_t mid;
|
||||
int err = lfsr_mdir_namelookup(lfs, mdir, did, name, name_len,
|
||||
int err = lfsr_mdir_namelookup(lfs, mdir_, did, name, name_len,
|
||||
&mid, tag_, data_);
|
||||
if (err && err != LFS_ERR_NOENT) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// update mdir with best place to insert even if we fail
|
||||
mdir->mid = mid;
|
||||
mdir_->mid = mid;
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -9272,9 +9272,9 @@ static inline bool lfsr_path_isdir(const char *path) {
|
||||
// the parent
|
||||
//
|
||||
static int lfsr_mtree_pathlookup(lfs_t *lfs, const char **path,
|
||||
lfsr_mdir_t *mdir, lfsr_tag_t *tag_, lfsr_did_t *did_) {
|
||||
lfsr_mdir_t *mdir_, lfsr_tag_t *tag_, lfsr_did_t *did_) {
|
||||
// setup root
|
||||
*mdir = lfs->mroot;
|
||||
*mdir_ = lfs->mroot;
|
||||
lfsr_tag_t tag = LFSR_TAG_DIR;
|
||||
lfsr_did_t did = LFSR_DID_ROOT;
|
||||
|
||||
@@ -9349,9 +9349,9 @@ static int lfsr_mtree_pathlookup(lfs_t *lfs, const char **path,
|
||||
}
|
||||
|
||||
// read the next did from the mdir if this is not the root
|
||||
if (mdir->mid != -1) {
|
||||
if (mdir_->mid != -1) {
|
||||
lfsr_data_t data;
|
||||
int err = lfsr_mdir_lookup(lfs, mdir, LFSR_TAG_DID,
|
||||
int err = lfsr_mdir_lookup(lfs, mdir_, LFSR_TAG_DID,
|
||||
NULL, &data);
|
||||
if (err) {
|
||||
return err;
|
||||
@@ -9368,7 +9368,7 @@ static int lfsr_mtree_pathlookup(lfs_t *lfs, const char **path,
|
||||
|
||||
// lookup up this name in the mtree
|
||||
int err = lfsr_mtree_namelookup(lfs, did, path_, name_len,
|
||||
mdir, &tag, NULL);
|
||||
mdir_, &tag, NULL);
|
||||
if (err && err != LFS_ERR_NOENT) {
|
||||
return err;
|
||||
}
|
||||
@@ -11000,11 +11000,11 @@ int lfsr_dir_rewind(lfs_t *lfs, lfsr_dir_t *dir) {
|
||||
/// Custom attribute stuff ///
|
||||
|
||||
static int lfsr_lookupattr(lfs_t *lfs, const char *path, uint8_t type,
|
||||
lfsr_mdir_t *mdir, lfsr_data_t *data_) {
|
||||
lfsr_mdir_t *mdir_, lfsr_data_t *data_) {
|
||||
// lookup our entry
|
||||
lfsr_tag_t tag;
|
||||
int err = lfsr_mtree_pathlookup(lfs, &path,
|
||||
mdir, &tag, NULL);
|
||||
mdir_, &tag, NULL);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
@@ -11014,7 +11014,7 @@ static int lfsr_lookupattr(lfs_t *lfs, const char *path, uint8_t type,
|
||||
}
|
||||
|
||||
// lookup our attr
|
||||
err = lfsr_mdir_lookup(lfs, mdir, LFSR_TAG_ATTR(type),
|
||||
err = lfsr_mdir_lookup(lfs, mdir_, LFSR_TAG_ATTR(type),
|
||||
NULL, data_);
|
||||
if (err) {
|
||||
if (err == LFS_ERR_NOENT) {
|
||||
@@ -11512,13 +11512,13 @@ int lfsr_file_close(lfs_t *lfs, lfsr_file_t *file) {
|
||||
|
||||
static int lfsr_file_lookupleaf(lfs_t *lfs, const lfsr_file_t *file,
|
||||
lfsr_bid_t bid,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd, lfsr_srid_t *rid_,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_,
|
||||
lfsr_bid_t *weight_, lfsr_bptr_t *bptr) {
|
||||
lfsr_tag_t tag;
|
||||
lfsr_bid_t weight;
|
||||
lfsr_data_t data;
|
||||
int err = lfsr_bshrub_lookupleaf(lfs, &file->b, bid,
|
||||
bid_, rbyd, rid_, &tag, &weight, &data);
|
||||
bid_, rbyd_, rid_, &tag, &weight, &data);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user