Skip to content

Commit 37f9559

Browse files
committed
mass size_t conversion
Signed-off-by: Jeff King <[email protected]>
1 parent 68cb7f9 commit 37f9559

File tree

7 files changed

+27
-24
lines changed

7 files changed

+27
-24
lines changed

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
639639
}
640640

641641
while (tree_entry(tree, &entry)) {
642-
int te_len = tree_entry_len(&entry);
642+
size_t te_len = tree_entry_len(&entry);
643643

644644
if (match != all_entries_interesting) {
645645
strbuf_addstr(&name, base->buf + tn_len);

read-cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ int ie_modified(struct index_state *istate,
479479
return 0;
480480
}
481481

482-
static int cache_name_stage_compare(const char *name1, int len1, int stage1,
483-
const char *name2, int len2, int stage2)
482+
static int cache_name_stage_compare(const char *name1, size_t len1, int stage1,
483+
const char *name2, size_t len2, int stage2)
484484
{
485485
int cmp;
486486

tree-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void emit_path(struct combine_diff_path ***tail,
210210
unsigned short mode;
211211
const char *path;
212212
const struct object_id *oid;
213-
int pathlen;
213+
size_t pathlen;
214214
int old_baselen = base->len;
215215
int i, isdir, recurse = 0, emitthis = 1;
216216

tree-walk.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
1717
{
1818
const char *path;
19-
unsigned int len;
19+
size_t len;
2020
uint16_t mode;
2121
const unsigned hashsz = desc->algo->rawsz;
2222

@@ -260,7 +260,7 @@ struct tree_desc_x {
260260
struct tree_desc_skip *skip;
261261
};
262262

263-
static int check_entry_match(const char *a, int a_len, const char *b, int b_len)
263+
static int check_entry_match(const char *a, size_t a_len, const char *b, size_t b_len)
264264
{
265265
/*
266266
* The caller wants to pick *a* from a tree or nothing.
@@ -327,10 +327,10 @@ static int check_entry_match(const char *a, int a_len, const char *b, int b_len)
327327
static void extended_entry_extract(struct tree_desc_x *t,
328328
struct name_entry *a,
329329
const char *first,
330-
int first_len)
330+
size_t first_len)
331331
{
332332
const char *path;
333-
int len;
333+
size_t len;
334334
struct tree_desc probe;
335335
struct tree_desc_skip *skip;
336336

@@ -472,9 +472,9 @@ int traverse_trees(struct index_state *istate,
472472
int trees_used;
473473
unsigned long mask, dirmask;
474474
const char *first = NULL;
475-
int first_len = 0;
475+
size_t first_len = 0;
476476
struct name_entry *e = NULL;
477-
int len;
477+
size_t len;
478478

479479
for (i = 0; i < n; i++) {
480480
e = entry + i;
@@ -571,7 +571,8 @@ static int find_tree_entry(struct repository *r, struct tree_desc *t,
571571
while (t->size) {
572572
const char *entry;
573573
struct object_id oid;
574-
int entrylen, cmp;
574+
size_t entrylen;
575+
int cmp;
575576

576577
oidcpy(&oid, tree_entry_extract(t, &entry, mode));
577578
entrylen = tree_entry_len(&t->entry);
@@ -834,8 +835,8 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r,
834835
}
835836

836837
static int match_entry(const struct pathspec_item *item,
837-
const struct name_entry *entry, int pathlen,
838-
const char *match, int matchlen,
838+
const struct name_entry *entry, size_t pathlen,
839+
const char *match, size_t matchlen,
839840
enum interesting *never_interesting)
840841
{
841842
int m = -1; /* signals that we haven't called strncmp() */
@@ -926,10 +927,11 @@ static int match_entry(const struct pathspec_item *item,
926927

927928
/* :(icase)-aware string compare */
928929
static int basecmp(const struct pathspec_item *item,
929-
const char *base, const char *match, int len)
930+
const char *base, const char *match, size_t len)
930931
{
931932
if (item->magic & PATHSPEC_ICASE) {
932-
int ret, n = len > item->prefix ? item->prefix : len;
933+
int ret;
934+
size_t n = len > item->prefix ? item->prefix : len;
933935
ret = strncmp(base, match, n);
934936
if (ret)
935937
return ret;
@@ -942,7 +944,7 @@ static int basecmp(const struct pathspec_item *item,
942944

943945
static int match_dir_prefix(const struct pathspec_item *item,
944946
const char *base,
945-
const char *match, int matchlen)
947+
const char *match, size_t matchlen)
946948
{
947949
if (basecmp(item, base, match, matchlen))
948950
return 0;
@@ -1021,7 +1023,7 @@ static enum interesting do_match(struct index_state *istate,
10211023
int exclude)
10221024
{
10231025
int i;
1024-
int pathlen, baselen = base->len;
1026+
size_t pathlen, baselen = base->len;
10251027
enum interesting never_interesting = ps->has_wildcard ?
10261028
entry_not_interesting : all_entries_not_interesting;
10271029

tree-walk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct repository;
1616
struct name_entry {
1717
struct object_id oid;
1818
const char *path;
19-
int pathlen;
19+
size_t pathlen;
2020
unsigned int mode;
2121
};
2222

@@ -61,7 +61,7 @@ static inline const struct object_id *tree_entry_extract(struct tree_desc *desc,
6161
* memory structure of a tree entry to avoid the overhead of using a
6262
* generic strlen().
6363
*/
64-
static inline int tree_entry_len(const struct name_entry *ne)
64+
static inline size_t tree_entry_len(const struct name_entry *ne)
6565
{
6666
return ne->pathlen;
6767
}

tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int read_tree_at(struct repository *r,
2222
struct tree_desc desc;
2323
struct name_entry entry;
2424
struct object_id oid;
25-
int len, oldlen = base->len;
25+
size_t len, oldlen = base->len;
2626
enum interesting retval = entry_not_interesting;
2727

2828
if (depth > max_allowed_tree_depth)

unpack-trees.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static int do_compare_entry_piecewise(const struct cache_entry *ce,
967967
const char *name, size_t namelen,
968968
unsigned mode)
969969
{
970-
int pathlen, ce_len;
970+
size_t pathlen, ce_len;
971971
const char *ce_name;
972972

973973
if (info->prev) {
@@ -995,7 +995,7 @@ static int do_compare_entry(const struct cache_entry *ce,
995995
const char *name, size_t namelen,
996996
unsigned mode)
997997
{
998-
int pathlen, ce_len;
998+
size_t pathlen, ce_len;
999999
const char *ce_name;
10001000
int cmp;
10011001
unsigned ce_mode;
@@ -1280,12 +1280,13 @@ static int find_cache_pos(struct traverse_info *info,
12801280
int pos;
12811281
struct unpack_trees_options *o = info->data;
12821282
struct index_state *index = o->src_index;
1283-
int pfxlen = info->pathlen;
1283+
size_t pfxlen = info->pathlen;
12841284

12851285
for (pos = o->internal.cache_bottom; pos < index->cache_nr; pos++) {
12861286
const struct cache_entry *ce = index->cache[pos];
12871287
const char *ce_name, *ce_slash;
1288-
int cmp, ce_len;
1288+
int cmp;
1289+
size_t ce_len;
12891290

12901291
if (ce->ce_flags & CE_UNPACKED) {
12911292
/*

0 commit comments

Comments
 (0)