Skip to content

Commit

Permalink
Renamed name_size -> name_len
Browse files Browse the repository at this point in the history
This is to be consistent with name_len/lfsr_path_namelen in
lfsr_mtree_pathlookup, and ultimately C's strlen.
  • Loading branch information
geky committed Dec 20, 2024
1 parent aa3be97 commit a07544c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ static lfs_scmp_t lfsr_data_cmp(lfs_t *lfs, lfsr_data_t data,
}

static lfs_scmp_t lfsr_data_namecmp(lfs_t *lfs, lfsr_data_t data,
lfsr_did_t did, const char *name, lfs_size_t name_size) {
lfsr_did_t did, const char *name, lfs_size_t name_len) {
// first compare the did
lfsr_did_t did_;
int err = lfsr_data_readleb128(lfs, &data, &did_);
Expand All @@ -2169,7 +2169,7 @@ static lfs_scmp_t lfsr_data_namecmp(lfs_t *lfs, lfsr_data_t data,
}

// then compare the actual name
return lfsr_data_cmp(lfs, data, name, name_size);
return lfsr_data_cmp(lfs, data, name, name_len);
}

static int lfsr_bd_progdata(lfs_t *lfs,
Expand Down Expand Up @@ -2375,17 +2375,17 @@ static inline lfs_size_t lfsr_rattr_size(lfsr_rattr_t rattr) {
// full lfsr_data_t
typedef struct lfsr_data_name {
lfsr_data_t did_data;
lfs_size_t name_size;
lfs_size_t name_len;
const uint8_t *name;
} lfsr_data_name_t;

#define LFSR_RATTR_NAME(_tag, _weight, _did, _name, _name_size) \
#define LFSR_RATTR_NAME(_tag, _weight, _did, _name, _name_len) \
LFSR_RATTR_CAT_( \
_tag, \
_weight, \
((lfsr_data_t*)&(lfsr_data_name_t){ \
.did_data=LFSR_DATA_LEB128(_did), \
.name_size=_name_size, \
.name_len=_name_len, \
.name=(const void*)(_name)}), \
2)

Expand Down Expand Up @@ -5004,7 +5004,7 @@ static int lfsr_rbyd_appendshrub(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// binary search an rbyd for a name, leaving the rid_/tag_/weight_/data_
// with the best matching name if not found
static lfs_scmp_t lfsr_rbyd_namelookup(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
lfsr_did_t did, const char *name, lfs_size_t name_size,
lfsr_did_t did, const char *name, lfs_size_t name_len,
lfsr_srid_t *rid_,
lfsr_tag_t *tag_, lfsr_rid_t *weight_, lfsr_data_t *data_) {
// empty rbyd? leave it up to upper layers to handle this
Expand Down Expand Up @@ -5037,7 +5037,7 @@ static lfs_scmp_t lfsr_rbyd_namelookup(lfs_t *lfs, const lfsr_rbyd_t *rbyd,

// compare names
} else {
cmp = lfsr_data_namecmp(lfs, data__, did, name, name_size);
cmp = lfsr_data_namecmp(lfs, data__, did, name, name_len);
if (cmp < 0) {
return cmp;
}
Expand Down Expand Up @@ -6098,7 +6098,7 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,

// lookup in a btree by name
static lfs_scmp_t lfsr_btree_namelookup(lfs_t *lfs, const lfsr_btree_t *btree,
lfsr_did_t did, const char *name, lfs_size_t name_size,
lfsr_did_t did, const char *name, lfs_size_t name_len,
lfsr_bid_t *bid_,
lfsr_tag_t *tag_, lfsr_bid_t *weight_, lfsr_data_t *data_) {
// an empty tree?
Expand All @@ -6114,7 +6114,7 @@ static lfs_scmp_t lfsr_btree_namelookup(lfs_t *lfs, const lfsr_btree_t *btree,
lfsr_srid_t rid__;
lfsr_rid_t weight__;
lfs_scmp_t cmp = lfsr_rbyd_namelookup(lfs, &branch,
did, name, name_size,
did, name, name_len,
&rid__, NULL, &weight__, NULL);
if (cmp < 0) {
LFS_ASSERT(cmp != LFS_ERR_NOENT);
Expand Down Expand Up @@ -9381,7 +9381,7 @@ static int lfsr_mdir_compact(lfs_t *lfs, lfsr_mdir_t *mdir) {
//
// if not found, rid will be the best place to insert
static int lfsr_mdir_namelookup(lfs_t *lfs, const lfsr_mdir_t *mdir,
lfsr_did_t did, const char *name, lfs_size_t name_size,
lfsr_did_t did, const char *name, lfs_size_t name_len,
lfsr_smid_t *mid_, lfsr_tag_t *tag_, lfsr_data_t *data_) {
// default to mid_ = 0, this blanket assignment is the only way to
// keep GCC happy
Expand All @@ -9397,7 +9397,7 @@ static int lfsr_mdir_namelookup(lfs_t *lfs, const lfsr_mdir_t *mdir,
lfsr_srid_t rid;
lfsr_tag_t tag;
lfs_scmp_t cmp = lfsr_rbyd_namelookup(lfs, &mdir->rbyd,
did, name, name_size,
did, name, name_len,
&rid, &tag, NULL, data_);
if (cmp < 0) {
LFS_ASSERT(cmp != LFS_ERR_NOENT);
Expand Down Expand Up @@ -9433,7 +9433,7 @@ 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_size,
lfsr_did_t did, const char *name, lfs_size_t name_len,
lfsr_mdir_t *mdir_, lfsr_tag_t *tag_, lfsr_data_t *data_) {
// do we only have mroot?
lfsr_mdir_t mdir;
Expand All @@ -9456,7 +9456,7 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
lfsr_bid_t weight;
lfsr_data_t data;
lfs_scmp_t cmp = lfsr_btree_namelookup(lfs, &lfs->mtree.u.btree,
did, name, name_size,
did, name, name_len,
&bid, &tag, &weight, &data);
if (cmp < 0) {
LFS_ASSERT(cmp != LFS_ERR_NOENT);
Expand All @@ -9476,7 +9476,7 @@ static int lfsr_mtree_namelookup(lfs_t *lfs,
// and finally lookup name in our mdir
lfsr_smid_t mid;
int err = lfsr_mdir_namelookup(lfs, &mdir,
did, name, name_size,
did, name, name_len,
&mid, tag_, data_);
if (err && err != LFS_ERR_NOENT) {
return err;
Expand Down Expand Up @@ -10876,12 +10876,12 @@ static int lfsr_stat_(lfs_t *lfs, const lfsr_mdir_t *mdir,

// read the file name
LFS_ASSERT(lfsr_data_size(name) <= LFS_NAME_MAX);
lfs_ssize_t name_size = lfsr_data_read(lfs, &name,
lfs_ssize_t name_len = lfsr_data_read(lfs, &name,
info->name, LFS_NAME_MAX);
if (name_size < 0) {
return name_size;
if (name_len < 0) {
return name_len;
}
info->name[name_size] = '\0';
info->name[name_len] = '\0';

// get file size if we're a regular file, this gets a bit messy
// because of the different file representations
Expand Down

0 comments on commit a07544c

Please sign in to comment.