Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-16 04:11:53 +0300
committerJunio C Hamano <gitster@pobox.com>2023-02-16 04:11:53 +0300
commitc5f7b2a6fe34bbdd4453be6620e08dbcf1b695fb (patch)
treebf9ee398bbb3180d0bbb2d63d5355446ef81f491 /builtin/pack-objects.c
parent063ec7b3b8ab5c13bb37f20e42ecdcc01614aea5 (diff)
parente65b868d074a38b3049529064bb05df53948761f (diff)
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()
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r--builtin/pack-objects.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3395f63aba..74a167a180 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -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))