Merge branch 'rs/size-t-fixes'

Type fixes.

* rs/size-t-fixes:
  pack-objects: use strcspn(3) in name_cmp_len()
  read-cache: use size_t for {base,df}_name_compare()
This commit is contained in:
Junio C Hamano 2023-02-15 17:11:53 -08:00
commit c5f7b2a6fe
3 changed files with 16 additions and 16 deletions

View File

@ -1710,17 +1710,14 @@ static void pbase_tree_put(struct pbase_tree_cache *cache)
free(cache);
}
static int name_cmp_len(const char *name)
static size_t name_cmp_len(const char *name)
{
int i;
for (i = 0; name[i] && name[i] != '\n' && name[i] != '/'; i++)
;
return i;
return strcspn(name, "\n/");
}
static void add_pbase_object(struct tree_desc *tree,
const char *name,
int cmplen,
size_t cmplen,
const char *fullname)
{
struct name_entry entry;
@ -1745,7 +1742,7 @@ static void add_pbase_object(struct tree_desc *tree,
struct tree_desc sub;
struct pbase_tree_cache *tree;
const char *down = name+cmplen+1;
int downlen = name_cmp_len(down);
size_t downlen = name_cmp_len(down);
tree = pbase_tree_get(&entry.oid);
if (!tree)
@ -1797,7 +1794,7 @@ static int check_pbase_path(unsigned hash)
static void add_preferred_base_object(const char *name)
{
struct pbase_tree *it;
int cmplen;
size_t cmplen;
unsigned hash = pack_name_hash(name);
if (!num_preferred_base || check_pbase_path(hash))

View File

@ -1623,8 +1623,10 @@ int repo_interpret_branch_name(struct repository *r,
int validate_headref(const char *ref);
int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
int base_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2);
int df_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2);
int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);

View File

@ -488,11 +488,11 @@ int ie_modified(struct index_state *istate,
return 0;
}
int base_name_compare(const char *name1, int len1, int mode1,
const char *name2, int len2, int mode2)
int base_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2)
{
unsigned char c1, c2;
int len = len1 < len2 ? len1 : len2;
size_t len = len1 < len2 ? len1 : len2;
int cmp;
cmp = memcmp(name1, name2, len);
@ -517,11 +517,12 @@ int base_name_compare(const char *name1, int len1, int mode1,
* This is used by routines that want to traverse the git namespace
* but then handle conflicting entries together when possible.
*/
int df_name_compare(const char *name1, int len1, int mode1,
const char *name2, int len2, int mode2)
int df_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2)
{
int len = len1 < len2 ? len1 : len2, cmp;
unsigned char c1, c2;
size_t len = len1 < len2 ? len1 : len2;
int cmp;
cmp = memcmp(name1, name2, len);
if (cmp)