{"thread":{"id":"58962","subject":"[PATCH] git: edit variable types to match what is assigned to them","startedAt":"2022-12-16T02:29:32Z","lastAt":"2023-03-15T19:10:09Z","messageCount":20,"participants":["Rose via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"469154","messageId":"pull.1399.git.git.1671157765711.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":null,"subject":"[PATCH] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-16T02:29:25Z","receivedAt":"2022-12-16T02:29:32Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t.\n\nNot to mention, this is poor logic,\nand needless truncations can add\nextra unneeded instructions.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v1\nPull-Request: https://github.com/git/git/pull/1399\n\n add-interactive.c |  2 +-\n apply.c           | 16 ++++++++--------\n base85.c          | 11 ++++++-----\n cache.h           | 13 ++++++++-----\n color.c           | 30 +++++++++++++++--------------\n color.h           |  2 +-\n column.c          |  7 ++++---\n diff.c            |  4 ++--\n read-cache.c      | 49 +++++++++++++++++++++++++----------------------\n 9 files changed, 72 insertions(+), 62 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/diff.c b/diff.c\nindex 1054a4b7329..5bcfce125e2 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n\nbase-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8\n-- \ngitgitgadget\n"},{"id":"469155","messageId":"xmqqa63onhou.fsf@gitster.g","threadId":"58962","inReplyTo":"pull.1399.git.git.1671157765711.gitgitgadget@gmail.com","subject":"Re: [PATCH] git: edit variable types to match what is assigned to them","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-16T03:36:17Z","receivedAt":"2022-12-16T03:36:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rose via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> diff --git a/add-interactive.c b/add-interactive.c\n> index ae1839c04a7..59ac88f8b5a 100644\n> --- a/add-interactive.c\n> +++ b/add-interactive.c\n> @@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n>  \n>  \tfor (i = 0; i < stat.nr; i++) {\n>  \t\tconst char *name = stat.files[i]->name;\n> -\t\tint hash = strhash(name);\n> +\t\tunsigned int hash = strhash(name);\n>  \t\tstruct pathname_entry *entry;\n>  \t\tstruct file_item *file_item;\n>  \t\tstruct adddel *adddel, *other_adddel;\n\nThis is unquestionably correct.  strhash() returns unsigned, and\nhash is passed to hashmap functions that expect unsigned.\n\n> diff --git a/apply.c b/apply.c\n> index bc338143134..ee5dcdb9133 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n>  /* remove double slashes to make --index work with such filenames */\n>  static char *squash_slash(char *name)\n>  {\n> -\tint i = 0, j = 0;\n> +\tsize_t i = 0, j = 0;\n>  \n>  \tif (!name)\n>  \t\treturn NULL;\n\nThese pointers are used to iterate over the same array from the\nbeginning to the end, so size_t is very much appropriate.\n\n> @@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n>  \t\t\t      const char *end,\n>  \t\t\t      int terminate)\n>  {\n> -\tint len;\n> +\tsize_t len;\n>  \tconst char *start = NULL;\n>  \n>  \tif (p_value == 0)\n> @@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n>  \t * or \"file~\").\n>  \t */\n>  \tif (def) {\n> -\t\tint deflen = strlen(def);\n> +\t\tsize_t deflen = strlen(def);\n>  \t\tif (deflen < len && !strncmp(start, def, deflen))\n>  \t\t\treturn squash_slash(xstrdup(def));\n>  \t}\n\nThe above look sensible as these two variables are to hold the\nresult from strlen().\n\n>  \tif (root->len) {\n> -\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n> +\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n\nThis rewrite is correct, but having to do this makes the careful use\nof (potentially larger) size_t more or less a moot point.  If the\nlength does not fit in \"int\", the returned pathname would not have\nthe correct contents.\n\n> @@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n>  \tconst char *timestamp = NULL, *cp, *colon;\n>  \tstatic regex_t *stamp;\n>  \tregmatch_t m[10];\n> -\tint zoneoffset, epoch_hour, hour, minute;\n> +\tlong zoneoffset, epoch_hour, hour, minute;\n>  \tint status;\n\nThis are not wrong per-se, but is not necessary.\n\nWe use strtol() at the beginning of a string to read into hour, but\nwe clamp the source digit string with regexp that begins with\n\"^[0-2][0-9]:([0-5][0-9]):00(\\\\.0+)?\" so unless your int is so small\nthat it cannot hold 29, the code should be safe.  The same holds for\nthe minute.  The latter part of the same regexp clamps the zone\noffset in a similar fashion and we won't feed a string longer than 4\ndecimal digits to strtol() to read the zone offset.\n\n> @@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n>  \t * and optional space with octal mode.\n>  \t */\n>  \tconst char *ptr, *eol;\n> -\tint len;\n> +\tsize_t len;\n>  \tconst unsigned hexsz = the_hash_algo->hexsz;\n\nAbsolutely correct.  The variable is used to hold a ptrdiff and is\nused to count number of bytes memcpy() should copy.\n\n> @@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n>  \t\t\t\t\"Files \",\n>  \t\t\t\tNULL,\n>  \t\t\t};\n> -\t\t\tint i;\n> +\t\t\tsize_t i;\n>  \t\t\tfor (i = 0; binhdr[i]; i++) {\n> -\t\t\t\tint len = strlen(binhdr[i]);\n> +\t\t\t\tsize_t len = strlen(binhdr[i]);\n>  \t\t\t\tif (len < size - hd &&\n>  \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n>  \t\t\t\t\tstate->linenr++;\n\nOK.  But I think there are bigger fish in the same function to fry\naround hdrsize and find_header(), both of which may want to become\nsize_t (I didn't look too carefully, though).\n\n> diff --git a/base85.c b/base85.c\n> index 5ca601ee14f..ad32ba1411a 100644\n> --- a/base85.c\n> +++ b/base85.c\n> @@ -37,14 +37,15 @@ static void prep_base85(void)\n>  \t}\n>  }\n>  \n> -int decode_85(char *dst, const char *buffer, int len)\n> +int decode_85(char *dst, const char *buffer, size_t len)\n>  {\n>  \tprep_base85();\n>  \n> -\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n> +\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n>  \twhile (len) {\n>  \t\tunsigned acc = 0;\n> -\t\tint de, cnt = 4;\n> +\t\tint de;\n> +\t\tsize_t cnt = 4;\n>  \t\tunsigned char ch;\n>  \t\tdo {\n>  \t\t\tch = *buffer++;\n\nCorrect.  The debug-only bits around say2() spoils the careful\ndebugging the same way as the \"len\" in find_name_common() we saw\nearlier, though\n\nI'd stop here for now.\n\nThanks.\n"},{"id":"469184","messageId":"pull.1399.v2.git.git.1671211155128.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.git.git.1671157765711.gitgitgadget@gmail.com","subject":"[PATCH v2] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-16T17:19:14Z","receivedAt":"2022-12-16T17:19:23Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t.\n\nNot to mention, this is poor logic,\nand needless truncations can add\nextra unneeded instructions.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v2\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v1:\n\n 1:  fd45b7f10a5 ! 1:  243cd53eebf git: edit variable types to match what is assigned to them\n     @@ apply.c: static int parse_chunk(struct apply_state *state, char *buffer, unsigne\n       \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n       \t\t\t\t\tstate->linenr++;\n      \n     + ## archive-tar.c ##\n     +@@ archive-tar.c: static void write_global_extended_header(struct archiver_args *args)\n     + }\n     + \n     + static struct archiver **tar_filters;\n     +-static int nr_tar_filters;\n     +-static int alloc_tar_filters;\n     ++static size_t nr_tar_filters;\n     ++static size_t alloc_tar_filters;\n     + \n     + static struct archiver *find_tar_filter(const char *name, size_t len)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < nr_tar_filters; i++) {\n     + \t\tstruct archiver *ar = tar_filters[i];\n     + \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n     +@@ archive-tar.c: static struct archiver tar_archiver = {\n     + \n     + void init_tar_archiver(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tregister_archiver(&tar_archiver);\n     + \n     + \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\n     +\n       ## base85.c ##\n      @@ base85.c: static void prep_base85(void)\n       \t}\n     @@ column.c: static void display_table(const struct string_list *list,\n       \n       \tmemset(&data, 0, sizeof(data));\n      \n     + ## compat/compiler.h ##\n     +@@\n     + \n     + static inline void get_compiler_info(struct strbuf *info)\n     + {\n     +-\tint len = info->len;\n     ++\tsize_t len = info->len;\n     ++\n     + #ifdef __clang__\n     + \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n     + #elif defined(__GNUC__)\n     +@@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n     + #endif\n     + \n     + #ifdef _MSC_VER\n     +-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n     +-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n     ++\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n     ++\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n     + #endif\n     + \n     + \tif (len == info->len)\n     +@@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n     + \n     + static inline void get_libc_info(struct strbuf *info)\n     + {\n     +-\tint len = info->len;\n     ++\tsize_t len = info->len;\n     + \n     + #ifdef __GLIBC__\n     + \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\n     +\n       ## diff.c ##\n      @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t/* emit data encoded in base85 */\n\n\n add-interactive.c |  2 +-\n apply.c           | 16 ++++++++--------\n archive-tar.c     |  8 ++++----\n base85.c          | 11 ++++++-----\n cache.h           | 13 ++++++++-----\n color.c           | 30 +++++++++++++++--------------\n color.h           |  2 +-\n column.c          |  7 ++++---\n compat/compiler.h |  9 +++++----\n diff.c            |  4 ++--\n read-cache.c      | 49 +++++++++++++++++++++++++----------------------\n 11 files changed, 81 insertions(+), 70 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 1054a4b7329..5bcfce125e2 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n\nbase-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8\n-- \ngitgitgadget\n"},{"id":"469188","messageId":"pull.1399.v3.git.git.1671228557381.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v2.git.git.1671211155128.gitgitgadget@gmail.com","subject":"[PATCH v3] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-16T22:09:16Z","receivedAt":"2022-12-16T22:09:32Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t.\n\nNot to mention, this is poor logic,\nand needless truncations can add\nextra unneeded instructions.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v3\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v2:\n\n 1:  243cd53eebf ! 1:  6a79dd1909d git: edit variable types to match what is assigned to them\n     @@ base85.c: void encode_85(char *buf, const unsigned char *data, int bytes)\n       \t\t\tbuf[cnt] = en85[val];\n       \t\t}\n      \n     + ## builtin/add.c ##\n     +@@ builtin/add.c: struct update_callback_data {\n     + \n     + static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n     + {\n     +-\tint i, ret = 0;\n     ++\tunsigned int i;\n     ++\tint ret = 0;\n     + \n     + \tfor (i = 0; i < the_index.cache_nr; i++) {\n     + \t\tstruct cache_entry *ce = the_index.cache[i];\n     +\n     + ## builtin/merge-file.c ##\n     +@@ builtin/merge-file.c: int cmd_merge_file(int argc, const char **argv, const char *prefix)\n     + \tmmfile_t mmfs[3] = { 0 };\n     + \tmmbuffer_t result = { 0 };\n     + \txmparam_t xmp = { 0 };\n     +-\tint ret = 0, i = 0, to_stdout = 0;\n     ++\tint ret = 0, to_stdout = 0;\n     ++\tunsigned int i = 0;\n     + \tint quiet = 0;\n     + \tstruct option options[] = {\n     + \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\n     +\n     + ## builtin/submodule--helper.c ##\n     +@@ builtin/submodule--helper.c: static int module_list_compute(const char **argv,\n     + \t\t\t       struct pathspec *pathspec,\n     + \t\t\t       struct module_list *list)\n     + {\n     +-\tint i, result = 0;\n     ++\tunsigned int i;\n     ++\tint result = 0;\n     + \tchar *ps_matched = NULL;\n     + \n     + \tparse_pathspec(pathspec, 0,\n     +\n       ## cache.h ##\n      @@ cache.h: int repo_interpret_branch_name(struct repository *r,\n       \n     @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t\tdata_size -= bytes;\n       \t\tif (bytes <= 26)\n      \n     + ## fsck.c ##\n     +@@ fsck.c: static struct {\n     + \n     + static void prepare_msg_ids(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (msg_id_info[0].downcased)\n     + \t\treturn;\n     +@@ fsck.c: static void prepare_msg_ids(void)\n     + \t/* convert id_string to lower case, without underscores. */\n     + \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n     + \t\tconst char *p = msg_id_info[i].id_string;\n     +-\t\tint len = strlen(p);\n     ++\t\tsize_t len = strlen(p);\n     + \t\tchar *q = xmalloc(len);\n     + \n     + \t\tmsg_id_info[i].downcased = q;\n     +\n     + ## list-objects-filter-options.c ##\n     +@@ list-objects-filter-options.c: void list_objects_filter_copy(\n     + \tstruct list_objects_filter_options *dest,\n     + \tconst struct list_objects_filter_options *src)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* Copy everything. We will overwrite the pointers shortly. */\n     + \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\n     +\n     + ## merge-recursive.c ##\n     +@@ merge-recursive.c: static struct commit *get_ref(struct repository *repo,\n     + int merge_recursive_generic(struct merge_options *opt,\n     + \t\t\t    const struct object_id *head,\n     + \t\t\t    const struct object_id *merge,\n     +-\t\t\t    int num_merge_bases,\n     ++\t\t\t    unsigned int num_merge_bases,\n     + \t\t\t    const struct object_id **merge_bases,\n     + \t\t\t    struct commit **result)\n     + {\n     +@@ merge-recursive.c: int merge_recursive_generic(struct merge_options *opt,\n     + \tstruct commit_list *ca = NULL;\n     + \n     + \tif (merge_bases) {\n     +-\t\tint i;\n     ++\t\tunsigned int i;\n     + \t\tfor (i = 0; i < num_merge_bases; ++i) {\n     + \t\t\tstruct commit *base;\n     + \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\n     +\n     + ## merge-recursive.h ##\n     +@@ merge-recursive.h: int merge_recursive(struct merge_options *opt,\n     + int merge_recursive_generic(struct merge_options *opt,\n     + \t\t\t    const struct object_id *head,\n     + \t\t\t    const struct object_id *merge,\n     +-\t\t\t    int num_merge_bases,\n     ++\t\t\t    unsigned int num_merge_bases,\n     + \t\t\t    const struct object_id **merge_bases,\n     + \t\t\t    struct commit **result);\n     + \n     +\n     + ## notes.c ##\n     +@@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n     + {\n     + \tstruct string_list split = STRING_LIST_INIT_NODUP;\n     + \tchar *globs_copy = xstrdup(globs);\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n     + \tstring_list_remove_empty_items(&split, 0);\n     +\n       ## read-cache.c ##\n      @@ read-cache.c: static struct mem_pool *find_mem_pool(struct index_state *istate)\n       \n     @@ read-cache.c: int repo_read_index_unmerged(struct repository *repo)\n       \n       \t\tif (!ce_stage(ce))\n       \t\t\tcontinue;\n     +\n     + ## run-command.c ##\n     +@@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n     + \t\t\t     const struct run_process_parallel_opts *opts,\n     + \t\t\t     int output_timeout)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     +-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n     ++\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n     + \t\tif (errno == EINTR)\n     + \t\t\tcontinue;\n     + \t\tpp_cleanup(pp, opts);\n     +@@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n     + \t}\n     + \n     + \t/* Buffer output from all pipes. */\n     +-\tfor (size_t i = 0; i < opts->processes; i++) {\n     ++\tfor (i = 0; i < opts->processes; i++) {\n     + \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n     + \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n     +-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n     +-\t\t\t\t\t\t pp->children[i].process.err, 0);\n     ++\t\t\tssize_t n = strbuf_read_once(\n     ++\t\t\t\t&pp->children[i].err,\n     ++\t\t\t\tpp->children[i].process.err, 0);\n     + \t\t\tif (n == 0) {\n     + \t\t\t\tclose(pp->children[i].process.err);\n     + \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\n     +\n     + ## xdiff-interface.c ##\n     +@@ xdiff-interface.c: static long ff_regexp(const char *line, long len,\n     + {\n     + \tstruct ff_regs *regs = priv;\n     + \tregmatch_t pmatch[2];\n     +-\tint i;\n     +-\tint result;\n     ++\tsize_t i;\n     ++\tlong result;\n     + \n     + \t/* Exclude terminating newline (and cr) from matching */\n     + \tif (len > 0 && line[len-1] == '\\n') {\n     +@@ xdiff-interface.c: static long ff_regexp(const char *line, long len,\n     + \n     + void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct ff_regs *regs;\n     + \n     + \txecfg->find_func = ff_regexp;\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 21 files changed, 103 insertions(+), 88 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 1054a4b7329..5bcfce125e2 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 48b9ba6d6f0..c46e7331b1d 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8\n-- \ngitgitgadget\n"},{"id":"469197","messageId":"xmqqmt7mkisx.fsf@gitster.g","threadId":"58962","inReplyTo":"pull.1399.v3.git.git.1671228557381.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] git: edit variable types to match what is assigned to them","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-16T23:52:46Z","receivedAt":"2022-12-16T23:52:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rose via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Seija Kijin <doremylover123@gmail.com>\n>\n> There are many places where \"int len = strlen(foo);\" is written,\n> just for len to be passed as a parameter of size_t.\n\nTrue.\n\n> This causes truncation and then expansion\n> back from int to size_t.\n>\n> Not to mention, this is poor logic,\n> and needless truncations can add\n> extra unneeded instructions.\n\nI'd omit the last paragraph if I were writing it, as these two\nparagraphs saying exactly the same thing.\n"},{"id":"469422","messageId":"pull.1399.v4.git.git.1671598870906.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v3.git.git.1671228557381.gitgitgadget@gmail.com","subject":"[PATCH v4] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T05:01:10Z","receivedAt":"2022-12-21T05:01:21Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v4\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v3:\n\n 1:  6a79dd1909d ! 1:  e4af173fccc git: edit variable types to match what is assigned to them\n     @@ Commit message\n          just for len to be passed as a parameter of size_t.\n      \n          This causes truncation and then expansion\n     -    back from int to size_t.\n     -\n     -    Not to mention, this is poor logic,\n     -    and needless truncations can add\n     -    extra unneeded instructions.\n     +    back from int to size_t. This is poor logic.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 21 files changed, 103 insertions(+), 88 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469499","messageId":"pull.1399.v5.git.git.1671823593187.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v4.git.git.1671598870906.gitgitgadget@gmail.com","subject":"[PATCH v5] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:26:32Z","receivedAt":"2022-12-23T19:26:43Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v5\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v4:\n\n 1:  e4af173fccc ! 1:  d0fb60496c6 git: edit variable types to match what is assigned to them\n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n       \tstring_list_remove_empty_items(&split, 0);\n      \n     + ## range-diff.c ##\n     +@@ range-diff.c: int is_range_diff_range(const char *arg)\n     + {\n     + \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n     + \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n     +-\tint i, positive = 0, negative = 0;\n     ++\tunsigned int i, positive = 0, negative = 0;\n     + \tstruct rev_info revs;\n     + \n     + \tinit_revisions(&revs, NULL);\n     +@@ range-diff.c: int is_range_diff_range(const char *arg)\n     + \n     + \tfree(copy);\n     + \trelease_revisions(&revs);\n     +-\treturn negative > 0 && positive > 0;\n     ++\treturn negative != 0 && positive != 0;\n     + }\n     +\n       ## read-cache.c ##\n      @@ read-cache.c: static struct mem_pool *find_mem_pool(struct index_state *istate)\n       \n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  |  4 +--\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 22 files changed, 105 insertions(+), 90 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..6d81d820e65 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -578,7 +578,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +599,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469500","messageId":"pull.1399.v6.git.git.1671824140973.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v5.git.git.1671823593187.gitgitgadget@gmail.com","subject":"[PATCH v6] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:35:40Z","receivedAt":"2022-12-23T19:35:52Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v6\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v5:\n\n 1:  d0fb60496c6 ! 1:  5fe5b2890a0 git: edit variable types to match what is assigned to them\n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \tstring_list_remove_empty_items(&split, 0);\n      \n       ## range-diff.c ##\n     +@@ range-diff.c: struct patch_util {\n     + \tstruct hashmap_entry e;\n     + \tconst char *diff, *patch;\n     + \n     +-\tint i, shown;\n     ++\tsize_t i;\n     ++\tint shown;\n     + \tint diffsize;\n     + \tsize_t diff_offset;\n     + \t/* the index of the matching item in the other branch, or -1 */\n     +@@ range-diff.c: static int patch_util_cmp(const void *cmp_data UNUSED,\n     + static void find_exact_matches(struct string_list *a, struct string_list *b)\n     + {\n     + \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* First, add the patches of a to a hash map */\n     + \tfor (i = 0; i < a->nr; i++) {\n      @@ range-diff.c: int is_range_diff_range(const char *arg)\n       {\n       \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  |  9 ++++---\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 22 files changed, 108 insertions(+), 92 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..d6a54eb756c 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -18,7 +18,8 @@ struct patch_util {\n \tstruct hashmap_entry e;\n \tconst char *diff, *patch;\n \n-\tint i, shown;\n+\tsize_t i;\n+\tint shown;\n \tint diffsize;\n \tsize_t diff_offset;\n \t/* the index of the matching item in the other branch, or -1 */\n@@ -235,7 +236,7 @@ static int patch_util_cmp(const void *cmp_data UNUSED,\n static void find_exact_matches(struct string_list *a, struct string_list *b)\n {\n \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n-\tint i;\n+\tsize_t i;\n \n \t/* First, add the patches of a to a hash map */\n \tfor (i = 0; i < a->nr; i++) {\n@@ -578,7 +579,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +600,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469501","messageId":"pull.1399.v7.git.git.1671824426074.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v6.git.git.1671824140973.gitgitgadget@gmail.com","subject":"[PATCH v7] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:40:25Z","receivedAt":"2022-12-23T19:40:34Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v7\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v6:\n\n 1:  5fe5b2890a0 ! 1:  8da0c61e544 git: edit variable types to match what is assigned to them\n     @@ range-diff.c: static int patch_util_cmp(const void *cmp_data UNUSED,\n       \n       \t/* First, add the patches of a to a hash map */\n       \tfor (i = 0; i < a->nr; i++) {\n     +@@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n     + \tif (!a_util)\n     + \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n     + \telse\n     +-\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n     ++\t\tstrbuf_addf(buf, \"%*lu:  %s \", patch_no_width, a_util->i + 1,\n     + \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n     + \n     + \tif (status == '!')\n     +@@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n     + \tif (!b_util)\n     + \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n     + \telse\n     +-\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n     ++\t\tstrbuf_addf(buf, \" %*lu:  %s\", patch_no_width, b_util->i + 1,\n     + \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n     + \n     + \tcommit = lookup_commit_reference(the_repository, oid);\n      @@ range-diff.c: int is_range_diff_range(const char *arg)\n       {\n       \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  | 13 +++++-----\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 22 files changed, 110 insertions(+), 94 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..e7c8c6d9deb 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -18,7 +18,8 @@ struct patch_util {\n \tstruct hashmap_entry e;\n \tconst char *diff, *patch;\n \n-\tint i, shown;\n+\tsize_t i;\n+\tint shown;\n \tint diffsize;\n \tsize_t diff_offset;\n \t/* the index of the matching item in the other branch, or -1 */\n@@ -235,7 +236,7 @@ static int patch_util_cmp(const void *cmp_data UNUSED,\n static void find_exact_matches(struct string_list *a, struct string_list *b)\n {\n \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n-\tint i;\n+\tsize_t i;\n \n \t/* First, add the patches of a to a hash map */\n \tfor (i = 0; i < a->nr; i++) {\n@@ -404,7 +405,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!a_util)\n \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n+\t\tstrbuf_addf(buf, \"%*lu:  %s \", patch_no_width, a_util->i + 1,\n \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n \n \tif (status == '!')\n@@ -416,7 +417,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!b_util)\n \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n+\t\tstrbuf_addf(buf, \" %*lu:  %s\", patch_no_width, b_util->i + 1,\n \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n \n \tcommit = lookup_commit_reference(the_repository, oid);\n@@ -578,7 +579,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +600,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469502","messageId":"pull.1399.v8.git.git.1671824586607.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v7.git.git.1671824426074.gitgitgadget@gmail.com","subject":"[PATCH v8] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:43:06Z","receivedAt":"2022-12-23T19:43:27Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v8\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v8\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v7:\n\n 1:  8da0c61e544 ! 1:  6d7410b6878 git: edit variable types to match what is assigned to them\n     @@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n       \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n       \telse\n      -\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n     -+\t\tstrbuf_addf(buf, \"%*lu:  %s \", patch_no_width, a_util->i + 1,\n     ++\t\tstrbuf_addf(buf, \"%*zu:  %s \", patch_no_width, a_util->i + 1,\n       \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n       \n       \tif (status == '!')\n     @@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n       \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n       \telse\n      -\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n     -+\t\tstrbuf_addf(buf, \" %*lu:  %s\", patch_no_width, b_util->i + 1,\n     ++\t\tstrbuf_addf(buf, \" %*zu:  %s\", patch_no_width, b_util->i + 1,\n       \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n       \n       \tcommit = lookup_commit_reference(the_repository, oid);\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  | 13 +++++-----\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n xdiff-interface.c             |  6 ++---\n 22 files changed, 110 insertions(+), 94 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..616285181dd 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -18,7 +18,8 @@ struct patch_util {\n \tstruct hashmap_entry e;\n \tconst char *diff, *patch;\n \n-\tint i, shown;\n+\tsize_t i;\n+\tint shown;\n \tint diffsize;\n \tsize_t diff_offset;\n \t/* the index of the matching item in the other branch, or -1 */\n@@ -235,7 +236,7 @@ static int patch_util_cmp(const void *cmp_data UNUSED,\n static void find_exact_matches(struct string_list *a, struct string_list *b)\n {\n \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n-\tint i;\n+\tsize_t i;\n \n \t/* First, add the patches of a to a hash map */\n \tfor (i = 0; i < a->nr; i++) {\n@@ -404,7 +405,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!a_util)\n \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n+\t\tstrbuf_addf(buf, \"%*zu:  %s \", patch_no_width, a_util->i + 1,\n \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n \n \tif (status == '!')\n@@ -416,7 +417,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!b_util)\n \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n+\t\tstrbuf_addf(buf, \" %*zu:  %s\", patch_no_width, b_util->i + 1,\n \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n \n \tcommit = lookup_commit_reference(the_repository, oid);\n@@ -578,7 +579,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +600,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469503","messageId":"pull.1399.v9.git.git.1671824812030.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v8.git.git.1671824586607.gitgitgadget@gmail.com","subject":"[PATCH v9] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:46:51Z","receivedAt":"2022-12-23T19:47:01Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v9\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v9\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v8:\n\n 1:  6d7410b6878 ! 1:  86aa007e7f2 git: edit variable types to match what is assigned to them\n     @@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n       \t\t\t\tclose(pp->children[i].process.err);\n       \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\n      \n     + ## strbuf.c ##\n     +@@ strbuf.c: struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n     + \tstruct strbuf *t;\n     + \n     + \twhile (slen) {\n     +-\t\tint len = slen;\n     ++\t\tsize_t len = slen;\n     + \t\tif (max <= 0 || nr + 1 < max) {\n     + \t\t\tconst char *end = memchr(str, terminator, slen);\n     + \t\t\tif (end)\n     +\n       ## xdiff-interface.c ##\n      @@ xdiff-interface.c: static long ff_regexp(const char *line, long len,\n       {\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  | 13 +++++-----\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n strbuf.c                      |  2 +-\n xdiff-interface.c             |  6 ++---\n 23 files changed, 111 insertions(+), 95 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..616285181dd 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -18,7 +18,8 @@ struct patch_util {\n \tstruct hashmap_entry e;\n \tconst char *diff, *patch;\n \n-\tint i, shown;\n+\tsize_t i;\n+\tint shown;\n \tint diffsize;\n \tsize_t diff_offset;\n \t/* the index of the matching item in the other branch, or -1 */\n@@ -235,7 +236,7 @@ static int patch_util_cmp(const void *cmp_data UNUSED,\n static void find_exact_matches(struct string_list *a, struct string_list *b)\n {\n \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n-\tint i;\n+\tsize_t i;\n \n \t/* First, add the patches of a to a hash map */\n \tfor (i = 0; i < a->nr; i++) {\n@@ -404,7 +405,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!a_util)\n \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n+\t\tstrbuf_addf(buf, \"%*zu:  %s \", patch_no_width, a_util->i + 1,\n \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n \n \tif (status == '!')\n@@ -416,7 +417,7 @@ static void output_pair_header(struct diff_options *diffopt,\n \tif (!b_util)\n \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n \telse\n-\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n+\t\tstrbuf_addf(buf, \" %*zu:  %s\", patch_no_width, b_util->i + 1,\n \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n \n \tcommit = lookup_commit_reference(the_repository, oid);\n@@ -578,7 +579,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +600,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex 0890b1405c5..3b500636eb1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469504","messageId":"pull.1399.v10.git.git.1671825145574.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v9.git.git.1671824812030.gitgitgadget@gmail.com","subject":"[PATCH v10] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:52:25Z","receivedAt":"2022-12-23T19:52:34Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v10\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v10\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v9:\n\n 1:  86aa007e7f2 ! 1:  869065779c0 git: edit variable types to match what is assigned to them\n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \tstring_list_remove_empty_items(&split, 0);\n      \n       ## range-diff.c ##\n     -@@ range-diff.c: struct patch_util {\n     - \tstruct hashmap_entry e;\n     - \tconst char *diff, *patch;\n     - \n     --\tint i, shown;\n     -+\tsize_t i;\n     -+\tint shown;\n     - \tint diffsize;\n     - \tsize_t diff_offset;\n     - \t/* the index of the matching item in the other branch, or -1 */\n     -@@ range-diff.c: static int patch_util_cmp(const void *cmp_data UNUSED,\n     - static void find_exact_matches(struct string_list *a, struct string_list *b)\n     - {\n     - \tstruct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);\n     --\tint i;\n     -+\tsize_t i;\n     - \n     - \t/* First, add the patches of a to a hash map */\n     - \tfor (i = 0; i < a->nr; i++) {\n     -@@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n     - \tif (!a_util)\n     - \t\tstrbuf_addf(buf, \"%*s:  %s \", patch_no_width, \"-\", dashes->buf);\n     - \telse\n     --\t\tstrbuf_addf(buf, \"%*d:  %s \", patch_no_width, a_util->i + 1,\n     -+\t\tstrbuf_addf(buf, \"%*zu:  %s \", patch_no_width, a_util->i + 1,\n     - \t\t\t    find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));\n     - \n     - \tif (status == '!')\n     -@@ range-diff.c: static void output_pair_header(struct diff_options *diffopt,\n     - \tif (!b_util)\n     - \t\tstrbuf_addf(buf, \" %*s:  %s\", patch_no_width, \"-\", dashes->buf);\n     - \telse\n     --\t\tstrbuf_addf(buf, \" %*d:  %s\", patch_no_width, b_util->i + 1,\n     -+\t\tstrbuf_addf(buf, \" %*zu:  %s\", patch_no_width, b_util->i + 1,\n     - \t\t\t    find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));\n     - \n     - \tcommit = lookup_commit_reference(the_repository, oid);\n      @@ range-diff.c: int is_range_diff_range(const char *arg)\n       {\n       \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  |  4 +--\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n strbuf.c                      |  2 +-\n xdiff-interface.c             |  6 ++---\n 23 files changed, 106 insertions(+), 91 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex ae1839c04a7..59ac88f8b5a 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex bc338143134..ee5dcdb9133 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 2c154cc3479..9981d8b271b 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 05f2c9bc985..2fb44987b90 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 07d40b0964b..ccbe88fcca4 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/diff.c b/diff.c\nindex 4dfe824c858..b2f57b168d9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8b7d81adc1b..6d81d820e65 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -578,7 +578,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -599,5 +599,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex 0890b1405c5..3b500636eb1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469631","messageId":"pull.1399.v11.git.git.1672328732375.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v10.git.git.1671825145574.gitgitgadget@gmail.com","subject":"[PATCH v11] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-29T15:45:31Z","receivedAt":"2022-12-29T15:45:41Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v11\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v11\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v10:\n\n 1:  869065779c0 ! 1:  ba551274887 git: edit variable types to match what is assigned to them\n     @@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n       #ifdef __GLIBC__\n       \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\n      \n     + ## daemon.c ##\n     +@@ daemon.c: static struct daemon_service daemon_service[] = {\n     + \n     + static void enable_service(const char *name, int ena)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n     + \t\tif (!strcmp(daemon_service[i].name, name)) {\n     + \t\t\tdaemon_service[i].enabled = ena;\n     +@@ daemon.c: static void enable_service(const char *name, int ena)\n     + \n     + static void make_service_overridable(const char *name, int ena)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n     + \t\tif (!strcmp(daemon_service[i].name, name)) {\n     + \t\t\tdaemon_service[i].overridable = ena;\n     +@@ daemon.c: static void canonicalize_client(struct strbuf *out, const char *in)\n     + static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n     + {\n     + \tchar *val;\n     +-\tint vallen;\n     ++\tsize_t vallen;\n     + \tchar *end = extra_args + buflen;\n     + \n     + \tif (extra_args < end && *extra_args) {\n     +\n       ## diff.c ##\n      @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t/* emit data encoded in base85 */\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n daemon.c                      |  6 ++---\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  |  4 +--\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n strbuf.c                      |  2 +-\n xdiff-interface.c             |  6 ++---\n 24 files changed, 109 insertions(+), 94 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..12cb87914f7 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex 85822280476..b409a323ca5 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0c604022676..5a6686d42dc 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6743fb27bd5..6583d755edc 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex fcf49706ad5..6f4d380e2e2 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..6fef18ecd8b 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\ndiff --git a/diff.c b/diff.c\nindex 9b14543e6ed..ffa9b599fc5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8255ab4349c..c65b6c81b53 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -582,7 +582,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -603,5 +603,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex 0890b1405c5..3b500636eb1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 6bae53b138a1f38d8887f6b46d17661357a1468b\n-- \ngitgitgadget\n"},{"id":"469633","messageId":"pull.1399.v12.git.git.1672330310586.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v11.git.git.1672328732375.gitgitgadget@gmail.com","subject":"[PATCH v12] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-29T16:11:50Z","receivedAt":"2022-12-29T16:12:04Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v12\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v12\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v11:\n\n 1:  ba551274887 ! 1:  7bcc1e37099 git: edit variable types to match what is assigned to them\n     @@ daemon.c: static void canonicalize_client(struct strbuf *out, const char *in)\n       \tchar *end = extra_args + buflen;\n       \n       \tif (extra_args < end && *extra_args) {\n     +@@ daemon.c: static void set_keep_alive(int sockfd)\n     + static int execute(void)\n     + {\n     + \tchar *line = packet_buffer;\n     +-\tint pktlen, len, i;\n     ++\tint pktlen, len;\n     ++\tsize_t i;\n     + \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n     + \tstruct hostinfo hi = HOSTINFO_INIT;\n     + \tstruct strvec env = STRVEC_INIT;\n     +@@ daemon.c: static int service_loop(struct socketlist *socklist)\n     + \tsignal(SIGCHLD, child_handler);\n     + \n     + \tfor (;;) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tcheck_dead_children();\n     + \n      \n       ## diff.c ##\n      @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 16 ++++++------\n archive-tar.c                 |  8 +++---\n base85.c                      | 11 ++++----\n builtin/add.c                 |  3 ++-\n builtin/merge-file.c          |  3 ++-\n builtin/submodule--helper.c   |  3 ++-\n cache.h                       | 13 ++++++----\n color.c                       | 30 +++++++++++----------\n color.h                       |  2 +-\n column.c                      |  7 ++---\n compat/compiler.h             |  9 ++++---\n daemon.c                      | 11 ++++----\n diff.c                        |  4 +--\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  |  4 +--\n read-cache.c                  | 49 +++++++++++++++++++----------------\n run-command.c                 | 11 ++++----\n strbuf.c                      |  2 +-\n xdiff-interface.c             |  6 ++---\n 24 files changed, 112 insertions(+), 96 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..12cb87914f7 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex 85822280476..b409a323ca5 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -2172,9 +2172,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0c604022676..5a6686d42dc 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6743fb27bd5..6583d755edc 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex fcf49706ad5..6f4d380e2e2 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..73e8ba48847 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1149,7 +1150,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/diff.c b/diff.c\nindex 9b14543e6ed..ffa9b599fc5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8255ab4349c..c65b6c81b53 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -582,7 +582,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -603,5 +603,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex 0890b1405c5..3b500636eb1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 6bae53b138a1f38d8887f6b46d17661357a1468b\n-- \ngitgitgadget\n"},{"id":"469772","messageId":"pull.1399.v13.git.git.1672767431037.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v12.git.git.1672330310586.gitgitgadget@gmail.com","subject":"[PATCH v13] git: edit variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-03T17:37:10Z","receivedAt":"2023-01-03T17:37:22Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: edit variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v13\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v13\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v12:\n\n 1:  7bcc1e37099 ! 1:  20febb0467b git: edit variable types to match what is assigned to them\n     @@ apply.c: static int has_epoch_timestamp(const char *nameline)\n       \tint status;\n       \n       \tfor (cp = nameline; *cp != '\\n'; cp++) {\n     +@@ apply.c: static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n     + \t\t\t\t const char *line,\n     + \t\t\t\t struct patch *patch)\n     + {\n     +-\tunsigned long val = strtoul(line, NULL, 10);\n     ++\tint val = atoi(line);\n     + \tif (val <= 100)\n     + \t\tpatch->score = val;\n     + \treturn 0;\n      @@ apply.c: static int gitdiff_index(struct gitdiff_data *state,\n       \t * and optional space with octal mode.\n       \t */\n     @@ apply.c: static int gitdiff_index(struct gitdiff_data *state,\n       \tconst unsigned hexsz = the_hash_algo->hexsz;\n       \n       \tptr = strchr(line, '.');\n     +@@ apply.c: static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n     +  * Skip p_value leading components from \"line\"; as we do not accept\n     +  * absolute paths, return NULL in that case.\n     +  */\n     +-static const char *skip_tree_prefix(int p_value,\n     +-\t\t\t\t    const char *line,\n     +-\t\t\t\t    int llen)\n     ++static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n     + {\n     + \tint nslash;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!p_value)\n     + \t\treturn (llen && line[0] == '/') ? NULL : line;\n     +@@ apply.c: static const char *skip_tree_prefix(int p_value,\n     +  * creation or deletion of an empty file.  In any of these cases,\n     +  * both sides are the same name under a/ and b/ respectively.\n     +  */\n     +-static char *git_header_name(int p_value,\n     +-\t\t\t     const char *line,\n     +-\t\t\t     int llen)\n     ++static char *git_header_name(int p_value, const char *line, size_t llen)\n     + {\n     + \tconst char *name;\n     + \tconst char *second = NULL;\n     +@@ apply.c: static int check_header_line(int linenr, struct patch *patch)\n     + \treturn 0;\n     + }\n     + \n     +-int parse_git_diff_header(struct strbuf *root,\n     +-\t\t\t  int *linenr,\n     +-\t\t\t  int p_value,\n     +-\t\t\t  const char *line,\n     +-\t\t\t  int len,\n     +-\t\t\t  unsigned int size,\n     ++int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n     ++\t\t\t  const char *line, size_t len, unsigned int size,\n     + \t\t\t  struct patch *patch)\n     + {\n     + \tunsigned long offset;\n     +@@ apply.c: int parse_git_diff_header(struct strbuf *root,\n     + \t\t\t{ \"index \", gitdiff_index },\n     + \t\t\t{ \"\", gitdiff_unrecognized },\n     + \t\t};\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tlen = linelen(line, size);\n     + \t\tif (!len || line[len-1] != '\\n')\n     + \t\t\tbreak;\n     + \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n     + \t\t\tconst struct opentry *p = optable + i;\n     +-\t\t\tint oplen = strlen(p->str);\n     ++\t\t\tsize_t oplen = strlen(p->str);\n     + \t\t\tint res;\n     + \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n     + \t\t\t\tcontinue;\n     +@@ apply.c: done:\n     + \t\t\t\t \"%d leading pathname components (line %d)\",\n     + \t\t\t\t parse_hdr_state.p_value),\n     + \t\t\t      parse_hdr_state.p_value, *linenr);\n     +-\t\t\treturn -128;\n     ++\t\t\treturn -1;\n     + \t\t}\n     + \t\tpatch->old_name = xstrdup(patch->def_name);\n     + \t\tpatch->new_name = xstrdup(patch->def_name);\n     +@@ apply.c: done:\n     + \t    (!patch->old_name && !patch->is_new)) {\n     + \t\terror(_(\"git diff header lacks filename information \"\n     + \t\t\t\"(line %d)\"), *linenr);\n     +-\t\treturn -128;\n     ++\t\treturn -1;\n     + \t}\n     + \tpatch->is_toplevel_relative = 1;\n     + \treturn offset;\n     +@@ apply.c: static int parse_range(const char *line, int len, int offset, const char *expect\n     + \treturn offset + ex;\n     + }\n     + \n     +-static void recount_diff(const char *line, int size, struct fragment *fragment)\n     ++static void recount_diff(const char *line, size_t size,\n     ++\t\t\t struct fragment *fragment)\n     + {\n     + \tint oldlines = 0, newlines = 0, ret = 0;\n     + \n     +-\tif (size < 1) {\n     ++\tif (size == 0) {\n     + \t\twarning(\"recount: ignore empty hunk\");\n     + \t\treturn;\n     + \t}\n     + \n     + \tfor (;;) {\n     +-\t\tint len = linelen(line, size);\n     +-\t\tsize -= len;\n     +-\t\tline += len;\n     ++\t\tsize_t len = linelen(line, size);\n     + \n     +-\t\tif (size < 1)\n     ++\t\tif (size <= len)\n     + \t\t\tbreak;\n     ++\t\tsize -= len;\n     ++\t\tline += len;\n     + \n     + \t\tswitch (*line) {\n     + \t\tcase ' ': case '\\n':\n      @@ apply.c: static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n       \t\t\t\t\"Files \",\n       \t\t\t\tNULL,\n     @@ apply.c: static int parse_chunk(struct apply_state *state, char *buffer, unsigne\n       \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n       \t\t\t\t\tstate->linenr++;\n      \n     + ## apply.h ##\n     +@@ apply.h: int check_apply_state(struct apply_state *state, int force_apply);\n     +  *\n     +  * Returns -1 on failure, the length of the parsed header otherwise.\n     +  */\n     +-int parse_git_diff_header(struct strbuf *root,\n     +-\t\t\t  int *linenr,\n     +-\t\t\t  int p_value,\n     +-\t\t\t  const char *line,\n     +-\t\t\t  int len,\n     +-\t\t\t  unsigned int size,\n     ++int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n     ++\t\t\t  const char *line, size_t len, unsigned int size,\n     + \t\t\t  struct patch *patch);\n     + \n     + void release_patch(struct patch *patch);\n     +\n       ## archive-tar.c ##\n      @@ archive-tar.c: static void write_global_extended_header(struct archiver_args *args)\n       }\n     @@ base85.c: void encode_85(char *buf, const unsigned char *data, int bytes)\n       \t\t\tbuf[cnt] = en85[val];\n       \t\t}\n      \n     + ## blame.c ##\n     +@@ blame.c: struct blame_list {\n     +  * and prepare a list of entry and the best split.\n     +  */\n     + static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n     +-\t\t\t\t\t   int *num_ents_p)\n     ++\t\t\t\t\t   size_t *num_ents_p)\n     + {\n     + \tstruct blame_entry *e;\n     +-\tint num_ents, i;\n     ++\tsize_t num_ents, i;\n     + \tstruct blame_list *blame_list = NULL;\n     + \n     + \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n     +@@ blame.c: static void find_copy_in_parent(struct blame_scoreboard *sb,\n     + \t\t\t\tint opt)\n     + {\n     + \tstruct diff_options diff_opts;\n     +-\tint i, j;\n     ++\tsize_t i, j;\n     + \tstruct blame_list *blame_list;\n     +-\tint num_ents;\n     ++\tsize_t num_ents;\n     + \tstruct blame_entry *unblamed = target->suspects;\n     + \tstruct blame_entry *leftover = NULL;\n     + \n     +@@ blame.c: static int prepare_lines(struct blame_scoreboard *sb)\n     + static struct commit *find_single_final(struct rev_info *revs,\n     + \t\t\t\t\tconst char **name_p)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct commit *found = NULL;\n     + \tconst char *name = NULL;\n     + \n     +@@ blame.c: static struct commit *dwim_reverse_initial(struct rev_info *revs,\n     + static struct commit *find_single_initial(struct rev_info *revs,\n     + \t\t\t\t\t  const char **name_p)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct commit *found = NULL;\n     + \tconst char *name = NULL;\n     + \n     +\n       ## builtin/add.c ##\n      @@ builtin/add.c: struct update_callback_data {\n       \n     @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t\tdata_size -= bytes;\n       \t\tif (bytes <= 26)\n      \n     + ## dir.c ##\n     +@@ dir.c: static void emit_traversal_statistics(struct dir_struct *dir,\n     + }\n     + \n     + int read_directory(struct dir_struct *dir, struct index_state *istate,\n     +-\t\t   const char *path, int len, const struct pathspec *pathspec)\n     ++\t\t   const char *path, unsigned int len, const struct pathspec *pathspec)\n     + {\n     + \tstruct untracked_cache_dir *untracked;\n     + \n     +\n     + ## dir.h ##\n     +@@ dir.h: int fill_directory(struct dir_struct *dir,\n     + \t\t   struct index_state *istate,\n     + \t\t   const struct pathspec *pathspec);\n     + int read_directory(struct dir_struct *, struct index_state *istate,\n     +-\t\t   const char *path, int len,\n     ++\t\t   const char *path, unsigned int len,\n     + \t\t   const struct pathspec *pathspec);\n     + \n     + enum pattern_match_result {\n     +\n       ## fsck.c ##\n      @@ fsck.c: static struct {\n       \n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \tstring_list_remove_empty_items(&split, 0);\n      \n       ## range-diff.c ##\n     +@@ range-diff.c: static int read_patches(const char *range, struct string_list *list,\n     + \tstruct patch_util *util = NULL;\n     + \tint in_header = 1;\n     + \tchar *line, *current_filename = NULL;\n     +-\tssize_t len;\n     ++\tsize_t len;\n     + \tsize_t size;\n     + \tint ret = -1;\n     + \n     +@@ range-diff.c: static int read_patches(const char *range, struct string_list *list,\n     + \t\t\tstruct patch patch = { 0 };\n     + \t\t\tstruct strbuf root = STRBUF_INIT;\n     + \t\t\tint linenr = 0;\n     +-\t\t\tint orig_len;\n     ++\t\t\tint orig_len, output;\n     + \n     + \t\t\tin_header = 0;\n     + \t\t\tstrbuf_addch(&buf, '\\n');\n     +@@ range-diff.c: static int read_patches(const char *range, struct string_list *list,\n     + \t\t\tif (eol)\n     + \t\t\t\t*eol = '\\n';\n     + \t\t\torig_len = len;\n     +-\t\t\tlen = parse_git_diff_header(&root, &linenr, 0, line,\n     +-\t\t\t\t\t\t    len, size, &patch);\n     +-\t\t\tif (len < 0) {\n     ++\t\t\toutput = parse_git_diff_header(&root, &linenr, 0, line,\n     ++\t\t\t\t\t\t       len, size, &patch);\n     ++\t\t\tif (output < 0) {\n     + \t\t\t\terror(_(\"could not parse git header '%.*s'\"),\n     + \t\t\t\t      orig_len, line);\n     + \t\t\t\tFREE_AND_NULL(util);\n     + \t\t\t\tstring_list_clear(list, 1);\n     + \t\t\t\tgoto cleanup;\n     + \t\t\t}\n     ++\t\t\tlen = output;\n     + \t\t\tstrbuf_addstr(&buf, \" ## \");\n     + \t\t\tif (patch.is_new > 0)\n     + \t\t\t\tstrbuf_addf(&buf, \"%s (new)\", patch.new_name);\n      @@ range-diff.c: int is_range_diff_range(const char *arg)\n       {\n       \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n     @@ strbuf.c: struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n       \t\t\tconst char *end = memchr(str, terminator, slen);\n       \t\t\tif (end)\n      \n     + ## strvec.h ##\n     +@@ strvec.h: extern const char *empty_strvec[];\n     +  */\n     + struct strvec {\n     + \tconst char **v;\n     +-\tsize_t nr;\n     ++\tint nr;\n     + \tsize_t alloc;\n     + };\n     + \n     +\n     + ## unpack-trees.c ##\n     +@@ unpack-trees.c: static int verify_clean_subdirectory(const struct cache_entry *ce,\n     + \t * we are about to extract \"ce->name\"; we would not want to lose\n     + \t * anything in the existing directory there.\n     + \t */\n     +-\tint namelen;\n     +-\tint i;\n     ++\tunsigned int namelen;\n     ++\tunsigned int i;\n     + \tstruct dir_struct d;\n     + \tchar *pathbuf;\n     + \tint cnt = 0;\n     +@@ unpack-trees.c: static int verify_clean_subdirectory(const struct cache_entry *ce,\n     + \t     i < o->src_index->cache_nr;\n     + \t     i++) {\n     + \t\tstruct cache_entry *ce2 = o->src_index->cache[i];\n     +-\t\tint len = ce_namelen(ce2);\n     ++\t\tunsigned int len = ce_namelen(ce2);\n     + \t\tif (len < namelen ||\n     + \t\t    strncmp(ce->name, ce2->name, namelen) ||\n     + \t\t    ce2->name[namelen] != '/')\n     +@@ unpack-trees.c: static int verify_clean_subdirectory(const struct cache_entry *ce,\n     + \t}\n     + \n     + \t/* Do not lose a locally present file that is not ignored. */\n     +-\tpathbuf = xstrfmt(\"%.*s/\", namelen, ce->name);\n     ++\tpathbuf = xstrfmt(\"%.*s/\", (int)namelen, ce->name);\n     + \n     + \tmemset(&d, 0, sizeof(d));\n     + \tif (o->dir)\n     +\n       ## xdiff-interface.c ##\n      @@ xdiff-interface.c: static long ff_regexp(const char *line, long len,\n       {\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 57 +++++++++++++++--------------------\n apply.h                       |  8 ++---\n archive-tar.c                 |  8 ++---\n base85.c                      | 11 ++++---\n blame.c                       | 12 ++++----\n builtin/add.c                 |  3 +-\n builtin/merge-file.c          |  3 +-\n builtin/submodule--helper.c   |  3 +-\n cache.h                       | 13 +++++---\n color.c                       | 30 +++++++++---------\n color.h                       |  2 +-\n column.c                      |  7 +++--\n compat/compiler.h             |  9 +++---\n daemon.c                      | 11 ++++---\n diff.c                        |  4 +--\n dir.c                         |  2 +-\n dir.h                         |  2 +-\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  | 15 ++++-----\n read-cache.c                  | 49 ++++++++++++++++--------------\n run-command.c                 | 11 ++++---\n strbuf.c                      |  2 +-\n strvec.h                      |  2 +-\n unpack-trees.c                |  8 ++---\n xdiff-interface.c             |  6 ++--\n 30 files changed, 150 insertions(+), 144 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..12cb87914f7 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex 85822280476..a5dc7c46ae8 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1068,7 +1068,7 @@ static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n \t\t\t\t const char *line,\n \t\t\t\t struct patch *patch)\n {\n-\tunsigned long val = strtoul(line, NULL, 10);\n+\tint val = atoi(line);\n \tif (val <= 100)\n \t\tpatch->score = val;\n \treturn 0;\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -1125,12 +1125,10 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n  * Skip p_value leading components from \"line\"; as we do not accept\n  * absolute paths, return NULL in that case.\n  */\n-static const char *skip_tree_prefix(int p_value,\n-\t\t\t\t    const char *line,\n-\t\t\t\t    int llen)\n+static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n {\n \tint nslash;\n-\tint i;\n+\tsize_t i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n@@ -1152,9 +1150,7 @@ static const char *skip_tree_prefix(int p_value,\n  * creation or deletion of an empty file.  In any of these cases,\n  * both sides are the same name under a/ and b/ respectively.\n  */\n-static char *git_header_name(int p_value,\n-\t\t\t     const char *line,\n-\t\t\t     int llen)\n+static char *git_header_name(int p_value, const char *line, size_t llen)\n {\n \tconst char *name;\n \tconst char *second = NULL;\n@@ -1302,12 +1298,8 @@ static int check_header_line(int linenr, struct patch *patch)\n \treturn 0;\n }\n \n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch)\n {\n \tunsigned long offset;\n@@ -1360,14 +1352,14 @@ int parse_git_diff_header(struct strbuf *root,\n \t\t\t{ \"index \", gitdiff_index },\n \t\t\t{ \"\", gitdiff_unrecognized },\n \t\t};\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tlen = linelen(line, size);\n \t\tif (!len || line[len-1] != '\\n')\n \t\t\tbreak;\n \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n \t\t\tconst struct opentry *p = optable + i;\n-\t\t\tint oplen = strlen(p->str);\n+\t\t\tsize_t oplen = strlen(p->str);\n \t\t\tint res;\n \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n \t\t\t\tcontinue;\n@@ -1391,7 +1383,7 @@ done:\n \t\t\t\t \"%d leading pathname components (line %d)\",\n \t\t\t\t parse_hdr_state.p_value),\n \t\t\t      parse_hdr_state.p_value, *linenr);\n-\t\t\treturn -128;\n+\t\t\treturn -1;\n \t\t}\n \t\tpatch->old_name = xstrdup(patch->def_name);\n \t\tpatch->new_name = xstrdup(patch->def_name);\n@@ -1400,7 +1392,7 @@ done:\n \t    (!patch->old_name && !patch->is_new)) {\n \t\terror(_(\"git diff header lacks filename information \"\n \t\t\t\"(line %d)\"), *linenr);\n-\t\treturn -128;\n+\t\treturn -1;\n \t}\n \tpatch->is_toplevel_relative = 1;\n \treturn offset;\n@@ -1454,22 +1446,23 @@ static int parse_range(const char *line, int len, int offset, const char *expect\n \treturn offset + ex;\n }\n \n-static void recount_diff(const char *line, int size, struct fragment *fragment)\n+static void recount_diff(const char *line, size_t size,\n+\t\t\t struct fragment *fragment)\n {\n \tint oldlines = 0, newlines = 0, ret = 0;\n \n-\tif (size < 1) {\n+\tif (size == 0) {\n \t\twarning(\"recount: ignore empty hunk\");\n \t\treturn;\n \t}\n \n \tfor (;;) {\n-\t\tint len = linelen(line, size);\n-\t\tsize -= len;\n-\t\tline += len;\n+\t\tsize_t len = linelen(line, size);\n \n-\t\tif (size < 1)\n+\t\tif (size <= len)\n \t\t\tbreak;\n+\t\tsize -= len;\n+\t\tline += len;\n \n \t\tswitch (*line) {\n \t\tcase ' ': case '\\n':\n@@ -2172,9 +2165,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/apply.h b/apply.h\nindex b9f18ce87d1..7e6b6eb5d2d 100644\n--- a/apply.h\n+++ b/apply.h\n@@ -165,12 +165,8 @@ int check_apply_state(struct apply_state *state, int force_apply);\n  *\n  * Returns -1 on failure, the length of the parsed header otherwise.\n  */\n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch);\n \n void release_patch(struct patch *patch);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/blame.c b/blame.c\nindex 8bfeaa1c63a..cfaccac9e76 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -2193,10 +2193,10 @@ struct blame_list {\n  * and prepare a list of entry and the best split.\n  */\n static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n-\t\t\t\t\t   int *num_ents_p)\n+\t\t\t\t\t   size_t *num_ents_p)\n {\n \tstruct blame_entry *e;\n-\tint num_ents, i;\n+\tsize_t num_ents, i;\n \tstruct blame_list *blame_list = NULL;\n \n \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n@@ -2224,9 +2224,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t\tint opt)\n {\n \tstruct diff_options diff_opts;\n-\tint i, j;\n+\tsize_t i, j;\n \tstruct blame_list *blame_list;\n-\tint num_ents;\n+\tsize_t num_ents;\n \tstruct blame_entry *unblamed = target->suspects;\n \tstruct blame_entry *leftover = NULL;\n \n@@ -2645,7 +2645,7 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2708,7 +2708,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0c604022676..5a6686d42dc 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6743fb27bd5..6583d755edc 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -186,7 +186,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex fcf49706ad5..6f4d380e2e2 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1609,10 +1609,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1822,8 +1825,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..73e8ba48847 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1149,7 +1150,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/diff.c b/diff.c\nindex 9b14543e6ed..ffa9b599fc5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/dir.c b/dir.c\nindex fbdb24fc819..9595a6871a2 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -2981,7 +2981,7 @@ static void emit_traversal_statistics(struct dir_struct *dir,\n }\n \n int read_directory(struct dir_struct *dir, struct index_state *istate,\n-\t\t   const char *path, int len, const struct pathspec *pathspec)\n+\t\t   const char *path, unsigned int len, const struct pathspec *pathspec)\n {\n \tstruct untracked_cache_dir *untracked;\n \ndiff --git a/dir.h b/dir.h\nindex 8acfc044181..73cdff47c9e 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -374,7 +374,7 @@ int fill_directory(struct dir_struct *dir,\n \t\t   struct index_state *istate,\n \t\t   const struct pathspec *pathspec);\n int read_directory(struct dir_struct *, struct index_state *istate,\n-\t\t   const char *path, int len,\n+\t\t   const char *path, unsigned int len,\n \t\t   const struct pathspec *pathspec);\n \n enum pattern_match_result {\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8255ab4349c..fc48c930e41 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -38,7 +38,7 @@ static int read_patches(const char *range, struct string_list *list,\n \tstruct patch_util *util = NULL;\n \tint in_header = 1;\n \tchar *line, *current_filename = NULL;\n-\tssize_t len;\n+\tsize_t len;\n \tsize_t size;\n \tint ret = -1;\n \n@@ -117,7 +117,7 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tstruct patch patch = { 0 };\n \t\t\tstruct strbuf root = STRBUF_INIT;\n \t\t\tint linenr = 0;\n-\t\t\tint orig_len;\n+\t\t\tint orig_len, output;\n \n \t\t\tin_header = 0;\n \t\t\tstrbuf_addch(&buf, '\\n');\n@@ -126,15 +126,16 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tif (eol)\n \t\t\t\t*eol = '\\n';\n \t\t\torig_len = len;\n-\t\t\tlen = parse_git_diff_header(&root, &linenr, 0, line,\n-\t\t\t\t\t\t    len, size, &patch);\n-\t\t\tif (len < 0) {\n+\t\t\toutput = parse_git_diff_header(&root, &linenr, 0, line,\n+\t\t\t\t\t\t       len, size, &patch);\n+\t\t\tif (output < 0) {\n \t\t\t\terror(_(\"could not parse git header '%.*s'\"),\n \t\t\t\t      orig_len, line);\n \t\t\t\tFREE_AND_NULL(util);\n \t\t\t\tstring_list_clear(list, 1);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n+\t\t\tlen = output;\n \t\t\tstrbuf_addstr(&buf, \" ## \");\n \t\t\tif (patch.is_new > 0)\n \t\t\t\tstrbuf_addf(&buf, \"%s (new)\", patch.new_name);\n@@ -582,7 +583,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -603,5 +604,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex c383f41a3c5..40b3789dad1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/strvec.h b/strvec.h\nindex 9f55c8766ba..b4ef9d68409 100644\n--- a/strvec.h\n+++ b/strvec.h\n@@ -29,7 +29,7 @@ extern const char *empty_strvec[];\n  */\n struct strvec {\n \tconst char **v;\n-\tsize_t nr;\n+\tint nr;\n \tsize_t alloc;\n };\n \ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex d11bef96bf3..ca2060a1e2d 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -2280,8 +2280,8 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t * we are about to extract \"ce->name\"; we would not want to lose\n \t * anything in the existing directory there.\n \t */\n-\tint namelen;\n-\tint i;\n+\tunsigned int namelen;\n+\tunsigned int i;\n \tstruct dir_struct d;\n \tchar *pathbuf;\n \tint cnt = 0;\n@@ -2308,7 +2308,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t     i < o->src_index->cache_nr;\n \t     i++) {\n \t\tstruct cache_entry *ce2 = o->src_index->cache[i];\n-\t\tint len = ce_namelen(ce2);\n+\t\tunsigned int len = ce_namelen(ce2);\n \t\tif (len < namelen ||\n \t\t    strncmp(ce->name, ce2->name, namelen) ||\n \t\t    ce2->name[namelen] != '/')\n@@ -2328,7 +2328,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t}\n \n \t/* Do not lose a locally present file that is not ignored. */\n-\tpathbuf = xstrfmt(\"%.*s/\", namelen, ce->name);\n+\tpathbuf = xstrfmt(\"%.*s/\", (int)namelen, ce->name);\n \n \tmemset(&d, 0, sizeof(d));\n \tif (o->dir)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c\n-- \ngitgitgadget\n"},{"id":"469918","messageId":"pull.1399.v14.git.git.1673189530588.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v13.git.git.1672767431037.gitgitgadget@gmail.com","subject":"[PATCH v14] git: change variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-08T14:52:09Z","receivedAt":"2023-01-08T14:52:33Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: change variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v14\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v14\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v13:\n\n 1:  20febb0467b ! 1:  2fb578b5668 git: edit variable types to match what is assigned to them\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    git: edit variable types to match what is assigned to them\n     +    git: change variable types to match what is assigned to them\n      \n          There are many places where \"int len = strlen(foo);\" is written,\n          just for len to be passed as a parameter of size_t.\n\n\n add-interactive.c             |  2 +-\n apply.c                       | 57 +++++++++++++++--------------------\n apply.h                       |  8 ++---\n archive-tar.c                 |  8 ++---\n base85.c                      | 11 ++++---\n blame.c                       | 12 ++++----\n builtin/add.c                 |  3 +-\n builtin/merge-file.c          |  3 +-\n builtin/submodule--helper.c   |  3 +-\n cache.h                       | 13 +++++---\n color.c                       | 30 +++++++++---------\n color.h                       |  2 +-\n column.c                      |  7 +++--\n compat/compiler.h             |  9 +++---\n daemon.c                      | 11 ++++---\n diff.c                        |  4 +--\n dir.c                         |  2 +-\n dir.h                         |  2 +-\n fsck.c                        |  4 +--\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  4 +--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n range-diff.c                  | 15 ++++-----\n read-cache.c                  | 49 ++++++++++++++++--------------\n run-command.c                 | 11 ++++---\n strbuf.c                      |  2 +-\n strvec.h                      |  2 +-\n unpack-trees.c                |  8 ++---\n xdiff-interface.c             |  6 ++--\n 30 files changed, 150 insertions(+), 144 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..12cb87914f7 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -469,7 +469,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\ndiff --git a/apply.c b/apply.c\nindex 85822280476..a5dc7c46ae8 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1068,7 +1068,7 @@ static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n \t\t\t\t const char *line,\n \t\t\t\t struct patch *patch)\n {\n-\tunsigned long val = strtoul(line, NULL, 10);\n+\tint val = atoi(line);\n \tif (val <= 100)\n \t\tpatch->score = val;\n \treturn 0;\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -1125,12 +1125,10 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n  * Skip p_value leading components from \"line\"; as we do not accept\n  * absolute paths, return NULL in that case.\n  */\n-static const char *skip_tree_prefix(int p_value,\n-\t\t\t\t    const char *line,\n-\t\t\t\t    int llen)\n+static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n {\n \tint nslash;\n-\tint i;\n+\tsize_t i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n@@ -1152,9 +1150,7 @@ static const char *skip_tree_prefix(int p_value,\n  * creation or deletion of an empty file.  In any of these cases,\n  * both sides are the same name under a/ and b/ respectively.\n  */\n-static char *git_header_name(int p_value,\n-\t\t\t     const char *line,\n-\t\t\t     int llen)\n+static char *git_header_name(int p_value, const char *line, size_t llen)\n {\n \tconst char *name;\n \tconst char *second = NULL;\n@@ -1302,12 +1298,8 @@ static int check_header_line(int linenr, struct patch *patch)\n \treturn 0;\n }\n \n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch)\n {\n \tunsigned long offset;\n@@ -1360,14 +1352,14 @@ int parse_git_diff_header(struct strbuf *root,\n \t\t\t{ \"index \", gitdiff_index },\n \t\t\t{ \"\", gitdiff_unrecognized },\n \t\t};\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tlen = linelen(line, size);\n \t\tif (!len || line[len-1] != '\\n')\n \t\t\tbreak;\n \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n \t\t\tconst struct opentry *p = optable + i;\n-\t\t\tint oplen = strlen(p->str);\n+\t\t\tsize_t oplen = strlen(p->str);\n \t\t\tint res;\n \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n \t\t\t\tcontinue;\n@@ -1391,7 +1383,7 @@ done:\n \t\t\t\t \"%d leading pathname components (line %d)\",\n \t\t\t\t parse_hdr_state.p_value),\n \t\t\t      parse_hdr_state.p_value, *linenr);\n-\t\t\treturn -128;\n+\t\t\treturn -1;\n \t\t}\n \t\tpatch->old_name = xstrdup(patch->def_name);\n \t\tpatch->new_name = xstrdup(patch->def_name);\n@@ -1400,7 +1392,7 @@ done:\n \t    (!patch->old_name && !patch->is_new)) {\n \t\terror(_(\"git diff header lacks filename information \"\n \t\t\t\"(line %d)\"), *linenr);\n-\t\treturn -128;\n+\t\treturn -1;\n \t}\n \tpatch->is_toplevel_relative = 1;\n \treturn offset;\n@@ -1454,22 +1446,23 @@ static int parse_range(const char *line, int len, int offset, const char *expect\n \treturn offset + ex;\n }\n \n-static void recount_diff(const char *line, int size, struct fragment *fragment)\n+static void recount_diff(const char *line, size_t size,\n+\t\t\t struct fragment *fragment)\n {\n \tint oldlines = 0, newlines = 0, ret = 0;\n \n-\tif (size < 1) {\n+\tif (size == 0) {\n \t\twarning(\"recount: ignore empty hunk\");\n \t\treturn;\n \t}\n \n \tfor (;;) {\n-\t\tint len = linelen(line, size);\n-\t\tsize -= len;\n-\t\tline += len;\n+\t\tsize_t len = linelen(line, size);\n \n-\t\tif (size < 1)\n+\t\tif (size <= len)\n \t\t\tbreak;\n+\t\tsize -= len;\n+\t\tline += len;\n \n \t\tswitch (*line) {\n \t\tcase ' ': case '\\n':\n@@ -2172,9 +2165,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\ndiff --git a/apply.h b/apply.h\nindex b9f18ce87d1..7e6b6eb5d2d 100644\n--- a/apply.h\n+++ b/apply.h\n@@ -165,12 +165,8 @@ int check_apply_state(struct apply_state *state, int force_apply);\n  *\n  * Returns -1 on failure, the length of the parsed header otherwise.\n  */\n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch);\n \n void release_patch(struct patch *patch);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/blame.c b/blame.c\nindex 8bfeaa1c63a..cfaccac9e76 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -2193,10 +2193,10 @@ struct blame_list {\n  * and prepare a list of entry and the best split.\n  */\n static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n-\t\t\t\t\t   int *num_ents_p)\n+\t\t\t\t\t   size_t *num_ents_p)\n {\n \tstruct blame_entry *e;\n-\tint num_ents, i;\n+\tsize_t num_ents, i;\n \tstruct blame_list *blame_list = NULL;\n \n \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n@@ -2224,9 +2224,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t\tint opt)\n {\n \tstruct diff_options diff_opts;\n-\tint i, j;\n+\tsize_t i, j;\n \tstruct blame_list *blame_list;\n-\tint num_ents;\n+\tsize_t num_ents;\n \tstruct blame_entry *unblamed = target->suspects;\n \tstruct blame_entry *leftover = NULL;\n \n@@ -2645,7 +2645,7 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2708,7 +2708,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0c604022676..5a6686d42dc 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..28b032dadb6 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tunsigned int i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 450680fc708..a0cb92eb569 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -185,7 +185,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\ndiff --git a/cache.h b/cache.h\nindex 21ed9633b2a..e8fee0a1fca 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1607,10 +1607,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1820,8 +1823,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..81de82b323d 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..98c32485cc7 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..73e8ba48847 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1149,7 +1150,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/diff.c b/diff.c\nindex 9b14543e6ed..ffa9b599fc5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\ndiff --git a/dir.c b/dir.c\nindex fbdb24fc819..9595a6871a2 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -2981,7 +2981,7 @@ static void emit_traversal_statistics(struct dir_struct *dir,\n }\n \n int read_directory(struct dir_struct *dir, struct index_state *istate,\n-\t\t   const char *path, int len, const struct pathspec *pathspec)\n+\t\t   const char *path, unsigned int len, const struct pathspec *pathspec)\n {\n \tstruct untracked_cache_dir *untracked;\n \ndiff --git a/dir.h b/dir.h\nindex 8acfc044181..73cdff47c9e 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -374,7 +374,7 @@ int fill_directory(struct dir_struct *dir,\n \t\t   struct index_state *istate,\n \t\t   const struct pathspec *pathspec);\n int read_directory(struct dir_struct *, struct index_state *istate,\n-\t\t   const char *path, int len,\n+\t\t   const char *path, unsigned int len,\n \t\t   const struct pathspec *pathspec);\n \n enum pattern_match_result {\ndiff --git a/fsck.c b/fsck.c\nindex b3da1d68c0b..c51a4aa3d06 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -35,7 +35,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -43,7 +43,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 2fd0aa96875..8ba57b64db2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -3805,7 +3805,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3816,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..e800007434f 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\ndiff --git a/range-diff.c b/range-diff.c\nindex 8255ab4349c..fc48c930e41 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -38,7 +38,7 @@ static int read_patches(const char *range, struct string_list *list,\n \tstruct patch_util *util = NULL;\n \tint in_header = 1;\n \tchar *line, *current_filename = NULL;\n-\tssize_t len;\n+\tsize_t len;\n \tsize_t size;\n \tint ret = -1;\n \n@@ -117,7 +117,7 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tstruct patch patch = { 0 };\n \t\t\tstruct strbuf root = STRBUF_INIT;\n \t\t\tint linenr = 0;\n-\t\t\tint orig_len;\n+\t\t\tint orig_len, output;\n \n \t\t\tin_header = 0;\n \t\t\tstrbuf_addch(&buf, '\\n');\n@@ -126,15 +126,16 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tif (eol)\n \t\t\t\t*eol = '\\n';\n \t\t\torig_len = len;\n-\t\t\tlen = parse_git_diff_header(&root, &linenr, 0, line,\n-\t\t\t\t\t\t    len, size, &patch);\n-\t\t\tif (len < 0) {\n+\t\t\toutput = parse_git_diff_header(&root, &linenr, 0, line,\n+\t\t\t\t\t\t       len, size, &patch);\n+\t\t\tif (output < 0) {\n \t\t\t\terror(_(\"could not parse git header '%.*s'\"),\n \t\t\t\t      orig_len, line);\n \t\t\t\tFREE_AND_NULL(util);\n \t\t\t\tstring_list_clear(list, 1);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n+\t\t\tlen = output;\n \t\t\tstrbuf_addstr(&buf, \" ## \");\n \t\t\tif (patch.is_new > 0)\n \t\t\t\tstrbuf_addf(&buf, \"%s (new)\", patch.new_name);\n@@ -582,7 +583,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -603,5 +604,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 1ff518b2a7f..8717dc3b56b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -488,11 +490,11 @@ int ie_modified(struct index_state *istate,\n \treturn 0;\n }\n \n-int base_name_compare(const char *name1, int len1, int mode1,\n-\t\t      const char *name2, int len2, int mode2)\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2)\n {\n \tunsigned char c1, c2;\n-\tint len = len1 < len2 ? len1 : len2;\n+\tsize_t len = len1 < len2 ? len1 : len2;\n \tint cmp;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -517,10 +519,10 @@ int base_name_compare(const char *name1, int len1, int mode1,\n  * This is used by routines that want to traverse the git namespace\n  * but then handle conflicting entries together when possible.\n  */\n-int df_name_compare(const char *name1, int len1, int mode1,\n-\t\t    const char *name2, int len2, int mode2)\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2)\n {\n-\tint len = len1 < len2 ? len1 : len2, cmp;\n+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n \tunsigned char c1, c2;\n \n \tcmp = memcmp(name1, name2, len);\n@@ -555,7 +557,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -703,7 +706,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -718,7 +721,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -735,7 +738,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -902,7 +905,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -931,7 +934,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -982,7 +985,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1109,8 +1112,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1151,7 +1154,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1598,7 +1601,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2762,7 +2765,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2842,8 +2845,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3471,7 +3474,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..511bed961c3 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1632,9 +1632,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t\t\t     const struct run_process_parallel_opts *opts,\n \t\t\t     int output_timeout)\n {\n-\tint i;\n+\tsize_t i;\n \n-\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n \t\tif (errno == EINTR)\n \t\t\tcontinue;\n \t\tpp_cleanup(pp, opts);\n@@ -1642,11 +1642,12 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \t}\n \n \t/* Buffer output from all pipes. */\n-\tfor (size_t i = 0; i < opts->processes; i++) {\n+\tfor (i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/strbuf.c b/strbuf.c\nindex c383f41a3c5..40b3789dad1 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\ndiff --git a/strvec.h b/strvec.h\nindex 9f55c8766ba..b4ef9d68409 100644\n--- a/strvec.h\n+++ b/strvec.h\n@@ -29,7 +29,7 @@ extern const char *empty_strvec[];\n  */\n struct strvec {\n \tconst char **v;\n-\tsize_t nr;\n+\tint nr;\n \tsize_t alloc;\n };\n \ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ea09023b015..5d963b51607 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -2284,8 +2284,8 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t * we are about to extract \"ce->name\"; we would not want to lose\n \t * anything in the existing directory there.\n \t */\n-\tint namelen;\n-\tint i;\n+\tunsigned int namelen;\n+\tunsigned int i;\n \tstruct dir_struct d;\n \tchar *pathbuf;\n \tint cnt = 0;\n@@ -2312,7 +2312,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t     i < o->src_index->cache_nr;\n \t     i++) {\n \t\tstruct cache_entry *ce2 = o->src_index->cache[i];\n-\t\tint len = ce_namelen(ce2);\n+\t\tunsigned int len = ce_namelen(ce2);\n \t\tif (len < namelen ||\n \t\t    strncmp(ce->name, ce2->name, namelen) ||\n \t\t    ce2->name[namelen] != '/')\n@@ -2332,7 +2332,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t}\n \n \t/* Do not lose a locally present file that is not ignored. */\n-\tpathbuf = xstrfmt(\"%.*s/\", namelen, ce->name);\n+\tpathbuf = xstrfmt(\"%.*s/\", (int)namelen, ce->name);\n \n \tmemset(&d, 0, sizeof(d));\n \tif (o->dir)\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1\n-- \ngitgitgadget\n"},{"id":"469925","messageId":"pull.1399.v15.git.git.1673204590945.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v14.git.git.1673189530588.gitgitgadget@gmail.com","subject":"[PATCH v15] git: change variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-08T19:03:09Z","receivedAt":"2023-01-08T19:03:24Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nAs of right now, the current set of changes\nis too large to keep going, so future changes\nshould be in future patches. However, the codebase\nworks perfectly even if only these changes\nwere ever to be accepted. I just do not want\nto change too much at a time.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com\n---\n    git: change variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v15\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v15\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v14:\n\n 1:  2fb578b5668 ! 1:  0fd1aa406a0 git: change variable types to match what is assigned to them\n     @@ Commit message\n          This causes truncation and then expansion\n          back from int to size_t. This is poor logic.\n      \n     -    Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n     +    As of right now, the current set of changes\n     +    is too large to keep going, so future changes\n     +    should be in future patches. However, the codebase\n     +    works perfectly even if only these changes\n     +    were ever to be accepted. I just do not want\n     +    to change too much at a time.\n     +\n     +    Signed-off-by: Seija Kijin <doremylover123@gmail.com\n      \n       ## add-interactive.c ##\n     +@@ add-interactive.c: static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n     + struct list_options {\n     + \tint columns;\n     + \tconst char *header;\n     +-\tvoid (*print_item)(int i, int selected, struct string_list_item *item,\n     ++\tvoid (*print_item)(size_t i, int selected,\n     ++\t\t\t   struct string_list_item *item,\n     + \t\t\t   void *print_item_data);\n     + \tvoid *print_item_data;\n     + };\n     +@@ add-interactive.c: struct list_options {\n     + static void list(struct add_i_state *s, struct string_list *list, int *selected,\n     + \t\t struct list_options *opts)\n     + {\n     +-\tint i, last_lf = 0;\n     ++\tsize_t i;\n     ++\tint last_lf = 0;\n     + \n     + \tif (!list->nr)\n     + \t\treturn;\n      @@ add-interactive.c: static void collect_changes_cb(struct diff_queue_struct *q,\n       \n       \tfor (i = 0; i < stat.nr; i++) {\n     @@ add-interactive.c: static void collect_changes_cb(struct diff_queue_struct *q,\n       \t\tstruct pathname_entry *entry;\n       \t\tstruct file_item *file_item;\n       \t\tstruct adddel *adddel, *other_adddel;\n     +@@ add-interactive.c: static int get_modified_files(struct repository *r,\n     + \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n     + \t\t\t\t\t     &head_oid, NULL);\n     + \tstruct collection_status s = { 0 };\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tdiscard_index(r->index);\n     + \tif (repo_read_index_preload(r, ps, 0) < 0)\n     +@@ add-interactive.c: struct print_file_item_data {\n     + \tunsigned only_names:1;\n     + };\n     + \n     +-static void print_file_item(int i, int selected, struct string_list_item *item,\n     ++static void print_file_item(size_t i, int selected,\n     ++\t\t\t    struct string_list_item *item,\n     + \t\t\t    void *print_file_item_data)\n     + {\n     + \tstruct file_item *c = item->util;\n     + \tstruct print_file_item_data *d = print_file_item_data;\n     + \tconst char *highlighted = NULL;\n     ++\tunsigned int e = (unsigned int)i + 1;\n     + \n     + \tstrbuf_reset(&d->index);\n     + \tstrbuf_reset(&d->worktree);\n     +@@ add-interactive.c: static void print_file_item(int i, int selected, struct string_list_item *item,\n     + \t}\n     + \n     + \tif (d->only_names) {\n     +-\t\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1,\n     ++\t\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e,\n     + \t\t       highlighted ? highlighted : item->string);\n     + \t\treturn;\n     + \t}\n     +@@ add-interactive.c: static void print_file_item(int i, int selected, struct string_list_item *item,\n     + \tstrbuf_addf(&d->buf, d->modified_fmt, d->index.buf, d->worktree.buf,\n     + \t\t    highlighted ? highlighted : item->string);\n     + \n     +-\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1, d->buf.buf);\n     ++\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e, d->buf.buf);\n     + }\n     + \n     + static int run_status(struct add_i_state *s, const struct pathspec *ps,\n     +@@ add-interactive.c: struct print_command_item_data {\n     + \tconst char *color, *reset;\n     + };\n     + \n     +-static void print_command_item(int i, int selected,\n     ++static void print_command_item(size_t i, int selected,\n     + \t\t\t       struct string_list_item *item,\n     + \t\t\t       void *print_command_item_data)\n     + {\n     ++\tunsigned int e = (unsigned int)(i + 1);\n     + \tstruct print_command_item_data *d = print_command_item_data;\n     + \tstruct command_item *util = item->util;\n     + \n     + \tif (!util->prefix_length ||\n     + \t    !is_valid_prefix(item->string, util->prefix_length))\n     +-\t\tprintf(\" %2d: %s\", i + 1, item->string);\n     ++\t\tprintf(\" %2u: %s\", e, item->string);\n     + \telse\n     +-\t\tprintf(\" %2d: %s%.*s%s%s\", i + 1,\n     +-\t\t       d->color, (int)util->prefix_length, item->string,\n     +-\t\t       d->reset, item->string + util->prefix_length);\n     ++\t\tprintf(\" %2u: %s%.*s%s%s\", e, d->color,\n     ++\t\t       (int)util->prefix_length, item->string, d->reset,\n     ++\t\t       item->string + util->prefix_length);\n     + }\n     + \n     + static void command_prompt_help(struct add_i_state *s)\n     +\n     + ## add-patch.c ##\n     +@@ add-patch.c: static int is_octal(const char *p, size_t len)\n     + \tif (!len)\n     + \t\treturn 0;\n     + \n     +-\twhile (len--)\n     ++\tdo {\n     + \t\tif (*p < '0' || *(p++) > '7')\n     + \t\t\treturn 0;\n     ++\t} while (--len);\n     + \treturn 1;\n     + }\n     + \n     +\n     + ## advice.c ##\n     +@@ advice.c: void advise_if_enabled(enum advice_type type, const char *advice, ...)\n     + int git_default_advice_config(const char *var, const char *value)\n     + {\n     + \tconst char *k, *slot_name;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!strcmp(var, \"color.advice\")) {\n     + \t\tadvice_use_color = git_config_colorbool(var, value);\n      \n       ## apply.c ##\n      @@ apply.c: static int name_terminate(int c, int terminate)\n     @@ apply.c: static int parse_range(const char *line, int len, int offset, const cha\n       \n       \t\tswitch (*line) {\n       \t\tcase ' ': case '\\n':\n     +@@ apply.c: static void add_name_limit(struct apply_state *state,\n     + static int use_patch(struct apply_state *state, struct patch *p)\n     + {\n     + \tconst char *pathname = p->new_name ? p->new_name : p->old_name;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* Paths outside are not touched regardless of \"--include\" */\n     + \tif (state->prefix && *state->prefix) {\n      @@ apply.c: static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n       \t\t\t\t\"Files \",\n       \t\t\t\tNULL,\n     @@ apply.c: static int parse_chunk(struct apply_state *state, char *buffer, unsigne\n       \t\t\t\tif (len < size - hd &&\n       \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n       \t\t\t\t\tstate->linenr++;\n     +@@ apply.c: static void update_pre_post_images(struct image *preimage,\n     + \tif (postlen\n     + \t    ? postlen < new_buf - postimage->buf\n     + \t    : postimage->len < new_buf - postimage->buf)\n     +-\t\tBUG(\"caller miscounted postlen: asked %d, orig = %d, used = %d\",\n     +-\t\t    (int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));\n     ++\t\tBUG(\"caller miscounted postlen: asked %u, orig = %u, used = %u\",\n     ++\t\t    (unsigned int)postlen, (unsigned int)postimage->len,\n     ++\t\t    (unsigned int)(new_buf - postimage->buf));\n     + \n     + \t/* Fix the length of the whole thing */\n     + \tpostimage->len = new_buf - postimage->buf;\n      \n       ## apply.h ##\n      @@ apply.h: int check_apply_state(struct apply_state *state, int force_apply);\n     @@ archive-tar.c: static struct archiver tar_archiver = {\n       \n       \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\n      \n     + ## archive.c ##\n     +@@ archive.c: int write_archive_entries(struct archiver_args *args,\n     + \tstruct strbuf path_in_archive = STRBUF_INIT;\n     + \tstruct strbuf content = STRBUF_INIT;\n     + \tstruct object_id fake_oid;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \toidcpy(&fake_oid, null_oid());\n     + \n     +\n     + ## attr.c ##\n     +@@ attr.c: struct attr_stack {\n     + \n     + static void attr_stack_free(struct attr_stack *e)\n     + {\n     +-\tint i;\n     ++\tunsigned int i, j;\n     + \tfree(e->origin);\n     + \tfor (i = 0; i < e->num_matches; i++) {\n     + \t\tstruct match_attr *a = e->attrs[i];\n     +-\t\tint j;\n     + \t\tfor (j = 0; j < a->num_attr; j++) {\n     + \t\t\tconst char *setto = a->state[j].setto;\n     + \t\t\tif (setto == ATTR__TRUE ||\n     +\n       ## base85.c ##\n      @@ base85.c: static void prep_base85(void)\n       \t}\n     @@ base85.c: void encode_85(char *buf, const unsigned char *data, int bytes)\n       \t\t\tbuf[cnt] = en85[val];\n       \t\t}\n      \n     + ## bisect.c ##\n     +@@ bisect.c: static void read_bisect_paths(struct strvec *array)\n     + static char *join_oid_array_hex(struct oid_array *array, char delim)\n     + {\n     + \tstruct strbuf joined_hexs = STRBUF_INIT;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < array->nr; i++) {\n     + \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\n     +\n       ## blame.c ##\n     +@@ blame.c: static void get_line_fingerprints(struct fingerprint *fingerprints,\n     + \t\t\t\t  const char *content, const int *line_starts,\n     + \t\t\t\t  long first_line, long line_count)\n     + {\n     +-\tint i;\n     ++\tlong i;\n     + \tconst char *linestart, *lineend;\n     + \n     + \tline_starts += first_line;\n     +@@ blame.c: static void split_overlap(struct blame_entry *split,\n     + \t\t\t  struct blame_origin *parent)\n     + {\n     + \tint chunk_end_lno;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tmemset(split, 0, sizeof(struct blame_entry [3]));\n     + \n     + \tfor (i = 0; i < 3; i++) {\n     +@@ blame.c: static void split_blame(struct blame_entry ***blamed,\n     +  */\n     + static void decref_split(struct blame_entry *split)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tfor (i = 0; i < 3; i++)\n     + \t\tblame_origin_decref(split[i].suspect);\n     +@@ blame.c: static void copy_split_if_better(struct blame_scoreboard *sb,\n     + \t\t\t\t struct blame_entry *best_so_far,\n     + \t\t\t\t struct blame_entry *potential)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tif (!potential[1].suspect)\n     + \t\treturn;\n      @@ blame.c: struct blame_list {\n        * and prepare a list of entry and the best split.\n        */\n     @@ blame.c: static struct commit *dwim_reverse_initial(struct rev_info *revs,\n       \tconst char *name = NULL;\n       \n      \n     + ## block-sha1/sha1.c ##\n     +@@ block-sha1/sha1.c: void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)\n     + {\n     + \tstatic const unsigned char pad[64] = { 0x80 };\n     + \tunsigned int padlen[2];\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* Pad with a binary 1 (ie 0x80), then zeroes, then length */\n     + \tpadlen[0] = htonl((uint32_t)(ctx->size >> 29));\n     +\n     + ## bloom.c ##\n     +@@ bloom.c: uint32_t murmur3_seeded(uint32_t seed, const char *data, size_t len)\n     + \tconst uint32_t r2 = 13;\n     + \tconst uint32_t m = 5;\n     + \tconst uint32_t n = 0xe6546b64;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tuint32_t k1 = 0;\n     + \tconst char *tail;\n     + \n     +-\tint len4 = len / sizeof(uint32_t);\n     ++\tsize_t len4 = len / sizeof(uint32_t);\n     + \n     + \tuint32_t k;\n     + \tfor (i = 0; i < len4; i++) {\n     +@@ bloom.c: void fill_bloom_key(const char *data,\n     + \t\t    struct bloom_key *key,\n     + \t\t    const struct bloom_filter_settings *settings)\n     + {\n     +-\tint i;\n     ++\tuint32_t i;\n     + \tconst uint32_t seed0 = 0x293ae76f;\n     + \tconst uint32_t seed1 = 0x7e646e2c;\n     + \tconst uint32_t hash0 = murmur3_seeded(seed0, data, len);\n     +@@ bloom.c: void add_key_to_filter(const struct bloom_key *key,\n     + \t\t       struct bloom_filter *filter,\n     + \t\t       const struct bloom_filter_settings *settings)\n     + {\n     +-\tint i;\n     ++\tuint32_t i;\n     + \tuint64_t mod = filter->len * BITS_PER_WORD;\n     + \n     + \tfor (i = 0; i < settings->num_hashes; i++) {\n     +@@ bloom.c: int bloom_filter_contains(const struct bloom_filter *filter,\n     + \t\t\t  const struct bloom_key *key,\n     + \t\t\t  const struct bloom_filter_settings *settings)\n     + {\n     +-\tint i;\n     ++\tuint32_t i;\n     + \tuint64_t mod = filter->len * BITS_PER_WORD;\n     + \n     + \tif (!mod)\n     +\n     + ## branch.c ##\n     +@@ branch.c: static struct strmap current_checked_out_branches = STRMAP_INIT;\n     + \n     + static void prepare_checked_out_branches(void)\n     + {\n     +-\tint i = 0;\n     ++\tsize_t i = 0;\n     + \tstruct worktree **worktrees;\n     + \n     + \tif (initialized_checked_out_branches)\n     +@@ branch.c: int replace_each_worktree_head_symref(const char *oldref, const char *newref,\n     + {\n     + \tint ret = 0;\n     + \tstruct worktree **worktrees = get_worktrees();\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; worktrees[i]; i++) {\n     + \t\tstruct ref_store *refs;\n     +\n       ## builtin/add.c ##\n      @@ builtin/add.c: struct update_callback_data {\n       \n     @@ builtin/add.c: struct update_callback_data {\n       \tfor (i = 0; i < the_index.cache_nr; i++) {\n       \t\tstruct cache_entry *ce = the_index.cache[i];\n      \n     - ## builtin/merge-file.c ##\n     -@@ builtin/merge-file.c: int cmd_merge_file(int argc, const char **argv, const char *prefix)\n     - \tmmfile_t mmfs[3] = { 0 };\n     - \tmmbuffer_t result = { 0 };\n     - \txmparam_t xmp = { 0 };\n     --\tint ret = 0, i = 0, to_stdout = 0;\n     -+\tint ret = 0, to_stdout = 0;\n     -+\tunsigned int i = 0;\n     - \tint quiet = 0;\n     - \tstruct option options[] = {\n     - \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\n     + ## builtin/fast-export.c ##\n     +@@ builtin/fast-export.c: static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n     + \n     + static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tfor (i = 0; i < info->nr; i++) {\n     + \t\tstruct rev_cmdline_entry *e = info->rev + i;\n     +@@ builtin/fast-export.c: int cmd_fast_export(int argc, const char **argv, const char *prefix)\n     + \t\tdie(_(\"the option '%s' requires '%s'\"), \"--anonymize-map\", \"--anonymize\");\n     + \n     + \tif (refspecs_list.nr) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tfor (i = 0; i < refspecs_list.nr; i++)\n     + \t\t\trefspec_append(&refspecs, refspecs_list.items[i].string);\n      \n     - ## builtin/submodule--helper.c ##\n     -@@ builtin/submodule--helper.c: static int module_list_compute(const char **argv,\n     - \t\t\t       struct pathspec *pathspec,\n     - \t\t\t       struct module_list *list)\n     + ## builtin/fast-import.c ##\n     +@@ builtin/fast-import.c: static void end_packfile(void)\n     + \t\tstruct packed_git *new_p;\n     + \t\tstruct object_id cur_pack_oid;\n     + \t\tchar *idx_name;\n     +-\t\tint i;\n     ++\t\tunsigned long i;\n     + \t\tstruct branch *b;\n     + \t\tstruct tag *t;\n     + \n     +\n     + ## builtin/fetch-pack.c ##\n     +@@ builtin/fetch-pack.c: int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n     + \tref = fetch_pack(&args, fd, ref, sought, nr_sought,\n     + \t\t\t &shallow, pack_lockfiles_ptr, version);\n     + \tif (pack_lockfiles.nr) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tprintf(\"lock %s\\n\", pack_lockfiles.items[0].string);\n     + \t\tfflush(stdout);\n     +\n     + ## builtin/fetch.c ##\n     +@@ builtin/fetch.c: static int add_oid(const char *refname UNUSED,\n     + static void add_negotiation_tips(struct git_transport_options *smart_options)\n     + {\n     + \tstruct oid_array *oids = xcalloc(1, sizeof(*oids));\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < negotiation_tip.nr; i++) {\n     + \t\tconst char *s = negotiation_tip.items[i].string;\n     +-\t\tint old_nr;\n     ++\t\tsize_t old_nr;\n     + \t\tif (!has_glob_specials(s)) {\n     + \t\t\tstruct object_id oid;\n     + \t\t\tif (get_oid(s, &oid))\n     +@@ builtin/fetch.c: static int fetch_finished(int result, struct strbuf *out,\n     + \n     + static int fetch_multiple(struct string_list *list, int max_children)\n       {\n      -\tint i, result = 0;\n     -+\tunsigned int i;\n     ++\tsize_t i;\n      +\tint result = 0;\n     - \tchar *ps_matched = NULL;\n     + \tstruct strvec argv = STRVEC_INIT;\n       \n     - \tparse_pathspec(pathspec, 0,\n     + \tif (!append && write_fetch_head) {\n      \n     - ## cache.h ##\n     -@@ cache.h: int repo_interpret_branch_name(struct repository *r,\n     + ## builtin/for-each-repo.c ##\n     +@@ builtin/for-each-repo.c: static int run_command_on_repo(const char *path, int argc, const char ** argv)\n     + int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n     + {\n     + \tstatic const char *config_key = NULL;\n     +-\tint i, result = 0;\n     ++\tint result = 0;\n     ++\tsize_t i;\n     + \tconst struct string_list *values;\n       \n     - int validate_headref(const char *ref);\n     + \tconst struct option options[] = {\n     +\n     + ## builtin/fsck.c ##\n     +@@ builtin/fsck.c: static void check_object(struct object *obj)\n       \n     --int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     --int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     -+int base_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t      const char *name2, size_t len2, int mode2);\n     -+int df_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t    const char *name2, size_t len2, int mode2);\n     - int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n     --int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n     -+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n     -+\t\t\t     const char *name2, size_t len2, int stage2);\n     + static void check_connectivity(void)\n     + {\n     +-\tint i, max;\n     ++\tunsigned int i, max;\n       \n     - void *read_object_with_reference(struct repository *r,\n     - \t\t\t\t const struct object_id *oid,\n     -@@ cache.h: extern const char *askpass_program;\n     - extern const char *excludes_file;\n     + \t/* Traverse the pending reachable objects */\n     + \ttraverse_reachable();\n     +\n     + ## builtin/gc.c ##\n     +@@ builtin/gc.c: static struct string_list pack_garbage = STRING_LIST_INIT_DUP;\n       \n     - /* base85 */\n     --int decode_85(char *dst, const char *line, int linelen);\n     --void encode_85(char *buf, const unsigned char *data, int bytes);\n     -+int decode_85(char *dst, const char *line, size_t linelen);\n     -+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n     + static void clean_pack_garbage(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < pack_garbage.nr; i++)\n     + \t\tunlink_or_warn(pack_garbage.items[i].string);\n     + \tstring_list_clear(&pack_garbage, 0);\n     +@@ builtin/gc.c: static int compare_tasks_by_selection(const void *a_, const void *b_)\n       \n     - /* pkt-line.c */\n     - void packet_trace_identity(const char *prog);\n     -\n     - ## color.c ##\n     -@@ color.c: struct color {\n     -  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n     -  * \"match\" exactly?\n     -  */\n     --static int match_word(const char *word, int len, const char *match)\n     -+static int match_word(const char *word, size_t len, const char *match)\n     + static int maintenance_run_tasks(struct maintenance_run_opts *opts)\n       {\n     - \treturn !strncasecmp(word, match, len) && !match[len];\n     - }\n     -@@ color.c: static int get_hex_color(const char *in, unsigned char *out)\n     -  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n     -  * Otherwise, leave out unchanged and return -1.\n     -  */\n     --static int parse_ansi_color(struct color *out, const char *name, int len)\n     -+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n     +-\tint i, found_selected = 0;\n     ++\tunsigned int i;\n     ++\tint found_selected = 0;\n     + \tint result = 0;\n     + \tstruct lock_file lk;\n     + \tstruct repository *r = the_repository;\n     +@@ builtin/gc.c: static void initialize_maintenance_strategy(void)\n     + \n     + static void initialize_task_config(int schedule)\n       {\n     - \t/* Positions in array must match ANSI color codes */\n     - \tstatic const char * const color_names[] = {\n     - \t\t\"black\", \"red\", \"green\", \"yellow\",\n     - \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n     - \t};\n      -\tint i;\n      +\tunsigned int i;\n     - \tint color_offset = COLOR_FOREGROUND_ANSI;\n     + \tstruct strbuf config_name = STRBUF_INIT;\n     + \tgc_config();\n       \n     - \tif (match_word(name, len, \"default\")) {\n     -@@ color.c: static int parse_ansi_color(struct color *out, const char *name, int len)\n     - \treturn -1;\n     - }\n     +@@ builtin/gc.c: static void initialize_task_config(int schedule)\n     + static int task_option_parse(const struct option *opt,\n     + \t\t\t     const char *arg, int unset)\n     + {\n     +-\tint i, num_selected = 0;\n     ++\tunsigned int i;\n     ++\tint num_selected = 0;\n     + \tstruct maintenance_task *task = NULL;\n       \n     --static int parse_color(struct color *out, const char *name, int len)\n     -+static int parse_color(struct color *out, const char *name, size_t len)\n     + \tBUG_ON_OPT_NEG(unset);\n     +@@ builtin/gc.c: static int task_option_parse(const struct option *opt,\n     + \n     + static int maintenance_run(int argc, const char **argv, const char *prefix)\n       {\n     - \tchar *end;\n     - \tlong val;\n     -@@ color.c: int color_parse(const char *value, char *dst)\n     -  * already have the ANSI escape code in it. \"out\" should have enough\n     -  * space in it to fit any color.\n     -  */\n     --static char *color_output(char *out, int len, const struct color *c, int background)\n     -+static char *color_output(char *out, size_t len, const struct color *c,\n     -+\t\t\t  int background)\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct maintenance_run_opts opts;\n     + \tstruct option builtin_maintenance_run_options[] = {\n     + \t\tOPT_BOOL(0, \"auto\", &opts.auto_flag,\n     +@@ builtin/gc.c: static int launchctl_list_contains_plist(const char *name, const char *cmd)\n     + \n     + static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule)\n       {\n     - \tint offset = 0;\n     +-\tint i, fd;\n     +-\tconst char *preamble, *repeat;\n     ++\tunsigned int i;\n     ++\tint fd;\n     ++\tconst char *preamble;\n     + \tconst char *frequency = get_frequency(schedule);\n     + \tchar *name = launchctl_service_name(frequency);\n     + \tchar *filename = launchctl_service_filename(name);\n     +@@ builtin/gc.c: static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n     + \n     + \tswitch (schedule) {\n     + \tcase SCHEDULE_HOURLY:\n     +-\t\trepeat = \"<dict>\\n\"\n     +-\t\t\t \"<key>Hour</key><integer>%d</integer>\\n\"\n     +-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n     +-\t\t\t \"</dict>\\n\";\n     + \t\tfor (i = 1; i <= 23; i++)\n     +-\t\t\tstrbuf_addf(&plist, repeat, i);\n     ++\t\t\tstrbuf_addf(&plist,\n     ++\t\t\t\t    \"<dict>\\n\"\n     ++\t\t\t\t    \"<key>Hour</key><integer>%u</integer>\\n\"\n     ++\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n     ++\t\t\t\t    \"</dict>\\n\",\n     ++\t\t\t\t    i);\n     + \t\tbreak;\n     + \n     + \tcase SCHEDULE_DAILY:\n     +-\t\trepeat = \"<dict>\\n\"\n     +-\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n     +-\t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n     +-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n     +-\t\t\t \"</dict>\\n\";\n     + \t\tfor (i = 1; i <= 6; i++)\n     +-\t\t\tstrbuf_addf(&plist, repeat, i);\n     ++\t\t\tstrbuf_addf(&plist,\n     ++\t\t\t\t    \"<dict>\\n\"\n     ++\t\t\t\t    \"<key>Day</key><integer>%u</integer>\\n\"\n     ++\t\t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n     ++\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n     ++\t\t\t\t    \"</dict>\\n\",\n     ++\t\t\t\t    i);\n     + \t\tbreak;\n     + \n     + \tcase SCHEDULE_WEEKLY:\n     +@@ builtin/gc.c: static void validate_scheduler(enum scheduler scheduler)\n     + static int update_background_schedule(const struct maintenance_start_opts *opts,\n     + \t\t\t\t      int enable)\n     + {\n     +-\tunsigned int i;\n     ++\tsize_t i;\n     + \tint result = 0;\n     + \tstruct lock_file lk;\n     + \tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n     +\n     + ## builtin/grep.c ##\n     +@@ builtin/grep.c: static void work_done(struct work_item *w)\n       \n     -@@ color.c: static int color_empty(const struct color *c)\n     - \treturn c->type <= COLOR_NORMAL;\n     - }\n     + static void free_repos(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n       \n     --int color_parse_mem(const char *value, int value_len, char *dst)\n     -+int color_parse_mem(const char *value, size_t value_len, char *dst)\n     + \tfor (i = 0; i < repos_to_free_nr; i++) {\n     + \t\trepo_clear(repos_to_free[i]);\n     +@@ builtin/grep.c: static void run_pager(struct grep_opt *opt, const char *prefix)\n       {\n     - \tconst char *ptr = value;\n     --\tint len = value_len;\n     -+\tsize_t len = value_len;\n     - \tchar *end = dst + COLOR_MAXLEN;\n     --\tunsigned int has_reset = 0;\n     -+\tint has_reset = 0;\n     - \tunsigned int attr = 0;\n     - \tstruct color fg = { COLOR_UNSPECIFIED };\n     - \tstruct color bg = { COLOR_UNSPECIFIED };\n     + \tstruct string_list *path_list = opt->output_priv;\n     + \tstruct child_process child = CHILD_PROCESS_INIT;\n     +-\tint i, status;\n     ++\tsize_t i;\n     ++\tint status;\n       \n     --\twhile (len > 0 && isspace(*ptr)) {\n     -+\twhile (len && isspace(*ptr)) {\n     - \t\tptr++;\n     - \t\tlen--;\n     - \t}\n     -@@ color.c: int color_parse_mem(const char *value, int value_len, char *dst)\n     - \t}\n     + \tfor (i = 0; i < path_list->nr; i++)\n     + \t\tstrvec_push(&child.args, path_list->items[i].string);\n     +\n     + ## builtin/help.c ##\n     +@@ builtin/help.c: static void list_config_help(enum show_config_type type)\n     + \tstruct string_list keys = STRING_LIST_INIT_DUP;\n     + \tstruct string_list keys_uniq = STRING_LIST_INIT_DUP;\n     + \tstruct string_list_item *item;\n     +-\tint i;\n     ++\tsize_t i;\n       \n     - \t/* [reset] [fg [bg]] [attr]... */\n     --\twhile (len > 0) {\n     -+\twhile (len) {\n     - \t\tconst char *word = ptr;\n     - \t\tstruct color c = { COLOR_UNSPECIFIED };\n     --\t\tint val, wordlen = 0;\n     -+\t\tint val;\n     -+\t\tsize_t wordlen = 0;\n     + \tfor (p = config_name_list; *p; p++) {\n     + \t\tconst char *var = *p;\n     +\n     + ## builtin/log.c ##\n     +@@ builtin/log.c: static void cmd_log_init_defaults(struct rev_info *rev)\n       \n     - \t\twhile (len > 0 && !isspace(word[wordlen])) {\n     - \t\t\twordlen++;\n     -@@ color.c: int color_parse_mem(const char *value, int value_len, char *dst)\n     + static void set_default_decoration_filter(struct decoration_filter *decoration_filter)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tchar *value = NULL;\n     + \tstruct string_list *include = decoration_filter->include_ref_pattern;\n     + \tconst struct string_list *config_exclude =\n     +@@ builtin/log.c: static struct itimerval early_output_timer;\n     + \n     + static void log_show_early(struct rev_info *revs, struct commit_list *list)\n     + {\n     +-\tint i = revs->early_output;\n     ++\tunsigned int i = revs->early_output;\n     + \tint show_header = 1;\n     + \tint no_free = revs->diffopt.no_free;\n     + \n     +\n     + ## builtin/ls-files.c ##\n     +@@ builtin/ls-files.c: static void show_ru_info(struct index_state *istate)\n     + \tfor_each_string_list_item(item, istate->resolve_undo) {\n     + \t\tconst char *path = item->string;\n     + \t\tstruct resolve_undo_info *ui = item->util;\n     +-\t\tint i, len;\n     ++\t\tunsigned int i;\n     ++\t\tint len;\n     + \n     + \t\tlen = strlen(path);\n     + \t\tif (len < max_prefix_len)\n     +@@ builtin/ls-files.c: static void show_ru_info(struct index_state *istate)\n     + \t\tfor (i = 0; i < 3; i++) {\n     + \t\t\tif (!ui->mode[i])\n     + \t\t\t\tcontinue;\n     +-\t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n     +-\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev),\n     +-\t\t\t       i + 1);\n     ++\t\t\tprintf(\"%s%06o %s %u\\t\", tag_resolve_undo, ui->mode[i],\n     ++\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev), i + 1);\n     + \t\t\twrite_name(path);\n     + \t\t}\n     + \t}\n     +@@ builtin/ls-files.c: static void construct_fullname(struct strbuf *out, const struct repository *repo\n     + \n     + static void show_files(struct repository *repo, struct dir_struct *dir)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct strbuf fullname = STRBUF_INIT;\n     + \n     + \t/* For cached/deleted files we don't need to even do the readdir */\n     +@@ builtin/ls-files.c: static void show_files(struct repository *repo, struct dir_struct *dir)\n     + \n     + skip_to_next_name:\n     + \t\t{\n     +-\t\t\tint j;\n     +-\t\t\tstruct cache_entry **cache = repo->index->cache;\n     +-\t\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n     +-\t\t\t\tif (strcmp(ce->name, cache[j]->name))\n     +-\t\t\t\t\tbreak;\n     +-\t\t\ti = j - 1; /* compensate for the for loop */\n     ++\t\tunsigned int j;\n     ++\t\tstruct cache_entry **cache = repo->index->cache;\n     ++\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n     ++\t\t\tif (strcmp(ce->name, cache[j]->name))\n     ++\t\t\t\tbreak;\n     ++\t\ti = j - 1; /* compensate for the for loop */\n     + \t\t}\n     + \t}\n     + \n     +@@ builtin/ls-files.c: void overlay_tree_on_index(struct index_state *istate,\n     + \tstruct object_id oid;\n     + \tstruct pathspec pathspec;\n     + \tstruct cache_entry *last_stage0 = NULL;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tread_tree_fn_t fn = NULL;\n     + \tint err;\n     + \n     +\n     + ## builtin/ls-remote.c ##\n     +@@ builtin/ls-remote.c: int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n     + \tpacket_trace_identity(\"ls-remote\");\n     + \n     + \tif (argc > 1) {\n     +-\t\tint i;\n     + \t\tCALLOC_ARRAY(pattern, argc);\n     + \t\tfor (i = 1; i < argc; i++) {\n     + \t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\n     +\n     + ## builtin/mailsplit.c ##\n     +@@ builtin/mailsplit.c: static int split_maildir(const char *maildir, const char *dir,\n     + \tchar *file = NULL;\n     + \tFILE *f = NULL;\n     + \tint ret = -1;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct string_list list = STRING_LIST_INIT_DUP;\n     + \n     + \tlist.cmp = maildir_filename_cmp;\n     +\n     + ## builtin/merge-file.c ##\n     +@@ builtin/merge-file.c: int cmd_merge_file(int argc, const char **argv, const char *prefix)\n     + \tmmfile_t mmfs[3] = { 0 };\n     + \tmmbuffer_t result = { 0 };\n     + \txmparam_t xmp = { 0 };\n     +-\tint ret = 0, i = 0, to_stdout = 0;\n     ++\tint ret = 0, to_stdout = 0;\n     ++\tsize_t i = 0;\n     + \tint quiet = 0;\n     + \tstruct option options[] = {\n     + \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\n     +\n     + ## builtin/merge.c ##\n     +@@ builtin/merge.c: static struct strategy *get_strategy(const char *name)\n     + \t\tmemset(&not_strategies, 0, sizeof(struct cmdnames));\n     + \t\tload_command_list(\"git-merge-\", &main_cmds, &other_cmds);\n     + \t\tfor (i = 0; i < main_cmds.cnt; i++) {\n     +-\t\t\tint j, found = 0;\n     ++\t\t\tsize_t j;\n     ++\t\t\tint found = 0;\n     + \t\t\tstruct cmdname *ent = main_cmds.names[i];\n     + \t\t\tfor (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n     + \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\n     +\n     + ## builtin/name-rev.c ##\n     +@@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix)\n     + \t\t}\n     + \t\tstrbuf_release(&sb);\n     + \t} else if (all) {\n     +-\t\tint i, max;\n     ++\t\tunsigned int i, max;\n     + \n     + \t\tmax = get_max_object_index();\n     + \t\tfor (i = 0; i < max; i++) {\n     +@@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix)\n     + \t\t\t\t  always, allow_undefined, data.name_only);\n     + \t\t}\n     + \t} else {\n     +-\t\tint i;\n     ++\t\tunsigned int i;\n     + \t\tfor (i = 0; i < revs.nr; i++)\n     + \t\t\tshow_name(revs.objects[i].item, revs.objects[i].name,\n     + \t\t\t\t  always, allow_undefined, data.name_only);\n     +\n     + ## builtin/pack-objects.c ##\n     +@@ builtin/pack-objects.c: static int want_object_in_pack(const struct object_id *oid,\n     + \tif (uri_protocols.nr) {\n     + \t\tstruct configured_exclusion *ex =\n     + \t\t\toidmap_get(&configured_exclusions, oid);\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tconst char *p;\n     + \n     + \t\tif (ex) {\n     +@@ builtin/pack-objects.c: static void pbase_tree_put(struct pbase_tree_cache *cache)\n     + \tfree(cache);\n     + }\n     + \n     +-static int name_cmp_len(const char *name)\n     ++static size_t name_cmp_len(const char *name)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; name[i] && name[i] != '\\n' && name[i] != '/'; i++)\n     + \t\t;\n     + \treturn i;\n     + }\n     + \n     +-static void add_pbase_object(struct tree_desc *tree,\n     +-\t\t\t     const char *name,\n     +-\t\t\t     int cmplen,\n     +-\t\t\t     const char *fullname)\n     ++static void add_pbase_object(struct tree_desc *tree, const char *name,\n     ++\t\t\t     size_t cmplen, const char *fullname)\n     + {\n     + \tstruct name_entry entry;\n     + \tint cmp;\n     +@@ builtin/pack-objects.c: static void add_pbase_object(struct tree_desc *tree,\n     + \t\t\tstruct tree_desc sub;\n     + \t\t\tstruct pbase_tree_cache *tree;\n     + \t\t\tconst char *down = name+cmplen+1;\n     +-\t\t\tint downlen = name_cmp_len(down);\n     ++\t\t\tsize_t downlen = name_cmp_len(down);\n     + \n     + \t\t\ttree = pbase_tree_get(&entry.oid);\n     + \t\t\tif (!tree)\n     +@@ builtin/pack-objects.c: static void add_extra_kept_packs(const struct string_list *names)\n     + \n     + \tfor (p = get_all_packs(the_repository); p; p = p->next) {\n     + \t\tconst char *name = basename(p->pack_name);\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tif (!p->pack_local)\n     + \t\t\tcontinue;\n     +\n     + ## builtin/pack-redundant.c ##\n     +@@ builtin/pack-redundant.c: static inline struct llist_item *llist_item_get(void)\n     + \t\tnew_item = free_nodes;\n     + \t\tfree_nodes = free_nodes->next;\n     + \t} else {\n     +-\t\tint i = 1;\n     ++\t\tsize_t i;\n     + \t\tALLOC_ARRAY(new_item, BLKSIZE);\n     +-\t\tfor (; i < BLKSIZE; i++)\n     ++\t\tfor (i = 1; i < BLKSIZE; i++)\n     + \t\t\tllist_item_put(&new_item[i]);\n     + \t}\n     + \treturn new_item;\n     +@@ builtin/pack-redundant.c: static int cmp_remaining_objects(const void *a, const void *b)\n     + static void sort_pack_list(struct pack_list **pl)\n     + {\n     + \tstruct pack_list **ary, *p;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tsize_t n = pack_list_size(*pl);\n     + \n     + \tif (n < 2)\n     +\n     + ## builtin/patch-id.c ##\n     +@@ builtin/patch-id.c: static void flush_current_id(int patchlen, struct object_id *id, struct object_i\n     + \t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n     + }\n     + \n     +-static int remove_space(char *line)\n     ++static size_t remove_space(char *line)\n     + {\n     + \tchar *src = line;\n     + \tchar *dst = line;\n     +@@ builtin/patch-id.c: static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n     + \treturn 1;\n     + }\n     + \n     +-static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n     +-\t\t\t   struct strbuf *line_buf, int stable, int verbatim)\n     ++static size_t get_one_patchid(struct object_id *next_oid,\n     ++\t\t\t      struct object_id *result, struct strbuf *line_buf,\n     ++\t\t\t      int stable, int verbatim)\n     + {\n     +-\tint patchlen = 0, found_next = 0;\n     ++\tsize_t patchlen = 0;\n     ++\tint found_next = 0;\n     + \tint before = -1, after = -1;\n     + \tint diff_is_binary = 0;\n     + \tchar pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];\n     +@@ builtin/patch-id.c: static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n     + \twhile (strbuf_getwholeline(line_buf, stdin, '\\n') != EOF) {\n     + \t\tchar *line = line_buf->buf;\n     + \t\tconst char *p = line;\n     +-\t\tint len;\n     ++\t\tsize_t len;\n     + \n     + \t\t/* Possibly skip over the prefix added by \"log\" or \"format-patch\" */\n     + \t\tif (!skip_prefix(line, \"commit \", &p) &&\n     +@@ builtin/patch-id.c: static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n     + static void generate_id_list(int stable, int verbatim)\n     + {\n     + \tstruct object_id oid, n, result;\n     +-\tint patchlen;\n     ++\tsize_t patchlen;\n     + \tstruct strbuf line_buf = STRBUF_INIT;\n     + \n     + \toidclr(&oid);\n     +\n     + ## builtin/pull.c ##\n     +@@ builtin/pull.c: static int get_can_ff(struct object_id *orig_head,\n     + static int already_up_to_date(struct object_id *orig_head,\n     + \t\t\t      struct oid_array *merge_heads)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct commit *ours;\n     + \n     + \tours = lookup_commit_reference(the_repository, orig_head);\n     +\n     + ## builtin/read-tree.c ##\n     +@@ builtin/read-tree.c: static void debug_stage(const char *label, const struct cache_entry *ce,\n     + static int debug_merge(const struct cache_entry * const *stages,\n     + \t\t       struct unpack_trees_options *o)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     +-\tprintf(\"* %d-way merge\\n\", o->merge_size);\n     ++\tprintf(\"* %u-way merge\\n\", o->merge_size);\n     + \tdebug_stage(\"index\", stages[0], o);\n     + \tfor (i = 1; i <= o->merge_size; i++) {\n     + \t\tchar buf[24];\n     +-\t\txsnprintf(buf, sizeof(buf), \"ent#%d\", i);\n     ++\t\txsnprintf(buf, sizeof(buf), \"ent#%u\", i);\n     + \t\tdebug_stage(buf, stages[i], o);\n     + \t}\n     + \treturn 0;\n     +\n     + ## builtin/rebase.c ##\n     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)\n     + \t\toptions.gpg_sign_opt = xstrfmt(\"-S%s\", gpg_sign);\n     + \n     + \tif (exec.nr) {\n     +-\t\tint i;\n     ++\t\tsize_t j;\n     + \n     + \t\timply_merge(&options, \"--exec\");\n     + \n     + \t\tstrbuf_reset(&buf);\n     +-\t\tfor (i = 0; i < exec.nr; i++)\n     +-\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[i].string);\n     ++\t\tfor (j = 0; j < exec.nr; j++)\n     ++\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[j].string);\n     + \t\toptions.cmd = xstrdup(buf.buf);\n     + \t}\n     + \n     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)\n     + \t}\n     + \n     + \tif (strategy_options.nr) {\n     +-\t\tint i;\n     ++\t\tsize_t j;\n     + \n     + \t\tif (!options.strategy)\n     + \t\t\toptions.strategy = \"ort\";\n     + \n     + \t\tstrbuf_reset(&buf);\n     +-\t\tfor (i = 0; i < strategy_options.nr; i++)\n     ++\t\tfor (j = 0; j < strategy_options.nr; j++)\n     + \t\t\tstrbuf_addf(&buf, \" --%s\",\n     +-\t\t\t\t    strategy_options.items[i].string);\n     ++\t\t\t\t    strategy_options.items[j].string);\n     + \t\toptions.strategy_opts = xstrdup(buf.buf);\n     + \t}\n     + \n     +\n     + ## builtin/receive-pack.c ##\n     +@@ builtin/receive-pack.c: static void hmac_hash(unsigned char *out,\n     + \tunsigned char key[GIT_MAX_BLKSZ];\n     + \tunsigned char k_ipad[GIT_MAX_BLKSZ];\n     + \tunsigned char k_opad[GIT_MAX_BLKSZ];\n     +-\tint i;\n     ++\tsize_t i;\n     + \tgit_hash_ctx ctx;\n     + \n     + \t/* RFC 2104 2. (1) */\n     +@@ builtin/receive-pack.c: static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n     + \tstruct oid_array extra = OID_ARRAY_INIT;\n     + \tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n     + \tuint32_t mask = 1 << (cmd->index % 32);\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \ttrace_printf_key(&trace_shallow,\n     + \t\t\t \"shallow: update_shallow_ref %s\\n\", cmd->ref_name);\n     +@@ builtin/receive-pack.c: static const char *unpack_with_sideband(struct shallow_info *si)\n     + \n     + static void prepare_shallow_update(struct shallow_info *si)\n     + {\n     +-\tint i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n     ++\tsize_t i, j, k;\n     ++\tsize_t bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n     ++\tint l;\n     + \n     + \tALLOC_ARRAY(si->used_shallow, si->shallow->nr);\n     + \tassign_shallow_commits_to_refs(si, si->used_shallow, NULL);\n     +@@ builtin/receive-pack.c: static void prepare_shallow_update(struct shallow_info *si)\n     + \tCALLOC_ARRAY(si->reachable, si->shallow->nr);\n     + \tCALLOC_ARRAY(si->shallow_ref, si->ref->nr);\n     + \n     +-\tfor (i = 0; i < si->nr_ours; i++)\n     +-\t\tsi->need_reachability_test[si->ours[i]] = 1;\n     ++\tfor (l = 0; l < si->nr_ours; l++)\n     ++\t\tsi->need_reachability_test[si->ours[l]] = 1;\n     + \n     + \tfor (i = 0; i < si->shallow->nr; i++) {\n     + \t\tif (!si->used_shallow[i])\n     +\n     + ## builtin/remote.c ##\n     +@@ builtin/remote.c: static int add(int argc, const char **argv, const char *prefix)\n     + \tstruct remote *remote;\n     + \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n     + \tconst char *name, *url;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tstruct option options[] = {\n     + \t\tOPT_BOOL('f', \"fetch\", &fetch, N_(\"fetch the remote branches\")),\n     +@@ builtin/remote.c: static int rm(int argc, const char **argv, const char *prefix)\n     + \tstruct string_list branches = STRING_LIST_INIT_DUP;\n     + \tstruct string_list skipped = STRING_LIST_INIT_DUP;\n     + \tstruct branches_for_remote cb_data;\n     +-\tint i, result;\n     ++\tsize_t i;\n     ++\tint result;\n     + \n     + \tmemset(&cb_data, 0, sizeof(cb_data));\n     + \tcb_data.branches = &branches;\n     +@@ builtin/remote.c: static int show_local_info_item(struct string_list_item *item, void *cb_data)\n     + \tstruct branch_info *branch_info = item->util;\n     + \tstruct string_list *merge = &branch_info->merge;\n     + \tint width = show_info->width + 4;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (branch_info->rebase >= REBASE_TRUE && branch_info->merge.nr > 1) {\n     + \t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n     +@@ builtin/remote.c: static int show_all(void)\n     + \tresult = for_each_remote(get_one_entry, &list);\n     + \n     + \tif (!result) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tstring_list_sort(&list);\n     + \t\tfor (i = 0; i < list.nr; i++) {\n     +@@ builtin/remote.c: static int show(int argc, const char **argv, const char *prefix)\n     + \n     + static int set_head(int argc, const char **argv, const char *prefix)\n     + {\n     +-\tint i, opt_a = 0, opt_d = 0, result = 0;\n     ++\tint opt_a = 0, opt_d = 0, result = 0;\n     + \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n     + \tchar *head_name = NULL;\n     + \n     +@@ builtin/remote.c: static int set_head(int argc, const char **argv, const char *prefix)\n     + \t\tif (!states.heads.nr)\n     + \t\t\tresult |= error(_(\"Cannot determine remote HEAD\"));\n     + \t\telse if (states.heads.nr > 1) {\n     ++\t\t\tsize_t i;\n     + \t\t\tresult |= error(_(\"Multiple remote HEAD branches. \"\n     + \t\t\t\t\t  \"Please choose one explicitly with:\"));\n     + \t\t\tfor (i = 0; i < states.heads.nr; i++)\n     +\n     + ## builtin/repack.c ##\n     +@@ builtin/repack.c: static void collect_pack_filenames(struct string_list *fname_nonkept_list,\n     + \n     + \twhile ((e = readdir(dir)) != NULL) {\n     + \t\tsize_t len;\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tif (!strip_suffix(e->d_name, \".pack\", &len))\n     + \t\t\tcontinue;\n     +@@ builtin/repack.c: static struct generated_pack_data *populate_pack_exts(const char *name)\n     + \tstruct stat statbuf;\n     + \tstruct strbuf path = STRBUF_INIT;\n     + \tstruct generated_pack_data *data = xcalloc(1, sizeof(*data));\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n     + \t\tstrbuf_reset(&path);\n     +@@ builtin/repack.c: int cmd_repack(int argc, const char **argv, const char *prefix)\n     + \tstruct pack_geometry *geometry = NULL;\n     + \tstruct strbuf line = STRBUF_INIT;\n     + \tstruct tempfile *refs_snapshot = NULL;\n     +-\tint i, ext, ret;\n     ++\tsize_t i;\n     ++\tint ext, ret;\n     + \tFILE *out;\n     + \tint show_progress;\n     + \n     +\n     + ## builtin/rerere.c ##\n     +@@ builtin/rerere.c: static int diff_two(const char *file1, const char *label1,\n     + int cmd_rerere(int argc, const char **argv, const char *prefix)\n     + {\n     + \tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n     +-\tint i, autoupdate = -1, flags = 0;\n     ++\tsize_t i;\n     ++\tint autoupdate = -1, flags = 0;\n     + \n     + \tstruct option options[] = {\n     + \t\tOPT_SET_INT(0, \"rerere-autoupdate\", &autoupdate,\n     +\n     + ## builtin/reset.c ##\n     +@@ builtin/reset.c: static inline int is_merge(void)\n     + \n     + static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)\n     + {\n     +-\tint i, nr = 0;\n     ++\tunsigned int i, nr = 0;\n     + \tstruct tree_desc desc[2];\n     + \tstruct tree *tree;\n     + \tstruct unpack_trees_options opts;\n     +\n     + ## builtin/rev-parse.c ##\n     +@@ builtin/rev-parse.c: int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n     + \n     + \t\tif (!seen_end_of_options) {\n     + \t\t\tif (!strcmp(arg, \"--local-env-vars\")) {\n     +-\t\t\t\tint i;\n     ++\t\t\t\tsize_t i;\n     + \t\t\t\tfor (i = 0; local_repo_env[i]; i++)\n     + \t\t\t\t\tprintf(\"%s\\n\", local_repo_env[i]);\n     + \t\t\t\tcontinue;\n     +\n     + ## builtin/rm.c ##\n     +@@ builtin/rm.c: static void print_error_files(struct string_list *files_list,\n     + \t\t\t      int *errs)\n     + {\n     + \tif (files_list->nr) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tstruct strbuf err_msg = STRBUF_INIT;\n     + \n     + \t\tstrbuf_addstr(&err_msg, main_msg);\n     +@@ builtin/rm.c: static struct option builtin_rm_options[] = {\n     + int cmd_rm(int argc, const char **argv, const char *prefix)\n     + {\n     + \tstruct lock_file lock_file = LOCK_INIT;\n     +-\tint i, ret = 0;\n     ++\tint i;\n     ++\tunsigned int j;\n     ++\tint ret = 0;\n     + \tstruct pathspec pathspec;\n     + \tchar *seen;\n     + \n     +@@ builtin/rm.c: int cmd_rm(int argc, const char **argv, const char *prefix)\n     + \tif (pathspec_needs_expanded_index(&the_index, &pathspec))\n     + \t\tensure_full_index(&the_index);\n     + \n     +-\tfor (i = 0; i < the_index.cache_nr; i++) {\n     +-\t\tconst struct cache_entry *ce = the_index.cache[i];\n     ++\tfor (j = 0; j < the_index.cache_nr; j++) {\n     ++\t\tconst struct cache_entry *ce = the_index.cache[j];\n     + \n     + \t\tif (!include_sparse &&\n     + \t\t    (ce_skip_worktree(ce) ||\n     +\n     + ## builtin/show-branch.c ##\n     +@@ builtin/show-branch.c: static void name_parent(struct commit *commit, struct commit *parent)\n     + \t\t\t    commit_name->generation + 1);\n     + }\n     + \n     +-static int name_first_parent_chain(struct commit *c)\n     ++static size_t name_first_parent_chain(struct commit *c)\n     + {\n     +-\tint i = 0;\n     ++\tsize_t i = 0;\n     + \twhile (c) {\n     + \t\tstruct commit *p;\n     + \t\tif (!commit_to_name(c))\n     +@@ builtin/show-branch.c: static int name_first_parent_chain(struct commit *c)\n     + \treturn i;\n     + }\n     + \n     +-static void name_commits(struct commit_list *list,\n     +-\t\t\t struct commit **rev,\n     +-\t\t\t char **ref_name,\n     +-\t\t\t int num_rev)\n     ++static void name_commits(struct commit_list *list, struct commit **rev,\n     ++\t\t\t char **ref_name, size_t num_rev)\n     + {\n     + \tstruct commit_list *cl;\n     + \tstruct commit *c;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* First give names to the given heads */\n     + \tfor (cl = list; cl; cl = cl->next) {\n     +@@ builtin/show-branch.c: static int mark_seen(struct commit *commit, struct commit_list **seen_p)\n     + \treturn 0;\n     + }\n     + \n     +-static void join_revs(struct commit_list **list_p,\n     +-\t\t      struct commit_list **seen_p,\n     +-\t\t      int num_rev, int extra)\n     ++static void join_revs(struct commit_list **list_p, struct commit_list **seen_p,\n     ++\t\t      size_t num_rev, int extra)\n     + {\n     +-\tint all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n     +-\tint all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n     ++\tsize_t all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n     ++\tsize_t all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n     + \n     + \twhile (*list_p) {\n     + \t\tstruct commit_list *parents;\n     + \t\tint still_interesting = !!interesting(*list_p);\n     + \t\tstruct commit *commit = pop_commit(list_p);\n     +-\t\tint flags = commit->object.flags & all_mask;\n     ++\t\tunsigned int flags = commit->object.flags & all_mask;\n     + \n     + \t\tif (!still_interesting && extra <= 0)\n     + \t\t\tbreak;\n     +@@ builtin/show-branch.c: static int show_merge_base(struct commit_list *seen, int num_rev)\n     + \treturn exit_status;\n     + }\n     + \n     +-static int show_independent(struct commit **rev,\n     +-\t\t\t    int num_rev,\n     ++static int show_independent(struct commit **rev, size_t num_rev,\n     + \t\t\t    unsigned int *rev_mask)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < num_rev; i++) {\n     + \t\tstruct commit *commit = rev[i];\n     +@@ builtin/show-branch.c: int cmd_show_branch(int ac, const char **av, const char *prefix)\n     + \tchar *reflog_msg[MAX_REVS];\n     + \tstruct commit_list *list = NULL, *seen = NULL;\n     + \tunsigned int rev_mask[MAX_REVS];\n     +-\tint num_rev, i, extra = 0;\n     ++\tsize_t num_rev, i;\n     ++\tint extra = 0;\n     + \tint all_heads = 0, all_remotes = 0;\n     + \tint all_mask, all_revs;\n     + \tenum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;\n     +@@ builtin/show-branch.c: int cmd_show_branch(int ac, const char **av, const char *prefix)\n     + \t\t\t\t\t\tmsg);\n     + \t\t\tfree(logmsg);\n     + \n     +-\t\t\tnth_desc = xstrfmt(\"%s@{%d}\", *av, base+i);\n     ++\t\t\tnth_desc = xstrfmt(\"%s@{%lu}\", *av,\n     ++\t\t\t\t\t   (unsigned long)(base + i));\n     + \t\t\tappend_ref(nth_desc, &oid, 1);\n     + \t\t\tfree(nth_desc);\n     + \t\t}\n     +\n     + ## builtin/show-index.c ##\n     +@@ builtin/show-index.c: static const char *const show_index_usage[] = {\n     + \n     + int cmd_show_index(int argc, const char **argv, const char *prefix)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tunsigned nr;\n     + \tunsigned int version;\n     + \tstatic unsigned int top_index[256];\n     +\n     + ## builtin/sparse-checkout.c ##\n     +@@ builtin/sparse-checkout.c: static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n     + \t}\n     + \n     + \tif (pl.use_cone_patterns) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tstruct pattern_entry *pe;\n     + \t\tstruct hashmap_iter iter;\n     + \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n     +@@ builtin/sparse-checkout.c: static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n     + \n     + static void clean_tracked_sparse_directories(struct repository *r)\n     + {\n     +-\tint i, was_full = 0;\n     ++\tunsigned int i;\n     ++\tint was_full = 0;\n     + \tstruct strbuf path = STRBUF_INIT;\n     + \tsize_t pathlen;\n     + \tstruct string_list_item *item;\n     +@@ builtin/sparse-checkout.c: static char *escaped_pattern(char *pattern)\n     + \n     + static void write_cone_to_file(FILE *fp, struct pattern_list *pl)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct pattern_entry *pe;\n     + \tstruct hashmap_iter iter;\n     + \tstruct string_list sl = STRING_LIST_INIT_DUP;\n     +\n     + ## builtin/stash.c ##\n     +@@ builtin/stash.c: static void diff_include_untracked(const struct stash_info *info, struct diff_op\n     + \tstruct tree *tree[ARRAY_SIZE(oid)];\n     + \tstruct tree_desc tree_desc[ARRAY_SIZE(oid)];\n     + \tstruct unpack_trees_options unpack_tree_opt = { 0 };\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < ARRAY_SIZE(oid); i++) {\n     + \t\ttree[i] = parse_tree_indirect(oid[i]);\n     +@@ builtin/stash.c: static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n     + \n     + \trepo_read_index_preload(the_repository, NULL, 0);\n     + \tif (!include_untracked && ps->nr) {\n     +-\t\tint i;\n     ++\t\tunsigned int i;\n     + \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n     + \n     + \t\t/* TODO: audit for interaction with sparse-index. */\n     +\n     + ## builtin/submodule--helper.c ##\n     +@@ builtin/submodule--helper.c: static int module_list_compute(const char **argv,\n     + \t\t\t       struct pathspec *pathspec,\n     + \t\t\t       struct module_list *list)\n     + {\n     +-\tint i, result = 0;\n     ++\tunsigned int i;\n     ++\tint result = 0;\n     + \tchar *ps_matched = NULL;\n     + \n     + \tparse_pathspec(pathspec, 0,\n     +@@ builtin/submodule--helper.c: static char *get_up_path(const char *path)\n     + \tint i;\n     + \tstruct strbuf sb = STRBUF_INIT;\n     + \n     +-\tfor (i = count_slashes(path); i; i--)\n     ++\tfor (i = count_slashes(path); i > 0; i--)\n     + \t\tstrbuf_addstr(&sb, \"../\");\n     + \n     + \t/*\n     +@@ builtin/submodule--helper.c: static void die_on_index_match(const char *path, int force)\n     + \t\tdie(_(\"index file corrupt\"));\n     + \n     + \tif (ps.nr) {\n     +-\t\tint i;\n     ++\t\tunsigned int i;\n     + \t\tchar *ps_matched = xcalloc(ps.nr, 1);\n     + \n     + \t\t/* TODO: audit for interaction with sparse-index. */\n     +\n     + ## builtin/unpack-objects.c ##\n     +@@ builtin/unpack-objects.c: static void unpack_one(unsigned nr)\n     + \n     + static void unpack_all(void)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n     + \n     + \tnr_objects = ntohl(hdr->hdr_entries);\n     +\n     + ## builtin/update-ref.c ##\n     +@@ builtin/update-ref.c: static void update_refs_stdin(void)\n     + \tstruct strbuf input = STRBUF_INIT, err = STRBUF_INIT;\n     + \tenum update_refs_state state = UPDATE_REFS_OPEN;\n     + \tstruct ref_transaction *transaction;\n     +-\tint i, j;\n     ++\tsize_t i;\n     + \n     + \ttransaction = ref_transaction_begin(&err);\n     + \tif (!transaction)\n     +@@ builtin/update-ref.c: static void update_refs_stdin(void)\n     + \t\t * error in case there is an early EOF to let the command\n     + \t\t * handle missing arguments with a proper error message.\n     + \t\t */\n     +-\t\tfor (j = 1; line_termination == '\\0' && j < cmd->args; j++)\n     ++\t\tfor (i = 1; line_termination == '\\0' && i < cmd->args; i++)\n     + \t\t\tif (strbuf_appendwholeline(&input, stdin, line_termination))\n     + \t\t\t\tbreak;\n     + \n     +\n     + ## builtin/worktree.c ##\n     +@@ builtin/worktree.c: static int prune_cmp(const void *a, const void *b)\n     + \n     + static void prune_dups(struct string_list *l)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tQSORT(l->items, l->nr, prune_cmp);\n     + \tfor (i = 1; i < l->nr; i++) {\n     +@@ builtin/worktree.c: static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n     + \n     + static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; wt[i]; i++) {\n     + \t\tint sha1_len;\n     +@@ builtin/worktree.c: static void validate_no_submodules(const struct worktree *wt)\n     + {\n     + \tstruct index_state istate = { NULL };\n     + \tstruct strbuf path = STRBUF_INIT;\n     +-\tint i, found_submodules = 0;\n     ++\tunsigned int i;\n     ++\tint found_submodules = 0;\n     + \n     + \tif (is_directory(worktree_git_path(wt, \"modules\"))) {\n     + \t\t/*\n     +\n     + ## bulk-checkin.c ##\n     +@@ bulk-checkin.c: static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n     + {\n     + \tunsigned char hash[GIT_MAX_RAWSZ];\n     + \tstruct strbuf packname = STRBUF_INIT;\n     +-\tint i;\n     ++\tuint32_t i;\n     + \n     + \tif (!state->f)\n     + \t\treturn;\n     +@@ bulk-checkin.c: static void flush_batch_fsync(void)\n     + \n     + static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n     + {\n     +-\tint i;\n     ++\tuint32_t i;\n     + \n     + \t/* The object may already exist in the repository */\n     + \tif (has_object_file(oid))\n     +\n     + ## bundle.c ##\n     +@@ bundle.c: static int parse_capability(struct bundle_header *header, const char *capability\n     + \n     + static int parse_bundle_signature(struct bundle_header *header, const char *line)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n     + \t\tif (!strcmp(line, bundle_sigs[i].signature)) {\n     +@@ bundle.c: int is_bundle(const char *path, int quiet)\n     + \n     + static int list_refs(struct string_list *r, int argc, const char **argv)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < r->nr; i++) {\n     + \t\tstruct object_id *oid;\n     +@@ bundle.c: int verify_bundle(struct repository *r,\n     + \tstruct rev_info revs = REV_INFO_INIT;\n     + \tconst char *argv[] = {NULL, \"--all\", NULL};\n     + \tstruct commit *commit;\n     +-\tint i, ret = 0, req_nr;\n     ++\tsize_t i;\n     ++\tint ret = 0;\n     ++\tunsigned int req_nr;\n     + \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n     + \n     + \tif (!r || !r->objects || !r->objects->odb)\n     +@@ bundle.c: out:\n     + static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n     + {\n     + \tstruct child_process pack_objects = CHILD_PROCESS_INIT;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tstrvec_pushl(&pack_objects.args,\n     + \t\t     \"pack-objects\",\n     +@@ bundle.c: static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n     +  */\n     + static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tint ref_count = 0;\n     + \n     + \tfor (i = 0; i < revs->pending.nr; i++) {\n     +@@ bundle.c: int create_bundle(struct repository *r, const char *path,\n     + \tstruct rev_info revs, revs_copy;\n     + \tint min_version = 2;\n     + \tstruct bundle_prerequisites_info bpi;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \t/* init revs to list objects for pack-objects later */\n     + \tsave_commit_buffer = 0;\n     +\n     + ## cache-tree.c ##\n     +@@ cache-tree.c: struct tree* write_in_core_index_as_tree(struct repository *repo) {\n     + \n     + \tret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);\n     + \tif (ret == WRITE_TREE_UNMERGED_INDEX) {\n     +-\t\tint i;\n     ++\t\tunsigned int i;\n     + \t\tbug(\"there are unmerged index entries:\");\n     + \t\tfor (i = 0; i < index_state->cache_nr; i++) {\n     + \t\t\tconst struct cache_entry *ce = index_state->cache[i];\n     +@@ cache-tree.c: static int verify_one(struct repository *r,\n     + \t\t      struct cache_tree *it,\n     + \t\t      struct strbuf *path)\n     + {\n     +-\tint i, pos, len = path->len;\n     ++\tint i, pos;\n     ++\tsize_t len = path->len;\n     + \tstruct strbuf tree_buf = STRBUF_INIT;\n     + \tstruct object_id new_oid;\n     + \n     +@@ cache-tree.c: static int verify_one(struct repository *r,\n     + \t\t\t &new_oid);\n     + \tif (!oideq(&new_oid, &it->oid))\n     + \t\tBUG(\"cache-tree for path %.*s does not match. \"\n     +-\t\t    \"Expected %s got %s\", len, path->buf,\n     +-\t\t    oid_to_hex(&new_oid), oid_to_hex(&it->oid));\n     ++\t\t    \"Expected %s got %s\",\n     ++\t\t    (int)len, path->buf, oid_to_hex(&new_oid),\n     ++\t\t    oid_to_hex(&it->oid));\n     + \tstrbuf_setlen(path, len);\n     + \tstrbuf_release(&tree_buf);\n     + \treturn 0;\n     +\n     + ## cache.h ##\n     +@@ cache.h: void check_repository_format(struct repository_format *fmt);\n     +  */\n     + const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);\n     + #define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)\n     +-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);\n     ++unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n     ++\t\t\t\t       const struct object_id *oid, int len);\n     + #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)\n     + \n     + /* set default permissions by passing mode arguments to open(2) */\n     +@@ cache.h: int repo_interpret_branch_name(struct repository *r,\n     + \n     + int validate_headref(const char *ref);\n     + \n     +-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     +-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     ++int base_name_compare(const char *name1, size_t len1, int mode1,\n     ++\t\t      const char *name2, size_t len2, int mode2);\n     ++int df_name_compare(const char *name1, size_t len1, int mode1,\n     ++\t\t    const char *name2, size_t len2, int mode2);\n     + int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n     +-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n     ++int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n     ++\t\t\t     const char *name2, size_t len2, int stage2);\n     + \n     + void *read_object_with_reference(struct repository *r,\n     + \t\t\t\t const struct object_id *oid,\n     +@@ cache.h: extern const char *askpass_program;\n     + extern const char *excludes_file;\n     + \n     + /* base85 */\n     +-int decode_85(char *dst, const char *line, int linelen);\n     +-void encode_85(char *buf, const unsigned char *data, int bytes);\n     ++int decode_85(char *dst, const char *line, size_t linelen);\n     ++void encode_85(char *buf, const unsigned char *data, size_t bytes);\n     + \n     + /* pkt-line.c */\n     + void packet_trace_identity(const char *prog);\n     +\n     + ## chunk-format.c ##\n     +@@ chunk-format.c: void add_chunk(struct chunkfile *cf,\n     + \n     + int write_chunkfile(struct chunkfile *cf, void *data)\n     + {\n     +-\tint i, result = 0;\n     ++\tsize_t i;\n     ++\tint result = 0;\n     + \tuint64_t cur_offset = hashfile_total(cf->f);\n     + \n     + \ttrace2_region_enter(\"chunkfile\", \"write\", the_repository);\n     +@@ chunk-format.c: int read_table_of_contents(struct chunkfile *cf,\n     + \t\t\t   uint64_t toc_offset,\n     + \t\t\t   int toc_length)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tuint32_t chunk_id;\n     + \tconst unsigned char *table_of_contents = mfile + toc_offset;\n     + \n     +@@ chunk-format.c: int read_chunk(struct chunkfile *cf,\n     + \t       chunk_read_fn fn,\n     + \t       void *data)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < cf->chunks_nr; i++) {\n     + \t\tif (cf->chunks[i].id == chunk_id)\n     +\n     + ## color.c ##\n     +@@ color.c: struct color {\n     +  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n     +  * \"match\" exactly?\n     +  */\n     +-static int match_word(const char *word, int len, const char *match)\n     ++static int match_word(const char *word, size_t len, const char *match)\n     + {\n     + \treturn !strncasecmp(word, match, len) && !match[len];\n     + }\n     +@@ color.c: static int get_hex_color(const char *in, unsigned char *out)\n     +  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n     +  * Otherwise, leave out unchanged and return -1.\n     +  */\n     +-static int parse_ansi_color(struct color *out, const char *name, int len)\n     ++static int parse_ansi_color(struct color *out, const char *name, size_t len)\n     + {\n     + \t/* Positions in array must match ANSI color codes */\n     + \tstatic const char * const color_names[] = {\n     + \t\t\"black\", \"red\", \"green\", \"yellow\",\n     + \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n     + \t};\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tint color_offset = COLOR_FOREGROUND_ANSI;\n     + \n     + \tif (match_word(name, len, \"default\")) {\n     +@@ color.c: static int parse_ansi_color(struct color *out, const char *name, int len)\n     + \treturn -1;\n     + }\n     + \n     +-static int parse_color(struct color *out, const char *name, int len)\n     ++static int parse_color(struct color *out, const char *name, size_t len)\n     + {\n     + \tchar *end;\n     + \tlong val;\n     +@@ color.c: static int parse_attr(const char *name, size_t len)\n     + #undef ATTR\n     + \t};\n     + \tint negate = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (skip_prefix_mem(name, len, \"no\", &name, &len)) {\n     + \t\tskip_prefix_mem(name, len, \"-\", &name, &len);\n     +@@ color.c: int color_parse(const char *value, char *dst)\n     +  * already have the ANSI escape code in it. \"out\" should have enough\n     +  * space in it to fit any color.\n     +  */\n     +-static char *color_output(char *out, int len, const struct color *c, int background)\n     ++static char *color_output(char *out, size_t len, const struct color *c,\n     ++\t\t\t  int background)\n     + {\n     + \tint offset = 0;\n     + \n     +@@ color.c: static int color_empty(const struct color *c)\n     + \treturn c->type <= COLOR_NORMAL;\n     + }\n     + \n     +-int color_parse_mem(const char *value, int value_len, char *dst)\n     ++int color_parse_mem(const char *value, size_t value_len, char *dst)\n     + {\n     + \tconst char *ptr = value;\n     +-\tint len = value_len;\n     ++\tsize_t len = value_len;\n     + \tchar *end = dst + COLOR_MAXLEN;\n     +-\tunsigned int has_reset = 0;\n     ++\tint has_reset = 0;\n     + \tunsigned int attr = 0;\n     + \tstruct color fg = { COLOR_UNSPECIFIED };\n     + \tstruct color bg = { COLOR_UNSPECIFIED };\n     + \n     +-\twhile (len > 0 && isspace(*ptr)) {\n     ++\twhile (len && isspace(*ptr)) {\n     + \t\tptr++;\n     + \t\tlen--;\n     + \t}\n     +@@ color.c: int color_parse_mem(const char *value, int value_len, char *dst)\n     + \t}\n     + \n     + \t/* [reset] [fg [bg]] [attr]... */\n     +-\twhile (len > 0) {\n     ++\twhile (len) {\n     + \t\tconst char *word = ptr;\n     + \t\tstruct color c = { COLOR_UNSPECIFIED };\n     +-\t\tint val, wordlen = 0;\n     ++\t\tint val;\n     ++\t\tsize_t wordlen = 0;\n     + \n     + \t\twhile (len > 0 && !isspace(word[wordlen])) {\n     + \t\t\twordlen++;\n     +@@ color.c: int color_parse_mem(const char *value, int value_len, char *dst)\n       \n       \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n       \t\tint sep = 0;\n     @@ column.c: static void display_table(const struct string_list *list,\n       \tchar *empty_cell;\n       \n       \tmemset(&data, 0, sizeof(data));\n     +@@ column.c: static int parse_option(const char *arg, int len, unsigned int *colopts,\n     + \t\t{ \"row\",    COL_ROW,      COL_LAYOUT_MASK },\n     + \t\t{ \"dense\",  COL_DENSE,    0 },\n     + \t};\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < ARRAY_SIZE(opts); i++) {\n     + \t\tint set = 1, arg_len = len, name_len;\n     +\n     + ## combine-diff.c ##\n     +@@ combine-diff.c: static struct combine_diff_path *intersect_paths(\n     + \n     + \tif (!n) {\n     + \t\tfor (i = 0; i < q->nr; i++) {\n     +-\t\t\tint len;\n     ++\t\t\tsize_t len;\n     + \t\t\tconst char *path;\n     + \t\t\tif (diff_unmodified_pair(q->queue[i]))\n     + \t\t\t\tcontinue;\n     +@@ combine-diff.c: static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n     + \t/* At this point, baseend and newend point to the end of each lists */\n     + \ti--;\n     + \tj--;\n     +-\twhile (i != 0 || j != 0) {\n     ++\twhile (i > 0 || j > 0) {\n     + \t\tif (directions[i][j] == MATCH) {\n     + \t\t\tbaseend->parent_map |= 1<<parent;\n     + \t\t\tbaseend = baseend->prev;\n     +\n     + ## commit-graph.c ##\n     +@@ commit-graph.c: static struct commit_graph *load_commit_graph_chain(struct repository *r,\n     + \tstruct strbuf line = STRBUF_INIT;\n     + \tstruct stat st;\n     + \tstruct object_id *oids;\n     +-\tint i = 0, valid = 1, count;\n     ++\tint i, valid = 1, count;\n     + \tchar *chain_name = get_commit_graph_chain_filename(odb);\n     + \tFILE *fp;\n     + \tint stat_res;\n     +@@ commit-graph.c: static int write_graph_chunk_fanout(struct hashfile *f,\n     + \t\t\t\t    void *data)\n     + {\n     + \tstruct write_commit_graph_context *ctx = data;\n     +-\tint i, count = 0;\n     ++\tunsigned int i;\n     ++\tuint32_t count = 0;\n     + \tstruct commit **list = ctx->commits.list;\n     + \n     + \t/*\n     +@@ commit-graph.c: static int write_graph_chunk_generation_data(struct hashfile *f,\n     + \t\t\t\t\t     void *data)\n     + {\n     + \tstruct write_commit_graph_context *ctx = data;\n     +-\tint i, num_generation_data_overflows = 0;\n     ++\tsize_t i, num_generation_data_overflows = 0;\n     + \n     + \tfor (i = 0; i < ctx->commits.nr; i++) {\n     + \t\tstruct commit *c = ctx->commits.list[i];\n     +@@ commit-graph.c: static int write_graph_chunk_generation_data_overflow(struct hashfile *f,\n     + \t\t\t\t\t\t      void *data)\n     + {\n     + \tstruct write_commit_graph_context *ctx = data;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ctx->commits.nr; i++) {\n     + \t\tstruct commit *c = ctx->commits.list[i];\n     + \t\ttimestamp_t offset = commit_graph_data_at(c)->generation - c->date;\n     +@@ commit-graph.c: static void add_missing_parents(struct write_commit_graph_context *ctx, struct c\n     + \n     + static void close_reachable(struct write_commit_graph_context *ctx)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct commit *commit;\n     + \tenum commit_graph_split_flags flags = ctx->opts ?\n     + \t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n     +@@ commit-graph.c: static void close_reachable(struct write_commit_graph_context *ctx)\n     + \n     + static void compute_topological_levels(struct write_commit_graph_context *ctx)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct commit_list *list = NULL;\n     + \n     + \tif (ctx->report_progress)\n     +@@ commit-graph.c: static void compute_topological_levels(struct write_commit_graph_context *ctx)\n     + \n     + static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct commit_list *list = NULL;\n     + \n     + \tif (ctx->report_progress)\n     +@@ commit-graph.c: static void trace2_bloom_filter_write_statistics(struct write_commit_graph_conte\n     + \n     + static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct progress *progress = NULL;\n     + \tstruct commit **sorted_commits;\n     +-\tint max_new_filters;\n     ++\tsize_t max_new_filters;\n     + \n     + \tinit_bloom_filters();\n     + \n     +\n     + ## commit-reach.c ##\n     +@@ commit-reach.c: int can_all_from_reach_with_flag(struct object_array *from,\n     + \t\t\t\t timestamp_t min_generation)\n     + {\n     + \tstruct commit **list = NULL;\n     +-\tint i;\n     ++\tunsigned int i;\n     ++\tint j;\n     + \tint nr_commits;\n     + \tint result = 1;\n     + \n     +@@ commit-reach.c: int can_all_from_reach_with_flag(struct object_array *from,\n     + \n     + \tQSORT(list, nr_commits, compare_commits_by_gen);\n     + \n     +-\tfor (i = 0; i < nr_commits; i++) {\n     ++\tfor (j = 0; j < nr_commits; j++) {\n     + \t\t/* DFS from list[i] */\n     + \t\tstruct commit_list *stack = NULL;\n     + \n     +-\t\tlist[i]->object.flags |= assign_flag;\n     +-\t\tcommit_list_insert(list[i], &stack);\n     ++\t\tlist[j]->object.flags |= assign_flag;\n     ++\t\tcommit_list_insert(list[j], &stack);\n     + \n     + \t\twhile (stack) {\n     + \t\t\tstruct commit_list *parent;\n     +@@ commit-reach.c: int can_all_from_reach_with_flag(struct object_array *from,\n     + \t\t\t\tpop_commit(&stack);\n     + \t\t}\n     + \n     +-\t\tif (!(list[i]->object.flags & (with_flag | RESULT))) {\n     ++\t\tif (!(list[j]->object.flags & (with_flag | RESULT))) {\n     + \t\t\tresult = 0;\n     + \t\t\tgoto cleanup;\n     + \t\t}\n     +\n     + ## commit.c ##\n     +@@ commit.c: int parse_commit_buffer(struct repository *r, struct commit *item, const void *b\n     + \tstruct object_id parent;\n     + \tstruct commit_list **pptr;\n     + \tstruct commit_graft *graft;\n     +-\tconst int tree_entry_len = the_hash_algo->hexsz + 5;\n     +-\tconst int parent_entry_len = the_hash_algo->hexsz + 7;\n     ++\tconst size_t tree_entry_len = the_hash_algo->hexsz + 5;\n     ++\tconst size_t parent_entry_len = the_hash_algo->hexsz + 7;\n     + \tstruct tree *tree;\n     + \n     + \tif (item->object.parsed)\n     +@@ commit.c: int remove_signature(struct strbuf *buf)\n     + \t\tif (in_signature && line[0] == ' ')\n     + \t\t\tsigp->end = next;\n     + \t\telse if (starts_with(line, \"gpgsig\")) {\n     +-\t\t\tint i;\n     ++\t\t\tunsigned int i;\n     + \t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n     + \t\t\t\tconst char *p;\n     + \t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\n      \n       ## compat/compiler.h ##\n      @@\n     @@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n      +\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n       #endif\n       \n     - \tif (len == info->len)\n     -@@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n     + \tif (len == info->len)\n     +@@ compat/compiler.h: static inline void get_compiler_info(struct strbuf *info)\n     + \n     + static inline void get_libc_info(struct strbuf *info)\n     + {\n     +-\tint len = info->len;\n     ++\tsize_t len = info->len;\n     + \n     + #ifdef __GLIBC__\n     + \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\n     +\n     + ## compat/strcasestr.c ##\n     +@@\n     + \n     + char *gitstrcasestr(const char *haystack, const char *needle)\n     + {\n     +-\tint nlen = strlen(needle);\n     +-\tint hlen = strlen(haystack) - nlen + 1;\n     +-\tint i;\n     ++\tsize_t nlen = strlen(needle);\n     ++\tsize_t hlen = strlen(haystack) - nlen + 1;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < hlen; i++) {\n     +-\t\tint j;\n     ++\t\tsize_t j;\n     + \t\tfor (j = 0; j < nlen; j++) {\n     + \t\t\tunsigned char c1 = haystack[i+j];\n     + \t\t\tunsigned char c2 = needle[j];\n     +-\t\t\tif (toupper(c1) != toupper(c2))\n     ++\t\t\tif (tolower(c1) != tolower(c2))\n     + \t\t\t\tgoto next;\n     + \t\t}\n     + \t\treturn (char *) haystack + i;\n     +\n     + ## compat/unsetenv.c ##\n     +@@ compat/unsetenv.c: int gitunsetenv(const char *name)\n     + #if !defined(__MINGW32__)\n     +      extern char **environ;\n     + #endif\n     +-     int src, dst;\n     ++     size_t src, dst;\n     +      size_t nmln;\n     + \n     +      nmln = strlen(name);\n     +\n     + ## compat/winansi.c ##\n     +@@ compat/winansi.c: static void erase_in_line(void)\n     + \t\t&dummy);\n     + }\n     + \n     +-static void set_attr(char func, const int *params, int paramlen)\n     ++static void set_attr(char func, const int *params, size_t paramlen)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tswitch (func) {\n     + \tcase 'm':\n     + \t\tfor (i = 0; i < paramlen; i++) {\n     +@@ compat/winansi.c: static DWORD WINAPI console_thread(LPVOID unused)\n     + {\n     + \tunsigned char buffer[BUFFER_SIZE];\n     + \tDWORD bytes;\n     +-\tint start, end = 0, c, parampos = 0, state = TEXT;\n     ++\tint start, end = 0, c, state = TEXT;\n     ++\tsize_t parampos = 0;\n     + \tint params[MAX_PARAMS];\n     + \n     + \twhile (1) {\n     +\n     + ## config.c ##\n     +@@ config.c: int git_config_from_parameters(config_fn_t fn, void *data)\n     + \tif (env) {\n     + \t\tunsigned long count;\n     + \t\tchar *endp;\n     +-\t\tint i;\n     ++\t\tunsigned long i;\n     + \n     + \t\tcount = strtoul(env, &endp, 10);\n     + \t\tif (*endp) {\n     +@@ config.c: int git_config_from_parameters(config_fn_t fn, void *data)\n     + \t\tfor (i = 0; i < count; i++) {\n     + \t\t\tconst char *key, *value;\n     + \n     +-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%d\", i);\n     ++\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%lu\", i);\n     + \t\t\tkey = getenv_safe(&to_free, envvar.buf);\n     + \t\t\tif (!key) {\n     + \t\t\t\tret = error(_(\"missing config key %s\"), envvar.buf);\n     +@@ config.c: int git_config_from_parameters(config_fn_t fn, void *data)\n     + \t\t\t}\n     + \t\t\tstrbuf_reset(&envvar);\n     + \n     +-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%d\", i);\n     ++\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%lu\", i);\n     + \t\t\tvalue = getenv_safe(&to_free, envvar.buf);\n     + \t\t\tif (!value) {\n     + \t\t\t\tret = error(_(\"missing config value %s\"), envvar.buf);\n     +@@ config.c: static enum fsync_component parse_fsync_components(const char *var, const char *\n     + \tenum fsync_component positive = 0, negative = 0;\n     + \n     + \twhile (string) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tsize_t len;\n     + \t\tconst char *ep;\n     + \t\tint negated = 0;\n     +@@ config.c: int config_with_options(config_fn_t fn, void *data,\n     + \n     + static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)\n     + {\n     +-\tint i, value_index;\n     ++\tunsigned int i;\n     ++\tsize_t value_index;\n     + \tstruct string_list *values;\n     + \tstruct config_set_element *entry;\n     + \tstruct configset_list *list = &cs->list;\n     +@@ config.c: static ssize_t write_section(int fd, const char *key,\n     + static ssize_t write_pair(int fd, const char *key, const char *value,\n     + \t\t\t  const struct config_store_data *store)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tssize_t ret;\n     + \tconst char *quote = \"\";\n     + \tstruct strbuf sb = STRBUF_INIT;\n     +@@ config.c: static ssize_t write_pair(int fd, const char *key, const char *value,\n     +  */\n     + static void maybe_remove_section(struct config_store_data *store,\n     + \t\t\t\t size_t *begin_offset, size_t *end_offset,\n     +-\t\t\t\t int *seen_ptr)\n     ++\t\t\t\t unsigned int *seen_ptr)\n     + {\n     + \tsize_t begin;\n     +-\tint i, seen, section_seen = 0;\n     ++\tunsigned int i;\n     ++\tunsigned int seen;\n     ++\tint section_seen = 0;\n     + \n     + \t/*\n     + \t * First, ensure that this is the first key, and that there are no\n     + \t * comments before the entry nor before the section header.\n     + \t */\n     + \tseen = *seen_ptr;\n     +-\tfor (i = store->seen[seen]; i > 0; i--) {\n     ++\tfor (i = store->seen[seen]; i; i--) {\n     + \t\tenum config_event_t type = store->parsed[i - 1].type;\n     + \n     + \t\tif (type == CONFIG_EVENT_COMMENT)\n     +@@ config.c: int git_config_set_multivar_in_file_gently(const char *config_filename,\n     + \t} else {\n     + \t\tstruct stat st;\n     + \t\tsize_t copy_begin, copy_end;\n     +-\t\tint i, new_line = 0;\n     ++\t\tunsigned int i;\n     ++\t\tint new_line = 0;\n     + \t\tstruct config_options opts;\n     + \n     + \t\tif (!value_pattern)\n     +@@ config.c: int git_config_set_multivar_in_file_gently(const char *config_filename,\n     + \n     + \t\tfor (i = 0, copy_begin = 0; i < store.seen_nr; i++) {\n     + \t\t\tsize_t replace_end;\n     +-\t\t\tint j = store.seen[i];\n     ++\t\t\tunsigned int j = store.seen[i];\n     + \n     + \t\t\tnew_line = 0;\n     + \t\t\tif (!store.key_seen) {\n     +@@ config.c: void git_config_set_multivar(const char *key, const char *value,\n     + \t\t\t\t\tflags);\n     + }\n     + \n     +-static int section_name_match (const char *buf, const char *name)\n     ++static unsigned int section_name_match(const char *buf, const char *name)\n     + {\n     +-\tint i = 0, j = 0, dot = 0;\n     ++\tunsigned int i = 0, j = 0;\n     ++\tint dot = 0;\n     + \tif (buf[i] != '[')\n     + \t\treturn 0;\n     + \tfor (i = 1; buf[i] && buf[i] != ']'; i++) {\n     +\n     + ## config.h ##\n     +@@ config.h: struct config_set_element {\n     + \n     + struct configset_list_item {\n     + \tstruct config_set_element *e;\n     +-\tint value_index;\n     ++\tsize_t value_index;\n     + };\n     + \n     + /*\n     +\n     + ## connect.c ##\n     +@@ connect.c: static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n     + \t\t\t  const char **unborn_head_target)\n     + {\n     + \tint ret = 1;\n     +-\tint i = 0;\n     ++\tsize_t i;\n     + \tstruct object_id old_oid;\n     + \tstruct ref *ref;\n     + \tstruct string_list line_sections = STRING_LIST_INIT_DUP;\n     +@@ connect.c: static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n     + \t\tgoto out;\n     + \t}\n     + \n     +-\tif (!strcmp(\"unborn\", line_sections.items[i].string)) {\n     +-\t\ti++;\n     ++\tif (!strcmp(\"unborn\", line_sections.items[0].string)) {\n     + \t\tif (unborn_head_target &&\n     +-\t\t    !strcmp(\"HEAD\", line_sections.items[i++].string)) {\n     ++\t\t    !strcmp(\"HEAD\", line_sections.items[1].string)) {\n     + \t\t\t/*\n     + \t\t\t * Look for the symref target (if any). If found,\n     + \t\t\t * return it to the caller.\n     + \t\t\t */\n     +-\t\t\tfor (; i < line_sections.nr; i++) {\n     ++\t\t\tfor (i = 2; i < line_sections.nr; i++) {\n     + \t\t\t\tconst char *arg = line_sections.items[i].string;\n     + \n     + \t\t\t\tif (skip_prefix(arg, \"symref-target:\", &arg)) {\n     +@@ connect.c: static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n     + \t\t}\n     + \t\tgoto out;\n     + \t}\n     +-\tif (parse_oid_hex_algop(line_sections.items[i++].string, &old_oid, &end, reader->hash_algo) ||\n     ++\tif (parse_oid_hex_algop(line_sections.items[0].string, &old_oid, &end,\n     ++\t\t\t\treader->hash_algo) ||\n     + \t    *end) {\n     + \t\tret = 0;\n     + \t\tgoto out;\n     + \t}\n     + \n     +-\tref = alloc_ref(line_sections.items[i++].string);\n     ++\tref = alloc_ref(line_sections.items[1].string);\n     + \n     + \tmemcpy(ref->old_oid.hash, old_oid.hash, reader->hash_algo->rawsz);\n     + \t**list = ref;\n     + \t*list = &ref->next;\n     + \n     +-\tfor (; i < line_sections.nr; i++) {\n     ++\tfor (i = 2; i < line_sections.nr; i++) {\n     + \t\tconst char *arg = line_sections.items[i].string;\n     + \t\tif (skip_prefix(arg, \"symref-target:\", &arg))\n     + \t\t\tref->symref = xstrdup(arg);\n     +@@ connect.c: struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,\n     + \t\t\t     const struct string_list *server_options,\n     + \t\t\t     int stateless_rpc)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct strvec *ref_prefixes = transport_options ?\n     + \t\t&transport_options->ref_prefixes : NULL;\n     + \tconst char **unborn_head_target = transport_options ?\n     +\n     + ## convert.c ##\n     +@@ convert.c: static void trace_encoding(const char *context, const char *path,\n     + {\n     + \tstatic struct trace_key coe = TRACE_KEY_INIT(WORKING_TREE_ENCODING);\n     + \tstruct strbuf trace = STRBUF_INIT;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tstrbuf_addf(&trace, \"%s (%s, considered %s):\\n\", context, path, encoding);\n     + \tfor (i = 0; i < len && buf; ++i) {\n     +-\t\tstrbuf_addf(\n     +-\t\t\t&trace, \"| \\033[2m%2i:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n     +-\t\t\ti,\n     +-\t\t\t(unsigned char) buf[i],\n     +-\t\t\t(buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n     +-\t\t\t((i+1) % 8 && (i+1) < len ? ' ' : '\\n')\n     +-\t\t);\n     ++\t\tstrbuf_addf(&trace,\n     ++\t\t\t    \"| \\033[2m%2u:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n     ++\t\t\t    (unsigned int)i, (unsigned char)buf[i],\n     ++\t\t\t    (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n     ++\t\t\t    ((i + 1) % 8 && (i + 1) < len ? ' ' : '\\n'));\n     + \t}\n     + \tstrbuf_addchars(&trace, '\\n', 1);\n     + \n     +@@ convert.c: struct ident_filter {\n     + \n     + static int is_foreign_ident(const char *str)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!skip_prefix(str, \"$Id: \", &str))\n     + \t\treturn 0;\n     +\n     + ## credential.c ##\n     +@@ credential.c: static int credential_do(struct credential *c, const char *helper,\n     + \n     + void credential_fill(struct credential *c)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (c->username && c->password)\n     + \t\treturn;\n     +@@ credential.c: void credential_fill(struct credential *c)\n     + \n     + void credential_approve(struct credential *c)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n       \n     - static inline void get_libc_info(struct strbuf *info)\n     + \tif (c->approved)\n     + \t\treturn;\n     +@@ credential.c: void credential_approve(struct credential *c)\n     + \n     + void credential_reject(struct credential *c)\n       {\n     --\tint len = info->len;\n     -+\tsize_t len = info->len;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tcredential_apply_config(c);\n       \n     - #ifdef __GLIBC__\n     - \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\n      \n       ## daemon.c ##\n      @@ daemon.c: static struct daemon_service daemon_service[] = {\n     @@ daemon.c: static void set_keep_alive(int sockfd)\n       \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n       \tstruct hostinfo hi = HOSTINFO_INIT;\n       \tstruct strvec env = STRVEC_INIT;\n     +@@ daemon.c: static void socksetup(struct string_list *listen_addr, int listen_port, struct s\n     + \tif (!listen_addr->nr)\n     + \t\tsetup_named_sock(NULL, listen_port, socklist);\n     + \telse {\n     +-\t\tint i, socknum;\n     ++\t\tsize_t i;\n     ++\t\tint socknum;\n     + \t\tfor (i = 0; i < listen_addr->nr; i++) {\n     + \t\t\tsocknum = setup_named_sock(listen_addr->items[i].string,\n     + \t\t\t\t\t\t   listen_port, socklist);\n      @@ daemon.c: static int service_loop(struct socketlist *socklist)\n       \tsignal(SIGCHLD, child_handler);\n       \n     @@ daemon.c: static int service_loop(struct socketlist *socklist)\n       \t\tcheck_dead_children();\n       \n      \n     + ## date.c ##\n     +@@ date.c: static const struct {\n     + \n     + static int match_string(const char *date, const char *str)\n     + {\n     +-\tint i = 0;\n     ++\tint i;\n     + \n     + \tfor (i = 0; *date; date++, str++, i++) {\n     + \t\tif (*date == *str)\n     + \t\t\tcontinue;\n     +-\t\tif (toupper(*date) == toupper(*str))\n     ++\t\tif (tolower(*date) == tolower(*str))\n     + \t\t\tcontinue;\n     + \t\tif (!isalnum(*date))\n     + \t\t\tbreak;\n     +\n     + ## decorate.c ##\n     +@@ decorate.c: static void *insert_decoration(struct decoration *n, const struct object *base,\n     + \n     + static void grow_decoration(struct decoration *n)\n     + {\n     +-\tint i;\n     +-\tint old_size = n->size;\n     ++\tunsigned int i;\n     ++\tunsigned int old_size = n->size;\n     + \tstruct decoration_entry *old_entries = n->entries;\n     + \n     + \tn->size = (old_size + 1000) * 3 / 2;\n     +@@ decorate.c: static void grow_decoration(struct decoration *n)\n     + void *add_decoration(struct decoration *n, const struct object *obj,\n     + \t\tvoid *decoration)\n     + {\n     +-\tint nr = n->nr + 1;\n     ++\tunsigned int nr = n->nr + 1;\n     + \n     + \tif (nr > n->size * 2 / 3)\n     + \t\tgrow_decoration(n);\n     +\n     + ## delta-islands.c ##\n     +@@ delta-islands.c: void resolve_tree_islands(struct repository *r,\n     + {\n     + \tstruct progress *progress_state = NULL;\n     + \tstruct tree_islands_todo *todo;\n     +-\tint nr = 0;\n     +-\tint i;\n     ++\tuint32_t nr = 0;\n     ++\tuint32_t i;\n     + \n     + \tif (!island_marks)\n     + \t\treturn;\n     +@@ delta-islands.c: static const char *core_island_name;\n     + \n     + static void free_config_regexes(struct island_load_data *ild)\n     + {\n     +-\tfor (size_t i = 0; i < ild->nr; i++)\n     ++\tsize_t i;\n     ++\tfor (i = 0; i < ild->nr; i++)\n     + \t\tregfree(&ild->rx[i]);\n     + \tfree(ild->rx);\n     + }\n     +@@ delta-islands.c: static int find_island_for_ref(const char *refname, const struct object_id *oid,\n     + \t * than we support.\n     + \t */\n     + \tregmatch_t matches[16];\n     +-\tint i, m;\n     ++\tint i;\n     ++\tsize_t m;\n     + \tstruct strbuf island_name = STRBUF_INIT;\n     + \n     + \t/* walk backwards to get last-one-wins ordering */\n     +\n     + ## diagnose.c ##\n     +@@ diagnose.c: static struct diagnose_option diagnose_options[] = {\n     + \n     + int option_parse_diagnose(const struct option *opt, const char *arg, int unset)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tenum diagnose_mode *diagnose = opt->value;\n     + \n     + \tif (!arg) {\n     +\n     + ## diff-lib.c ##\n     +@@ diff-lib.c: static int diff_cache(struct rev_info *revs,\n     + \n     + void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct commit *mb_child[2] = {0};\n     + \tstruct commit_list *merge_bases;\n     + \n     +\n     + ## diff-no-index.c ##\n     +@@ diff-no-index.c: int diff_no_index(struct rev_info *revs,\n     + \t\t  int implicit_no_index,\n     + \t\t  int argc, const char **argv)\n     + {\n     +-\tint i, no_index;\n     ++\tunsigned int i;\n     ++\tint no_index;\n     + \tint ret = 1;\n     + \tconst char *paths[2];\n     + \tchar *to_free[ARRAY_SIZE(paths)] = { 0 };\n     +\n       ## diff.c ##\n     +@@ diff.c: static int parse_dirstat_params(struct diff_options *options, const char *params\n     + \tchar *params_copy = xstrdup(params_string);\n     + \tstruct string_list params = STRING_LIST_INIT_NODUP;\n     + \tint ret = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (*params_copy)\n     + \t\tstring_list_split_in_place(&params, params_copy, ',', -1);\n     +@@ diff.c: static void emit_hunk_header(struct emit_callback *ecbdata,\n     + \n     + static struct diff_tempfile *claim_diff_tempfile(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++)\n     + \t\tif (!diff_temp[i].name)\n     + \t\t\treturn diff_temp + i;\n     +@@ diff.c: static struct diff_tempfile *claim_diff_tempfile(void)\n     + \n     + static void remove_tempfile(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++) {\n     + \t\tif (is_tempfile_active(diff_temp[i].tempfile))\n     + \t\t\tdelete_tempfile(&diff_temp[i].tempfile);\n     +@@ diff.c: static void fn_out_diff_words_aux(void *priv,\n     + \n     + /* This function starts looking at *begin, and returns 0 iff a word was found. */\n     + static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n     +-\t\tint *begin, int *end)\n     ++\t\t\t\tlong *begin, long *end)\n     + {\n     + \twhile (word_regex && *begin < buffer->size) {\n     + \t\tregmatch_t match[1];\n     +@@ diff.c: static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n     + static void diff_words_fill(struct diff_words_buffer *buffer, mmfile_t *out,\n     + \t\tregex_t *word_regex)\n     + {\n     +-\tint i, j;\n     ++\tlong i, j;\n     + \tlong alloc = 0;\n     + \n     + \tout->size = 0;\n     +@@ diff.c: static void init_diff_words_data(struct emit_callback *ecbdata,\n     + \t\t\t\t struct diff_filespec *one,\n     + \t\t\t\t struct diff_filespec *two)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct diff_options *o = xmalloc(sizeof(struct diff_options));\n     + \tmemcpy(o, orig_opts, sizeof(struct diff_options));\n     + \n      @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t/* emit data encoded in base85 */\n       \tcp = data;\n     @@ diff.c: static void emit_binary_diff_body(struct diff_options *o,\n       \t\tchar line[71];\n       \t\tdata_size -= bytes;\n       \t\tif (bytes <= 26)\n     +@@ diff.c: static void add_formatted_headers(struct strbuf *msg,\n     + \t\t\t\t  const char *meta,\n     + \t\t\t\t  const char *reset)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < more_headers->nr; i++)\n     + \t\tadd_formatted_header(msg, more_headers->items[i].string,\n     +@@ diff.c: static unsigned int filter_bit['Z' + 1];\n     + \n     + static void prepare_filter_bits(void)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tif (!filter_bit[DIFF_STATUS_ADDED]) {\n     + \t\tfor (i = 0; diff_status_letters[i]; i++)\n     +@@ diff.c: static int diff_opt_diff_filter(const struct option *option,\n     + \t\t\t\tconst char *optarg, int unset)\n     + {\n     + \tstruct diff_options *opt = option->value;\n     +-\tint i, optch;\n     ++\tsize_t i;\n     ++\tint optch;\n     + \n     + \tBUG_ON_OPT_NEG(unset);\n     + \tprepare_filter_bits();\n     +@@ diff.c: static int diff_opt_patience(const struct option *opt,\n     + \t\t\t     const char *arg, int unset)\n     + {\n     + \tstruct diff_options *options = opt->value;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tBUG_ON_OPT_NEG(unset);\n     + \tBUG_ON_OPT_ARG(arg);\n     +@@ diff.c: static void diff_summary(struct diff_options *opt, struct diff_filepair *p)\n     + \n     + struct patch_id_t {\n     + \tgit_hash_ctx *ctx;\n     +-\tint patchlen;\n     ++\tsize_t patchlen;\n     + };\n     + \n     +-static int remove_space(char *line, int len)\n     ++static size_t remove_space(char *line, unsigned long len)\n     + {\n     +-\tint i;\n     ++\tunsigned long i;\n     + \tchar *dst = line;\n     + \tunsigned char c;\n     + \n     +@@ diff.c: void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)\n     + static int patch_id_consume(void *priv, char *line, unsigned long len)\n     + {\n     + \tstruct patch_id_t *data = priv;\n     +-\tint new_len;\n     ++\tsize_t new_len;\n     + \n     + \tif (len > 12 && starts_with(line, \"\\\\ \"))\n     + \t\treturn 0;\n     +@@ diff.c: static int diff_get_patch_id(struct diff_options *options, struct object_id *oid\n     + \t\txdemitconf_t xecfg;\n     + \t\tmmfile_t mf1, mf2;\n     + \t\tstruct diff_filepair *p = q->queue[i];\n     +-\t\tint len1, len2;\n     ++\t\tsize_t len1, len2;\n     + \n     + \t\tmemset(&xpp, 0, sizeof(xpp));\n     + \t\tmemset(&xecfg, 0, sizeof(xecfg));\n      \n       ## dir.c ##\n      @@ dir.c: static void emit_traversal_statistics(struct dir_struct *dir,\n     @@ dir.c: static void emit_traversal_statistics(struct dir_struct *dir,\n       \n       int read_directory(struct dir_struct *dir, struct index_state *istate,\n      -\t\t   const char *path, int len, const struct pathspec *pathspec)\n     -+\t\t   const char *path, unsigned int len, const struct pathspec *pathspec)\n     ++\t\t   const char *path, unsigned int len,\n     ++\t\t   const struct pathspec *pathspec)\n       {\n       \tstruct untracked_cache_dir *untracked;\n       \n     @@ fsck.c: static void prepare_msg_ids(void)\n       \n       \t\tmsg_id_info[i].downcased = q;\n      \n     + ## git.c ##\n     +@@ git.c: static void list_builtins(struct string_list *list, unsigned int exclude_option)\n     + \n     + static void exclude_helpers_from_list(struct string_list *list)\n     + {\n     +-\tint i = 0;\n     ++\tsize_t i = 0;\n     + \n     + \twhile (i < list->nr) {\n     + \t\tif (strstr(list->items[i].string, \"--\"))\n     +\n       ## list-objects-filter-options.c ##\n      @@ list-objects-filter-options.c: void list_objects_filter_copy(\n       \tstruct list_objects_filter_options *dest,\n     @@ list-objects-filter-options.c: void list_objects_filter_copy(\n       \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\n      \n       ## merge-recursive.c ##\n     +@@ merge-recursive.c: static int was_dirty(struct merge_options *opt, const char *path)\n     + \n     + static int make_room_for_path(struct merge_options *opt, const char *path)\n     + {\n     +-\tint status, i;\n     ++\tint status;\n     ++\tsize_t i;\n     + \tconst char *msg = _(\"failed to create path '%s'%s\");\n     + \n     + \t/* Unlink any D/F conflict files that are in the way */\n      @@ merge-recursive.c: static struct commit *get_ref(struct repository *repo,\n       int merge_recursive_generic(struct merge_options *opt,\n       \t\t\t    const struct object_id *head,\n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n       \tstring_list_remove_empty_items(&split, 0);\n      \n     + ## object-name.c ##\n     +@@ object-name.c: static void find_abbrev_len_packed(struct min_abbrev_data *mad)\n     + \t\tfind_abbrev_len_for_pack(p, mad);\n     + }\n     + \n     +-int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n     +-\t\t\t      const struct object_id *oid, int len)\n     ++unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n     ++\t\t\t\t       const struct object_id *oid, int len)\n     + {\n     + \tstruct disambiguate_state ds;\n     + \tstruct min_abbrev_data mad;\n     +@@ object-name.c: const char *repo_find_unique_abbrev(struct repository *r,\n     + \t\t\t\t    const struct object_id *oid,\n     + \t\t\t\t    int len)\n     + {\n     +-\tstatic int bufno;\n     ++\tstatic unsigned int bufno;\n     + \tstatic char hexbuffer[4][GIT_MAX_HEXSZ + 1];\n     + \tchar *hex = hexbuffer[bufno];\n     + \tbufno = (bufno + 1) % ARRAY_SIZE(hexbuffer);\n     +\n       ## range-diff.c ##\n      @@ range-diff.c: static int read_patches(const char *range, struct string_list *list,\n       \tstruct patch_util *util = NULL;\n     @@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n       \t\t\t\tclose(pp->children[i].process.err);\n       \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\n      \n     + ## shallow.c ##\n     +@@ shallow.c: static void post_assign_shallow(struct shallow_info *info,\n     + }\n     + \n     + /* (Delayed) step 7, reachability test at commit level */\n     +-int delayed_reachability_test(struct shallow_info *si, int c)\n     ++int delayed_reachability_test(struct shallow_info *si, size_t c)\n     + {\n     + \tif (si->need_reachability_test[c]) {\n     + \t\tstruct commit *commit = lookup_commit(the_repository,\n     +\n     + ## shallow.h ##\n     +@@ shallow.h: void remove_nonexistent_theirs_shallow(struct shallow_info *);\n     + void assign_shallow_commits_to_refs(struct shallow_info *info,\n     + \t\t\t\t    uint32_t **used,\n     + \t\t\t\t    int *ref_status);\n     +-int delayed_reachability_test(struct shallow_info *si, int c);\n     ++int delayed_reachability_test(struct shallow_info *si, size_t c);\n     + \n     + extern struct trace_key trace_shallow;\n     + \n     +\n       ## strbuf.c ##\n      @@ strbuf.c: struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n       \tstruct strbuf *t;\n     @@ strbuf.c: struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n       \t\tif (max <= 0 || nr + 1 < max) {\n       \t\t\tconst char *end = memchr(str, terminator, slen);\n       \t\t\tif (end)\n     +@@ strbuf.c: void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm,\n     + void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,\n     + \t\t\t\t   const struct object_id *oid, int abbrev_len)\n     + {\n     +-\tint r;\n     ++\tunsigned int r;\n     + \tstrbuf_grow(sb, GIT_MAX_HEXSZ + 1);\n     + \tr = repo_find_unique_abbrev_r(repo, sb->buf + sb->len, oid, abbrev_len);\n     + \tstrbuf_setlen(sb, sb->len + r);\n     +\n     + ## string-list.c ##\n     +@@ string-list.c: int unsorted_string_list_has_string(struct string_list *list,\n     + \treturn unsorted_string_list_lookup(list, string) != NULL;\n     + }\n     + \n     +-void unsorted_string_list_delete_item(struct string_list *list, int i, int free_util)\n     ++void unsorted_string_list_delete_item(struct string_list *list, size_t i,\n     ++\t\t\t\t      int free_util)\n     + {\n     + \tif (list->strdup_strings)\n     + \t\tfree(list->items[i].string);\n      \n     - ## strvec.h ##\n     -@@ strvec.h: extern const char *empty_strvec[];\n     + ## string-list.h ##\n     +@@ string-list.h: struct string_list_item *unsorted_string_list_lookup(struct string_list *list,\n     +  * string_list is set. The third parameter controls if the `util`\n     +  * pointer of the items should be freed or not.\n        */\n     - struct strvec {\n     - \tconst char **v;\n     --\tsize_t nr;\n     -+\tint nr;\n     - \tsize_t alloc;\n     - };\n     +-void unsorted_string_list_delete_item(struct string_list *list, int i, int free_util);\n     ++void unsorted_string_list_delete_item(struct string_list *list, size_t i,\n     ++\t\t\t\t      int free_util);\n     + \n     + /**\n     +  * Split string into substrings on character `delim` and append the\n     +\n     + ## sub-process.c ##\n     +@@ sub-process.c: static int handshake_version(struct child_process *process,\n     + \t\t\t     int *chosen_version)\n     + {\n     + \tint version_scratch;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tchar *line;\n     + \tconst char *p;\n     + \n     +@@ sub-process.c: static int handshake_capabilities(struct child_process *process,\n     + \t\t\t\t  struct subprocess_capability *capabilities,\n     + \t\t\t\t  unsigned int *supported_capabilities)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tchar *line;\n     + \n     + \tfor (i = 0; capabilities[i].name; i++) {\n     +\n     + ## submodule.c ##\n     +@@ submodule.c: void add_submodule_odb_by_path(const char *path)\n     + \tstring_list_insert(&added_submodule_odb_paths, xstrdup(path));\n     + }\n     + \n     +-int register_all_submodule_odb_as_alternates(void)\n     ++size_t register_all_submodule_odb_as_alternates(void)\n     + {\n     +-\tint i;\n     +-\tint ret = added_submodule_odb_paths.nr;\n     ++\tsize_t i;\n     ++\tsize_t ret = added_submodule_odb_paths.nr;\n     + \n     + \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n     + \t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n     +@@ submodule.c: int is_submodule_populated_gently(const char *path, int *return_error_code)\n     + void die_in_unpopulated_submodule(struct index_state *istate,\n     + \t\t\t\t  const char *prefix)\n     + {\n     +-\tint i, prefixlen;\n     ++\tsize_t i, prefixlen;\n     + \n     + \tif (!prefix)\n     + \t\treturn;\n     +@@ submodule.c: void die_in_unpopulated_submodule(struct index_state *istate,\n     + \n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     + \t\tstruct cache_entry *ce = istate->cache[i];\n     +-\t\tint ce_len = ce_namelen(ce);\n     ++\t\tsize_t ce_len = ce_namelen(ce);\n     + \n     + \t\tif (!S_ISGITLINK(ce->ce_mode))\n     + \t\t\tcontinue;\n     +@@ submodule.c: void die_in_unpopulated_submodule(struct index_state *istate,\n     + void die_path_inside_submodule(struct index_state *istate,\n     + \t\t\t       const struct pathspec *ps)\n     + {\n     +-\tint i, j;\n     ++\tunsigned int i;\n     ++\tint j;\n     + \n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     + \t\tstruct cache_entry *ce = istate->cache[i];\n     +@@ submodule.c: int push_unpushed_submodules(struct repository *r,\n     + \t\t\t     const struct string_list *push_options,\n     + \t\t\t     int dry_run)\n     + {\n     +-\tint i, ret = 1;\n     ++\tsize_t i;\n     ++\tint ret = 1;\n     + \tstruct string_list needs_pushing = STRING_LIST_INIT_DUP;\n     + \n     + \tif (!find_unpushed_submodules(r, commits,\n     +\n     + ## submodule.h ##\n     +@@ submodule.h: int bad_to_remove_submodule(const char *path, unsigned flags);\n     +  * added as alternates in the_repository.\n     +  */\n     + void add_submodule_odb_by_path(const char *path);\n     +-int register_all_submodule_odb_as_alternates(void);\n     ++size_t register_all_submodule_odb_as_alternates(void);\n     + \n     + /*\n     +  * Checks if there are submodule changes in a..b. If a is the null OID,\n     +\n     + ## trailer.c ##\n     +@@ trailer.c: static int git_trailer_config(const char *conf_key, const char *value,\n     + \tstruct conf_info *conf;\n     + \tchar *name = NULL;\n     + \tenum trailer_info_type type;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!skip_prefix(conf_key, \"trailer.\", &trailer_item))\n     + \t\treturn 0;\n     +\n     + ## transport-helper.c ##\n     +@@ transport-helper.c: static int string_list_set_helper_option(struct helper_data *data,\n     + \t\t\t\t\t struct string_list *list)\n     + {\n     + \tstruct strbuf buf = STRBUF_INIT;\n     +-\tint i, ret = 0;\n     ++\tint ret = 0;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < list->nr; i++) {\n     + \t\tstrbuf_addf(&buf, \"option %s \", name);\n     +@@ transport-helper.c: static int set_helper_option(struct transport *transport,\n     + {\n     + \tstruct helper_data *data = transport->data;\n     + \tstruct strbuf buf = STRBUF_INIT;\n     +-\tint i, ret, is_bool = 0;\n     ++\tsize_t i;\n     ++\tint ret, is_bool = 0;\n     + \n     + \tget_helper(transport);\n     + \n     +@@ transport-helper.c: static int get_exporter(struct transport *transport,\n     + {\n     + \tstruct helper_data *data = transport->data;\n     + \tstruct child_process *helper = get_helper(transport);\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tchild_process_init(fastexport);\n     + \n     +\n     + ## transport.c ##\n     +@@ transport.c: static int transport_color_config(void)\n     + \t\t\"color.transport.rejected\"\n     + \t}, *key = \"color.transport\";\n     + \tchar *value;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstatic int initialized;\n     + \n     + \tif (initialized)\n     +@@ transport.c: static struct ref *get_refs_from_bundle(struct transport *transport,\n     + {\n     + \tstruct bundle_transport_data *data = transport->data;\n     + \tstruct ref *result = NULL;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (for_push)\n     + \t\treturn NULL;\n     +@@ transport.c: void transport_set_verbosity(struct transport *transport, int verbosity,\n       \n     + static void die_with_unpushed_submodules(struct string_list *needs_pushing)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfprintf(stderr, _(\"The following submodule paths contain changes that can\\n\"\n     + \t\t\t\"not be found on any remote:\\n\"));\n     +@@ transport.c: int transport_get_remote_bundle_uri(struct transport *transport)\n     + void transport_unlock_pack(struct transport *transport, unsigned int flags)\n     + {\n     + \tint in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < transport->pack_lockfiles.nr; i++)\n     + \t\tif (in_signal_handler)\n      \n       ## unpack-trees.c ##\n      @@ unpack-trees.c: static int verify_clean_subdirectory(const struct cache_entry *ce,\n     @@ unpack-trees.c: static int verify_clean_subdirectory(const struct cache_entry *c\n       \n       \tmemset(&d, 0, sizeof(d));\n       \tif (o->dir)\n     +@@ unpack-trees.c: int twoway_merge(const struct cache_entry * const *src,\n     + \tconst struct cache_entry *newtree = src[2];\n     + \n     + \tif (o->merge_size != 2)\n     +-\t\treturn error(\"Cannot do a twoway merge of %d trees\",\n     ++\t\treturn error(\"Cannot do a twoway merge of %u trees\",\n     + \t\t\t     o->merge_size);\n     + \n     + \tif (oldtree == o->df_conflict_entry)\n     +@@ unpack-trees.c: int bind_merge(const struct cache_entry * const *src,\n     + \tconst struct cache_entry *a = src[1];\n     + \n     + \tif (o->merge_size != 1)\n     +-\t\treturn error(\"Cannot do a bind merge of %d trees\",\n     ++\t\treturn error(\"Cannot do a bind merge of %u trees\",\n     + \t\t\t     o->merge_size);\n     + \tif (a && old)\n     + \t\treturn o->quiet ? -1 :\n     +@@ unpack-trees.c: int oneway_merge(const struct cache_entry * const *src,\n     + \tconst struct cache_entry *a = src[1];\n     + \n     + \tif (o->merge_size != 1)\n     +-\t\treturn error(\"Cannot do a oneway merge of %d trees\",\n     ++\t\treturn error(\"Cannot do a oneway merge of %u trees\",\n     + \t\t\t     o->merge_size);\n     + \n     + \tif (!a || a == o->df_conflict_entry)\n     +@@ unpack-trees.c: int stash_worktree_untracked_merge(const struct cache_entry * const *src,\n     + \tconst struct cache_entry *untracked = src[2];\n     + \n     + \tif (o->merge_size != 2)\n     +-\t\tBUG(\"invalid merge_size: %d\", o->merge_size);\n     ++\t\tBUG(\"invalid merge_size: %u\", o->merge_size);\n     + \n     + \tif (worktree && untracked)\n     + \t\treturn error(_(\"worktree and untracked commit have duplicate entries: %s\"),\n     +\n     + ## unpack-trees.h ##\n     +@@ unpack-trees.h: struct unpack_trees_options {\n     + \tstruct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES];\n     + \n     + \tint head_idx;\n     +-\tint merge_size;\n     ++\tunsigned merge_size;\n     + \n     + \tstruct cache_entry *df_conflict_entry;\n     + \tvoid *unpack_data;\n     +\n     + ## wt-status.c ##\n     +@@ wt-status.c: void wt_status_prepare(struct repository *r, struct wt_status *s)\n     + \n     + static void wt_longstatus_print_unmerged_header(struct wt_status *s)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tint del_mod_conflict = 0;\n     + \tint both_deleted = 0;\n     + \tint not_deleted = 0;\n     +@@ wt-status.c: static int add_file_to_list(const struct object_id *oid,\n     + static void wt_status_collect_changes_initial(struct wt_status *s)\n     + {\n     + \tstruct index_state *istate = s->repo->index;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     + \t\tstruct string_list_item *it;\n     +@@ wt-status.c: static void wt_status_collect_untracked(struct wt_status *s)\n     + \n     + static int has_unmerged(struct wt_status *s)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < s->change.nr; i++) {\n     + \t\tstruct wt_status_change_data *d;\n     +@@ wt-status.c: void wt_status_state_free_buffers(struct wt_status_state *state)\n     + static void wt_longstatus_print_unmerged(struct wt_status *s)\n     + {\n     + \tint shown_header = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < s->change.nr; i++) {\n     + \t\tstruct wt_status_change_data *d;\n     +@@ wt-status.c: static void wt_longstatus_print_unmerged(struct wt_status *s)\n     + static void wt_longstatus_print_updated(struct wt_status *s)\n     + {\n     + \tint shown_header = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < s->change.nr; i++) {\n     + \t\tstruct wt_status_change_data *d;\n     +@@ wt-status.c: static void wt_longstatus_print_updated(struct wt_status *s)\n     + static int wt_status_check_worktree_changes(struct wt_status *s,\n     + \t\t\t\t\t     int *dirty_submodules)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tint changes = 0;\n     + \n     + \t*dirty_submodules = 0;\n     +@@ wt-status.c: static int wt_status_check_worktree_changes(struct wt_status *s,\n     + \n     + static void wt_longstatus_print_changed(struct wt_status *s)\n     + {\n     +-\tint i, dirty_submodules;\n     ++\tsize_t i;\n     ++\tint dirty_submodules;\n     + \tint worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);\n     + \n     + \tif (!worktree_changes)\n     +@@ wt-status.c: static void wt_longstatus_print_other(struct wt_status *s,\n     + \t\t\t\t      const char *what,\n     + \t\t\t\t      const char *how)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct strbuf buf = STRBUF_INIT;\n     + \tstatic struct string_list output = STRING_LIST_INIT_DUP;\n     + \tstruct column_options copts;\n     +@@ wt-status.c: static void wt_longstatus_print_tracking(struct wt_status *s)\n     + \tconst char *cp, *ep, *branch_name;\n     + \tstruct branch *branch;\n     + \tchar comment_line_string[3];\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tuint64_t t_begin = 0;\n     + \n     + \tassert(s->branch && !s->is_initial);\n     +@@ wt-status.c: static int split_commit_in_progress(struct wt_status *s)\n     + static void abbrev_oid_in_line(struct strbuf *line)\n     + {\n     + \tstruct strbuf **split;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (starts_with(line->buf, \"exec \") ||\n     + \t    starts_with(line->buf, \"x \") ||\n     +@@ wt-status.c: static void show_rebase_information(struct wt_status *s,\n     + \t\t\t\t    const char *color)\n     + {\n     + \tif (s->state.rebase_interactive_in_progress) {\n     +-\t\tint i;\n     +-\t\tint nr_lines_to_show = 2;\n     ++\t\tsize_t i;\n     ++\t\tconst size_t nr_lines_to_show = 2;\n     + \n     + \t\tstruct string_list have_done = STRING_LIST_INIT_DUP;\n     + \t\tstruct string_list yet_to_do = STRING_LIST_INIT_DUP;\n     +@@ wt-status.c: static void wt_status_check_sparse_checkout(struct repository *r,\n     + \t\t\t\t\t    struct wt_status_state *state)\n     + {\n     + \tint skip_worktree = 0;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tif (!core_apply_sparse_checkout || r->index->cache_nr == 0) {\n     + \t\t/*\n     +@@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s)\n     + {\n     + \tstruct wt_status_change_data *d;\n     + \tstruct string_list_item *it;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (s->show_branch)\n     + \t\twt_porcelain_v2_print_tracking(s);\n      \n       ## xdiff-interface.c ##\n      @@ xdiff-interface.c: static long ff_regexp(const char *line, long len,\n\n\n add-interactive.c             | 29 +++++++++-------\n add-patch.c                   |  3 +-\n advice.c                      |  2 +-\n apply.c                       | 64 ++++++++++++++++-------------------\n apply.h                       |  8 ++---\n archive-tar.c                 |  8 ++---\n archive.c                     |  2 +-\n attr.c                        |  3 +-\n base85.c                      | 11 +++---\n bisect.c                      |  2 +-\n blame.c                       | 20 +++++------\n block-sha1/sha1.c             |  2 +-\n bloom.c                       | 10 +++---\n branch.c                      |  4 +--\n builtin/add.c                 |  3 +-\n builtin/fast-export.c         |  4 +--\n builtin/fast-import.c         |  2 +-\n builtin/fetch-pack.c          |  2 +-\n builtin/fetch.c               |  7 ++--\n builtin/for-each-repo.c       |  3 +-\n builtin/fsck.c                |  2 +-\n builtin/gc.c                  | 43 ++++++++++++-----------\n builtin/grep.c                |  5 +--\n builtin/help.c                |  2 +-\n builtin/log.c                 |  4 +--\n builtin/ls-files.c            | 24 ++++++-------\n builtin/ls-remote.c           |  1 -\n builtin/mailsplit.c           |  2 +-\n builtin/merge-file.c          |  3 +-\n builtin/merge.c               |  3 +-\n builtin/name-rev.c            |  4 +--\n builtin/pack-objects.c        | 16 ++++-----\n builtin/pack-redundant.c      |  6 ++--\n builtin/patch-id.c            | 14 ++++----\n builtin/pull.c                |  2 +-\n builtin/read-tree.c           |  6 ++--\n builtin/rebase.c              | 12 +++----\n builtin/receive-pack.c        | 12 ++++---\n builtin/remote.c              | 12 ++++---\n builtin/repack.c              |  7 ++--\n builtin/rerere.c              |  3 +-\n builtin/reset.c               |  2 +-\n builtin/rev-parse.c           |  2 +-\n builtin/rm.c                  | 10 +++---\n builtin/show-branch.c         | 34 +++++++++----------\n builtin/show-index.c          |  2 +-\n builtin/sparse-checkout.c     |  7 ++--\n builtin/stash.c               |  4 +--\n builtin/submodule--helper.c   |  7 ++--\n builtin/unpack-objects.c      |  2 +-\n builtin/update-ref.c          |  4 +--\n builtin/worktree.c            |  7 ++--\n bulk-checkin.c                |  4 +--\n bundle.c                      | 14 ++++----\n cache-tree.c                  | 10 +++---\n cache.h                       | 16 +++++----\n chunk-format.c                |  7 ++--\n color.c                       | 32 ++++++++++--------\n color.h                       |  2 +-\n column.c                      |  9 ++---\n combine-diff.c                |  4 +--\n commit-graph.c                | 19 ++++++-----\n commit-reach.c                | 11 +++---\n commit.c                      |  6 ++--\n compat/compiler.h             |  9 ++---\n compat/strcasestr.c           | 10 +++---\n compat/unsetenv.c             |  2 +-\n compat/winansi.c              |  7 ++--\n config.c                      | 31 ++++++++++-------\n config.h                      |  2 +-\n connect.c                     | 18 +++++-----\n convert.c                     | 16 ++++-----\n credential.c                  |  6 ++--\n daemon.c                      | 14 ++++----\n date.c                        |  4 +--\n decorate.c                    |  6 ++--\n delta-islands.c               | 10 +++---\n diagnose.c                    |  2 +-\n diff-lib.c                    |  2 +-\n diff-no-index.c               |  3 +-\n diff.c                        | 35 +++++++++----------\n dir.c                         |  3 +-\n dir.h                         |  2 +-\n fsck.c                        |  4 +--\n git.c                         |  2 +-\n list-objects-filter-options.c |  2 +-\n merge-recursive.c             |  7 ++--\n merge-recursive.h             |  2 +-\n notes.c                       |  2 +-\n object-name.c                 |  6 ++--\n range-diff.c                  | 15 ++++----\n read-cache.c                  | 49 ++++++++++++++-------------\n run-command.c                 | 11 +++---\n shallow.c                     |  2 +-\n shallow.h                     |  2 +-\n strbuf.c                      |  4 +--\n string-list.c                 |  3 +-\n string-list.h                 |  3 +-\n sub-process.c                 |  4 +--\n submodule.c                   | 16 +++++----\n submodule.h                   |  2 +-\n trailer.c                     |  2 +-\n transport-helper.c            |  8 +++--\n transport.c                   |  8 ++---\n unpack-trees.c                | 16 ++++-----\n unpack-trees.h                |  2 +-\n wt-status.c                   | 29 ++++++++--------\n xdiff-interface.c             |  6 ++--\n 108 files changed, 515 insertions(+), 461 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..5ece4dab996 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -218,7 +218,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n struct list_options {\n \tint columns;\n \tconst char *header;\n-\tvoid (*print_item)(int i, int selected, struct string_list_item *item,\n+\tvoid (*print_item)(size_t i, int selected,\n+\t\t\t   struct string_list_item *item,\n \t\t\t   void *print_item_data);\n \tvoid *print_item_data;\n };\n@@ -226,7 +227,8 @@ struct list_options {\n static void list(struct add_i_state *s, struct string_list *list, int *selected,\n \t\t struct list_options *opts)\n {\n-\tint i, last_lf = 0;\n+\tsize_t i;\n+\tint last_lf = 0;\n \n \tif (!list->nr)\n \t\treturn;\n@@ -469,7 +471,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\n@@ -528,7 +530,7 @@ static int get_modified_files(struct repository *r,\n \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t     &head_oid, NULL);\n \tstruct collection_status s = { 0 };\n-\tint i;\n+\tunsigned int i;\n \n \tdiscard_index(r->index);\n \tif (repo_read_index_preload(r, ps, 0) < 0)\n@@ -617,12 +619,14 @@ struct print_file_item_data {\n \tunsigned only_names:1;\n };\n \n-static void print_file_item(int i, int selected, struct string_list_item *item,\n+static void print_file_item(size_t i, int selected,\n+\t\t\t    struct string_list_item *item,\n \t\t\t    void *print_file_item_data)\n {\n \tstruct file_item *c = item->util;\n \tstruct print_file_item_data *d = print_file_item_data;\n \tconst char *highlighted = NULL;\n+\tunsigned int e = (unsigned int)i + 1;\n \n \tstrbuf_reset(&d->index);\n \tstrbuf_reset(&d->worktree);\n@@ -639,7 +643,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \t}\n \n \tif (d->only_names) {\n-\t\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1,\n+\t\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e,\n \t\t       highlighted ? highlighted : item->string);\n \t\treturn;\n \t}\n@@ -650,7 +654,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \tstrbuf_addf(&d->buf, d->modified_fmt, d->index.buf, d->worktree.buf,\n \t\t    highlighted ? highlighted : item->string);\n \n-\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1, d->buf.buf);\n+\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e, d->buf.buf);\n }\n \n static int run_status(struct add_i_state *s, const struct pathspec *ps,\n@@ -1067,20 +1071,21 @@ struct print_command_item_data {\n \tconst char *color, *reset;\n };\n \n-static void print_command_item(int i, int selected,\n+static void print_command_item(size_t i, int selected,\n \t\t\t       struct string_list_item *item,\n \t\t\t       void *print_command_item_data)\n {\n+\tunsigned int e = (unsigned int)(i + 1);\n \tstruct print_command_item_data *d = print_command_item_data;\n \tstruct command_item *util = item->util;\n \n \tif (!util->prefix_length ||\n \t    !is_valid_prefix(item->string, util->prefix_length))\n-\t\tprintf(\" %2d: %s\", i + 1, item->string);\n+\t\tprintf(\" %2u: %s\", e, item->string);\n \telse\n-\t\tprintf(\" %2d: %s%.*s%s%s\", i + 1,\n-\t\t       d->color, (int)util->prefix_length, item->string,\n-\t\t       d->reset, item->string + util->prefix_length);\n+\t\tprintf(\" %2u: %s%.*s%s%s\", e, d->color,\n+\t\t       (int)util->prefix_length, item->string, d->reset,\n+\t\t       item->string + util->prefix_length);\n }\n \n static void command_prompt_help(struct add_i_state *s)\ndiff --git a/add-patch.c b/add-patch.c\nindex a86a92e1646..be049301bb1 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -377,9 +377,10 @@ static int is_octal(const char *p, size_t len)\n \tif (!len)\n \t\treturn 0;\n \n-\twhile (len--)\n+\tdo {\n \t\tif (*p < '0' || *(p++) > '7')\n \t\t\treturn 0;\n+\t} while (--len);\n \treturn 1;\n }\n \ndiff --git a/advice.c b/advice.c\nindex fd189689437..eb2e2f6b863 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -138,7 +138,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)\n int git_default_advice_config(const char *var, const char *value)\n {\n \tconst char *k, *slot_name;\n-\tint i;\n+\tsize_t i;\n \n \tif (!strcmp(var, \"color.advice\")) {\n \t\tadvice_use_color = git_config_colorbool(var, value);\ndiff --git a/apply.c b/apply.c\nindex 85822280476..22b9c6e4c65 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1068,7 +1068,7 @@ static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n \t\t\t\t const char *line,\n \t\t\t\t struct patch *patch)\n {\n-\tunsigned long val = strtoul(line, NULL, 10);\n+\tint val = atoi(line);\n \tif (val <= 100)\n \t\tpatch->score = val;\n \treturn 0;\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -1125,12 +1125,10 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n  * Skip p_value leading components from \"line\"; as we do not accept\n  * absolute paths, return NULL in that case.\n  */\n-static const char *skip_tree_prefix(int p_value,\n-\t\t\t\t    const char *line,\n-\t\t\t\t    int llen)\n+static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n {\n \tint nslash;\n-\tint i;\n+\tsize_t i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n@@ -1152,9 +1150,7 @@ static const char *skip_tree_prefix(int p_value,\n  * creation or deletion of an empty file.  In any of these cases,\n  * both sides are the same name under a/ and b/ respectively.\n  */\n-static char *git_header_name(int p_value,\n-\t\t\t     const char *line,\n-\t\t\t     int llen)\n+static char *git_header_name(int p_value, const char *line, size_t llen)\n {\n \tconst char *name;\n \tconst char *second = NULL;\n@@ -1302,12 +1298,8 @@ static int check_header_line(int linenr, struct patch *patch)\n \treturn 0;\n }\n \n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch)\n {\n \tunsigned long offset;\n@@ -1360,14 +1352,14 @@ int parse_git_diff_header(struct strbuf *root,\n \t\t\t{ \"index \", gitdiff_index },\n \t\t\t{ \"\", gitdiff_unrecognized },\n \t\t};\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tlen = linelen(line, size);\n \t\tif (!len || line[len-1] != '\\n')\n \t\t\tbreak;\n \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n \t\t\tconst struct opentry *p = optable + i;\n-\t\t\tint oplen = strlen(p->str);\n+\t\t\tsize_t oplen = strlen(p->str);\n \t\t\tint res;\n \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n \t\t\t\tcontinue;\n@@ -1391,7 +1383,7 @@ done:\n \t\t\t\t \"%d leading pathname components (line %d)\",\n \t\t\t\t parse_hdr_state.p_value),\n \t\t\t      parse_hdr_state.p_value, *linenr);\n-\t\t\treturn -128;\n+\t\t\treturn -1;\n \t\t}\n \t\tpatch->old_name = xstrdup(patch->def_name);\n \t\tpatch->new_name = xstrdup(patch->def_name);\n@@ -1400,7 +1392,7 @@ done:\n \t    (!patch->old_name && !patch->is_new)) {\n \t\terror(_(\"git diff header lacks filename information \"\n \t\t\t\"(line %d)\"), *linenr);\n-\t\treturn -128;\n+\t\treturn -1;\n \t}\n \tpatch->is_toplevel_relative = 1;\n \treturn offset;\n@@ -1454,22 +1446,23 @@ static int parse_range(const char *line, int len, int offset, const char *expect\n \treturn offset + ex;\n }\n \n-static void recount_diff(const char *line, int size, struct fragment *fragment)\n+static void recount_diff(const char *line, size_t size,\n+\t\t\t struct fragment *fragment)\n {\n \tint oldlines = 0, newlines = 0, ret = 0;\n \n-\tif (size < 1) {\n+\tif (size == 0) {\n \t\twarning(\"recount: ignore empty hunk\");\n \t\treturn;\n \t}\n \n \tfor (;;) {\n-\t\tint len = linelen(line, size);\n-\t\tsize -= len;\n-\t\tline += len;\n+\t\tsize_t len = linelen(line, size);\n \n-\t\tif (size < 1)\n+\t\tif (size <= len)\n \t\t\tbreak;\n+\t\tsize -= len;\n+\t\tline += len;\n \n \t\tswitch (*line) {\n \t\tcase ' ': case '\\n':\n@@ -2086,7 +2079,7 @@ static void add_name_limit(struct apply_state *state,\n static int use_patch(struct apply_state *state, struct patch *p)\n {\n \tconst char *pathname = p->new_name ? p->new_name : p->old_name;\n-\tint i;\n+\tsize_t i;\n \n \t/* Paths outside are not touched regardless of \"--include\" */\n \tif (state->prefix && *state->prefix) {\n@@ -2172,9 +2165,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\n@@ -2384,8 +2377,9 @@ static void update_pre_post_images(struct image *preimage,\n \tif (postlen\n \t    ? postlen < new_buf - postimage->buf\n \t    : postimage->len < new_buf - postimage->buf)\n-\t\tBUG(\"caller miscounted postlen: asked %d, orig = %d, used = %d\",\n-\t\t    (int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));\n+\t\tBUG(\"caller miscounted postlen: asked %u, orig = %u, used = %u\",\n+\t\t    (unsigned int)postlen, (unsigned int)postimage->len,\n+\t\t    (unsigned int)(new_buf - postimage->buf));\n \n \t/* Fix the length of the whole thing */\n \tpostimage->len = new_buf - postimage->buf;\ndiff --git a/apply.h b/apply.h\nindex b9f18ce87d1..7e6b6eb5d2d 100644\n--- a/apply.h\n+++ b/apply.h\n@@ -165,12 +165,8 @@ int check_apply_state(struct apply_state *state, int force_apply);\n  *\n  * Returns -1 on failure, the length of the parsed header otherwise.\n  */\n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch);\n \n void release_patch(struct patch *patch);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/archive.c b/archive.c\nindex 941495f5d78..6042328451b 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -275,7 +275,7 @@ int write_archive_entries(struct archiver_args *args,\n \tstruct strbuf path_in_archive = STRBUF_INIT;\n \tstruct strbuf content = STRBUF_INIT;\n \tstruct object_id fake_oid;\n-\tint i;\n+\tsize_t i;\n \n \toidcpy(&fake_oid, null_oid());\n \ndiff --git a/attr.c b/attr.c\nindex 42ad6de8c7c..e7bb41a05f3 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -447,11 +447,10 @@ struct attr_stack {\n \n static void attr_stack_free(struct attr_stack *e)\n {\n-\tint i;\n+\tunsigned int i, j;\n \tfree(e->origin);\n \tfor (i = 0; i < e->num_matches; i++) {\n \t\tstruct match_attr *a = e->attrs[i];\n-\t\tint j;\n \t\tfor (j = 0; j < a->num_attr; j++) {\n \t\t\tconst char *setto = a->state[j].setto;\n \t\t\tif (setto == ATTR__TRUE ||\ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/bisect.c b/bisect.c\nindex ec7487e6836..a3bdc5eeac7 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -494,7 +494,7 @@ static void read_bisect_paths(struct strvec *array)\n static char *join_oid_array_hex(struct oid_array *array, char delim)\n {\n \tstruct strbuf joined_hexs = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < array->nr; i++) {\n \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\ndiff --git a/blame.c b/blame.c\nindex 8bfeaa1c63a..b050ba7f893 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -493,7 +493,7 @@ static void get_line_fingerprints(struct fingerprint *fingerprints,\n \t\t\t\t  const char *content, const int *line_starts,\n \t\t\t\t  long first_line, long line_count)\n {\n-\tint i;\n+\tlong i;\n \tconst char *linestart, *lineend;\n \n \tline_starts += first_line;\n@@ -1496,7 +1496,7 @@ static void split_overlap(struct blame_entry *split,\n \t\t\t  struct blame_origin *parent)\n {\n \tint chunk_end_lno;\n-\tint i;\n+\tunsigned int i;\n \tmemset(split, 0, sizeof(struct blame_entry [3]));\n \n \tfor (i = 0; i < 3; i++) {\n@@ -1583,7 +1583,7 @@ static void split_blame(struct blame_entry ***blamed,\n  */\n static void decref_split(struct blame_entry *split)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < 3; i++)\n \t\tblame_origin_decref(split[i].suspect);\n@@ -2001,7 +2001,7 @@ static void copy_split_if_better(struct blame_scoreboard *sb,\n \t\t\t\t struct blame_entry *best_so_far,\n \t\t\t\t struct blame_entry *potential)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tif (!potential[1].suspect)\n \t\treturn;\n@@ -2193,10 +2193,10 @@ struct blame_list {\n  * and prepare a list of entry and the best split.\n  */\n static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n-\t\t\t\t\t   int *num_ents_p)\n+\t\t\t\t\t   size_t *num_ents_p)\n {\n \tstruct blame_entry *e;\n-\tint num_ents, i;\n+\tsize_t num_ents, i;\n \tstruct blame_list *blame_list = NULL;\n \n \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n@@ -2224,9 +2224,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t\tint opt)\n {\n \tstruct diff_options diff_opts;\n-\tint i, j;\n+\tsize_t i, j;\n \tstruct blame_list *blame_list;\n-\tint num_ents;\n+\tsize_t num_ents;\n \tstruct blame_entry *unblamed = target->suspects;\n \tstruct blame_entry *leftover = NULL;\n \n@@ -2645,7 +2645,7 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2708,7 +2708,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 80cebd27564..a08be63bc63 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -214,7 +214,7 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)\n {\n \tstatic const unsigned char pad[64] = { 0x80 };\n \tunsigned int padlen[2];\n-\tint i;\n+\tsize_t i;\n \n \t/* Pad with a binary 1 (ie 0x80), then zeroes, then length */\n \tpadlen[0] = htonl((uint32_t)(ctx->size >> 29));\ndiff --git a/bloom.c b/bloom.c\nindex d0730525da5..d38064e257f 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -73,11 +73,11 @@ uint32_t murmur3_seeded(uint32_t seed, const char *data, size_t len)\n \tconst uint32_t r2 = 13;\n \tconst uint32_t m = 5;\n \tconst uint32_t n = 0xe6546b64;\n-\tint i;\n+\tsize_t i;\n \tuint32_t k1 = 0;\n \tconst char *tail;\n \n-\tint len4 = len / sizeof(uint32_t);\n+\tsize_t len4 = len / sizeof(uint32_t);\n \n \tuint32_t k;\n \tfor (i = 0; i < len4; i++) {\n@@ -127,7 +127,7 @@ void fill_bloom_key(const char *data,\n \t\t    struct bloom_key *key,\n \t\t    const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tconst uint32_t seed0 = 0x293ae76f;\n \tconst uint32_t seed1 = 0x7e646e2c;\n \tconst uint32_t hash0 = murmur3_seeded(seed0, data, len);\n@@ -147,7 +147,7 @@ void add_key_to_filter(const struct bloom_key *key,\n \t\t       struct bloom_filter *filter,\n \t\t       const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tfor (i = 0; i < settings->num_hashes; i++) {\n@@ -310,7 +310,7 @@ int bloom_filter_contains(const struct bloom_filter *filter,\n \t\t\t  const struct bloom_key *key,\n \t\t\t  const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tif (!mod)\ndiff --git a/branch.c b/branch.c\nindex d182756827f..bb9c861a9bc 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -375,7 +375,7 @@ static struct strmap current_checked_out_branches = STRMAP_INIT;\n \n static void prepare_checked_out_branches(void)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \tstruct worktree **worktrees;\n \n \tif (initialized_checked_out_branches)\n@@ -836,7 +836,7 @@ int replace_each_worktree_head_symref(const char *oldref, const char *newref,\n {\n \tint ret = 0;\n \tstruct worktree **worktrees = get_worktrees();\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; worktrees[i]; i++) {\n \t\tstruct ref_store *refs;\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0c604022676..5a6686d42dc 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 39a890fc005..43da493eb4b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -906,7 +906,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < info->nr; i++) {\n \t\tstruct rev_cmdline_entry *e = info->rev + i;\n@@ -1230,7 +1230,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"the option '%s' requires '%s'\"), \"--anonymize-map\", \"--anonymize\");\n \n \tif (refspecs_list.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tfor (i = 0; i < refspecs_list.nr; i++)\n \t\t\trefspec_append(&refspecs, refspecs_list.items[i].string);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 7134683ab93..068c218ca61 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -860,7 +860,7 @@ static void end_packfile(void)\n \t\tstruct packed_git *new_p;\n \t\tstruct object_id cur_pack_oid;\n \t\tchar *idx_name;\n-\t\tint i;\n+\t\tunsigned long i;\n \t\tstruct branch *b;\n \t\tstruct tag *t;\n \ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex afe679368de..9758d067b73 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -239,7 +239,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \tref = fetch_pack(&args, fd, ref, sought, nr_sought,\n \t\t\t &shallow, pack_lockfiles_ptr, version);\n \tif (pack_lockfiles.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tprintf(\"lock %s\\n\", pack_lockfiles.items[0].string);\n \t\tfflush(stdout);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7378cafeec9..2a86fe79fc7 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1479,11 +1479,11 @@ static int add_oid(const char *refname UNUSED,\n static void add_negotiation_tips(struct git_transport_options *smart_options)\n {\n \tstruct oid_array *oids = xcalloc(1, sizeof(*oids));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < negotiation_tip.nr; i++) {\n \t\tconst char *s = negotiation_tip.items[i].string;\n-\t\tint old_nr;\n+\t\tsize_t old_nr;\n \t\tif (!has_glob_specials(s)) {\n \t\t\tstruct object_id oid;\n \t\t\tif (get_oid(s, &oid))\n@@ -1938,7 +1938,8 @@ static int fetch_finished(int result, struct strbuf *out,\n \n static int fetch_multiple(struct string_list *list, int max_children)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tstruct strvec argv = STRVEC_INIT;\n \n \tif (!append && write_fetch_head) {\ndiff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c\nindex 6aeac371488..ababcbef101 100644\n--- a/builtin/for-each-repo.c\n+++ b/builtin/for-each-repo.c\n@@ -30,7 +30,8 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)\n int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n {\n \tstatic const char *config_key = NULL;\n-\tint i, result = 0;\n+\tint result = 0;\n+\tsize_t i;\n \tconst struct string_list *values;\n \n \tconst struct option options[] = {\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex d207bd909b4..3b411735a58 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_object(struct object *obj)\n \n static void check_connectivity(void)\n {\n-\tint i, max;\n+\tunsigned int i, max;\n \n \t/* Traverse the pending reachable objects */\n \ttraverse_reachable();\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 02455fdcd73..511419ba417 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -68,7 +68,7 @@ static struct string_list pack_garbage = STRING_LIST_INIT_DUP;\n \n static void clean_pack_garbage(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < pack_garbage.nr; i++)\n \t\tunlink_or_warn(pack_garbage.items[i].string);\n \tstring_list_clear(&pack_garbage, 0);\n@@ -1288,7 +1288,8 @@ static int compare_tasks_by_selection(const void *a_, const void *b_)\n \n static int maintenance_run_tasks(struct maintenance_run_opts *opts)\n {\n-\tint i, found_selected = 0;\n+\tunsigned int i;\n+\tint found_selected = 0;\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n@@ -1367,7 +1368,7 @@ static void initialize_maintenance_strategy(void)\n \n static void initialize_task_config(int schedule)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf config_name = STRBUF_INIT;\n \tgc_config();\n \n@@ -1401,7 +1402,8 @@ static void initialize_task_config(int schedule)\n static int task_option_parse(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n-\tint i, num_selected = 0;\n+\tunsigned int i;\n+\tint num_selected = 0;\n \tstruct maintenance_task *task = NULL;\n \n \tBUG_ON_OPT_NEG(unset);\n@@ -1431,7 +1433,7 @@ static int task_option_parse(const struct option *opt,\n \n static int maintenance_run(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct maintenance_run_opts opts;\n \tstruct option builtin_maintenance_run_options[] = {\n \t\tOPT_BOOL(0, \"auto\", &opts.auto_flag,\n@@ -1810,8 +1812,9 @@ static int launchctl_list_contains_plist(const char *name, const char *cmd)\n \n static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule)\n {\n-\tint i, fd;\n-\tconst char *preamble, *repeat;\n+\tunsigned int i;\n+\tint fd;\n+\tconst char *preamble;\n \tconst char *frequency = get_frequency(schedule);\n \tchar *name = launchctl_service_name(frequency);\n \tchar *filename = launchctl_service_filename(name);\n@@ -1843,22 +1846,24 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n \n \tswitch (schedule) {\n \tcase SCHEDULE_HOURLY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Hour</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 23; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_DAILY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 6; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Day</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_WEEKLY:\n@@ -2553,7 +2558,7 @@ static void validate_scheduler(enum scheduler scheduler)\n static int update_background_schedule(const struct maintenance_start_opts *opts,\n \t\t\t\t      int enable)\n {\n-\tunsigned int i;\n+\tsize_t i;\n \tint result = 0;\n \tstruct lock_file lk;\n \tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex f7821c5fbba..75cc21f632e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -174,7 +174,7 @@ static void work_done(struct work_item *w)\n \n static void free_repos(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < repos_to_free_nr; i++) {\n \t\trepo_clear(repos_to_free[i]);\n@@ -409,7 +409,8 @@ static void run_pager(struct grep_opt *opt, const char *prefix)\n {\n \tstruct string_list *path_list = opt->output_priv;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint i, status;\n+\tsize_t i;\n+\tint status;\n \n \tfor (i = 0; i < path_list->nr; i++)\n \t\tstrvec_push(&child.args, path_list->items[i].string);\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 53f2812dfb1..fd227be20f1 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -124,7 +124,7 @@ static void list_config_help(enum show_config_type type)\n \tstruct string_list keys = STRING_LIST_INIT_DUP;\n \tstruct string_list keys_uniq = STRING_LIST_INIT_DUP;\n \tstruct string_list_item *item;\n-\tint i;\n+\tsize_t i;\n \n \tfor (p = config_name_list; *p; p++) {\n \t\tconst char *var = *p;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 057e299c245..5a89440de82 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -179,7 +179,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n static void set_default_decoration_filter(struct decoration_filter *decoration_filter)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *value = NULL;\n \tstruct string_list *include = decoration_filter->include_ref_pattern;\n \tconst struct string_list *config_exclude =\n@@ -386,7 +386,7 @@ static struct itimerval early_output_timer;\n \n static void log_show_early(struct rev_info *revs, struct commit_list *list)\n {\n-\tint i = revs->early_output;\n+\tunsigned int i = revs->early_output;\n \tint show_header = 1;\n \tint no_free = revs->diffopt.no_free;\n \ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex a03b559ecaa..c369e95c30e 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -348,7 +348,8 @@ static void show_ru_info(struct index_state *istate)\n \tfor_each_string_list_item(item, istate->resolve_undo) {\n \t\tconst char *path = item->string;\n \t\tstruct resolve_undo_info *ui = item->util;\n-\t\tint i, len;\n+\t\tunsigned int i;\n+\t\tint len;\n \n \t\tlen = strlen(path);\n \t\tif (len < max_prefix_len)\n@@ -359,9 +360,8 @@ static void show_ru_info(struct index_state *istate)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n-\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev),\n-\t\t\t       i + 1);\n+\t\t\tprintf(\"%s%06o %s %u\\t\", tag_resolve_undo, ui->mode[i],\n+\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev), i + 1);\n \t\t\twrite_name(path);\n \t\t}\n \t}\n@@ -385,7 +385,7 @@ static void construct_fullname(struct strbuf *out, const struct repository *repo\n \n static void show_files(struct repository *repo, struct dir_struct *dir)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf fullname = STRBUF_INIT;\n \n \t/* For cached/deleted files we don't need to even do the readdir */\n@@ -449,12 +449,12 @@ static void show_files(struct repository *repo, struct dir_struct *dir)\n \n skip_to_next_name:\n \t\t{\n-\t\t\tint j;\n-\t\t\tstruct cache_entry **cache = repo->index->cache;\n-\t\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n-\t\t\t\tif (strcmp(ce->name, cache[j]->name))\n-\t\t\t\t\tbreak;\n-\t\t\ti = j - 1; /* compensate for the for loop */\n+\t\tunsigned int j;\n+\t\tstruct cache_entry **cache = repo->index->cache;\n+\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n+\t\t\tif (strcmp(ce->name, cache[j]->name))\n+\t\t\t\tbreak;\n+\t\ti = j - 1; /* compensate for the for loop */\n \t\t}\n \t}\n \n@@ -571,7 +571,7 @@ void overlay_tree_on_index(struct index_state *istate,\n \tstruct object_id oid;\n \tstruct pathspec pathspec;\n \tstruct cache_entry *last_stage0 = NULL;\n-\tint i;\n+\tunsigned int i;\n \tread_tree_fn_t fn = NULL;\n \tint err;\n \ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 5d5ac038716..2c87b473700 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -87,7 +87,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tpacket_trace_identity(\"ls-remote\");\n \n \tif (argc > 1) {\n-\t\tint i;\n \t\tCALLOC_ARRAY(pattern, argc);\n \t\tfor (i = 1; i < argc; i++) {\n \t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 73509f651bd..053c9eecb30 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -172,7 +172,7 @@ static int split_maildir(const char *maildir, const char *dir,\n \tchar *file = NULL;\n \tFILE *f = NULL;\n \tint ret = -1;\n-\tint i;\n+\tsize_t i;\n \tstruct string_list list = STRING_LIST_INIT_DUP;\n \n \tlist.cmp = maildir_filename_cmp;\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..e4655e8541c 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tsize_t i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 0f093f2a4f2..4aa3bdb6d16 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -186,7 +186,8 @@ static struct strategy *get_strategy(const char *name)\n \t\tmemset(&not_strategies, 0, sizeof(struct cmdnames));\n \t\tload_command_list(\"git-merge-\", &main_cmds, &other_cmds);\n \t\tfor (i = 0; i < main_cmds.cnt; i++) {\n-\t\t\tint j, found = 0;\n+\t\t\tsize_t j;\n+\t\t\tint found = 0;\n \t\t\tstruct cmdname *ent = main_cmds.names[i];\n \t\t\tfor (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 15535e914a6..0a96140d342 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -664,7 +664,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tstrbuf_release(&sb);\n \t} else if (all) {\n-\t\tint i, max;\n+\t\tunsigned int i, max;\n \n \t\tmax = get_max_object_index();\n \t\tfor (i = 0; i < max; i++) {\n@@ -675,7 +675,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t  always, allow_undefined, data.name_only);\n \t\t}\n \t} else {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < revs.nr; i++)\n \t\t\tshow_name(revs.objects[i].item, revs.objects[i].name,\n \t\t\t\t  always, allow_undefined, data.name_only);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 2193f80b897..e539e73e5ce 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1509,7 +1509,7 @@ static int want_object_in_pack(const struct object_id *oid,\n \tif (uri_protocols.nr) {\n \t\tstruct configured_exclusion *ex =\n \t\t\toidmap_get(&configured_exclusions, oid);\n-\t\tint i;\n+\t\tsize_t i;\n \t\tconst char *p;\n \n \t\tif (ex) {\n@@ -1708,18 +1708,16 @@ static void pbase_tree_put(struct pbase_tree_cache *cache)\n \tfree(cache);\n }\n \n-static int name_cmp_len(const char *name)\n+static size_t name_cmp_len(const char *name)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; name[i] && name[i] != '\\n' && name[i] != '/'; i++)\n \t\t;\n \treturn i;\n }\n \n-static void add_pbase_object(struct tree_desc *tree,\n-\t\t\t     const char *name,\n-\t\t\t     int cmplen,\n-\t\t\t     const char *fullname)\n+static void add_pbase_object(struct tree_desc *tree, const char *name,\n+\t\t\t     size_t cmplen, const char *fullname)\n {\n \tstruct name_entry entry;\n \tint cmp;\n@@ -1743,7 +1741,7 @@ static void add_pbase_object(struct tree_desc *tree,\n \t\t\tstruct tree_desc sub;\n \t\t\tstruct pbase_tree_cache *tree;\n \t\t\tconst char *down = name+cmplen+1;\n-\t\t\tint downlen = name_cmp_len(down);\n+\t\t\tsize_t downlen = name_cmp_len(down);\n \n \t\t\ttree = pbase_tree_get(&entry.oid);\n \t\t\tif (!tree)\n@@ -4085,7 +4083,7 @@ static void add_extra_kept_packs(const struct string_list *names)\n \n \tfor (p = get_all_packs(the_repository); p; p = p->next) {\n \t\tconst char *name = basename(p->pack_name);\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!p->pack_local)\n \t\t\tcontinue;\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex ecd49ca268f..0f6c827faca 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -51,9 +51,9 @@ static inline struct llist_item *llist_item_get(void)\n \t\tnew_item = free_nodes;\n \t\tfree_nodes = free_nodes->next;\n \t} else {\n-\t\tint i = 1;\n+\t\tsize_t i;\n \t\tALLOC_ARRAY(new_item, BLKSIZE);\n-\t\tfor (; i < BLKSIZE; i++)\n+\t\tfor (i = 1; i < BLKSIZE; i++)\n \t\t\tllist_item_put(&new_item[i]);\n \t}\n \treturn new_item;\n@@ -366,7 +366,7 @@ static int cmp_remaining_objects(const void *a, const void *b)\n static void sort_pack_list(struct pack_list **pl)\n {\n \tstruct pack_list **ary, *p;\n-\tint i;\n+\tsize_t i;\n \tsize_t n = pack_list_size(*pl);\n \n \tif (n < 2)\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex f840fbf1c7e..8fed7935e9a 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -10,7 +10,7 @@ static void flush_current_id(int patchlen, struct object_id *id, struct object_i\n \t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n }\n \n-static int remove_space(char *line)\n+static size_t remove_space(char *line)\n {\n \tchar *src = line;\n \tchar *dst = line;\n@@ -57,10 +57,12 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n-\t\t\t   struct strbuf *line_buf, int stable, int verbatim)\n+static size_t get_one_patchid(struct object_id *next_oid,\n+\t\t\t      struct object_id *result, struct strbuf *line_buf,\n+\t\t\t      int stable, int verbatim)\n {\n-\tint patchlen = 0, found_next = 0;\n+\tsize_t patchlen = 0;\n+\tint found_next = 0;\n \tint before = -1, after = -1;\n \tint diff_is_binary = 0;\n \tchar pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];\n@@ -72,7 +74,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n \twhile (strbuf_getwholeline(line_buf, stdin, '\\n') != EOF) {\n \t\tchar *line = line_buf->buf;\n \t\tconst char *p = line;\n-\t\tint len;\n+\t\tsize_t len;\n \n \t\t/* Possibly skip over the prefix added by \"log\" or \"format-patch\" */\n \t\tif (!skip_prefix(line, \"commit \", &p) &&\n@@ -173,7 +175,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n static void generate_id_list(int stable, int verbatim)\n {\n \tstruct object_id oid, n, result;\n-\tint patchlen;\n+\tsize_t patchlen;\n \tstruct strbuf line_buf = STRBUF_INIT;\n \n \toidclr(&oid);\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 1ab4de0005d..115b4bd8819 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -941,7 +941,7 @@ static int get_can_ff(struct object_id *orig_head,\n static int already_up_to_date(struct object_id *orig_head,\n \t\t\t      struct oid_array *merge_heads)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *ours;\n \n \tours = lookup_commit_reference(the_repository, orig_head);\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 3ce75417833..444939c70dc 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -85,13 +85,13 @@ static void debug_stage(const char *label, const struct cache_entry *ce,\n static int debug_merge(const struct cache_entry * const *stages,\n \t\t       struct unpack_trees_options *o)\n {\n-\tint i;\n+\tunsigned int i;\n \n-\tprintf(\"* %d-way merge\\n\", o->merge_size);\n+\tprintf(\"* %u-way merge\\n\", o->merge_size);\n \tdebug_stage(\"index\", stages[0], o);\n \tfor (i = 1; i <= o->merge_size; i++) {\n \t\tchar buf[24];\n-\t\txsnprintf(buf, sizeof(buf), \"ent#%d\", i);\n+\t\txsnprintf(buf, sizeof(buf), \"ent#%u\", i);\n \t\tdebug_stage(buf, stages[i], o);\n \t}\n \treturn 0;\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 1481c5b6a5b..38c69a0e0c9 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1423,13 +1423,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\toptions.gpg_sign_opt = xstrfmt(\"-S%s\", gpg_sign);\n \n \tif (exec.nr) {\n-\t\tint i;\n+\t\tsize_t j;\n \n \t\timply_merge(&options, \"--exec\");\n \n \t\tstrbuf_reset(&buf);\n-\t\tfor (i = 0; i < exec.nr; i++)\n-\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[i].string);\n+\t\tfor (j = 0; j < exec.nr; j++)\n+\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[j].string);\n \t\toptions.cmd = xstrdup(buf.buf);\n \t}\n \n@@ -1462,15 +1462,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (strategy_options.nr) {\n-\t\tint i;\n+\t\tsize_t j;\n \n \t\tif (!options.strategy)\n \t\t\toptions.strategy = \"ort\";\n \n \t\tstrbuf_reset(&buf);\n-\t\tfor (i = 0; i < strategy_options.nr; i++)\n+\t\tfor (j = 0; j < strategy_options.nr; j++)\n \t\t\tstrbuf_addf(&buf, \" --%s\",\n-\t\t\t\t    strategy_options.items[i].string);\n+\t\t\t\t    strategy_options.items[j].string);\n \t\toptions.strategy_opts = xstrdup(buf.buf);\n \t}\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex a90af303630..c1dc2ceb517 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -536,7 +536,7 @@ static void hmac_hash(unsigned char *out,\n \tunsigned char key[GIT_MAX_BLKSZ];\n \tunsigned char k_ipad[GIT_MAX_BLKSZ];\n \tunsigned char k_opad[GIT_MAX_BLKSZ];\n-\tint i;\n+\tsize_t i;\n \tgit_hash_ctx ctx;\n \n \t/* RFC 2104 2. (1) */\n@@ -1302,7 +1302,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \tstruct oid_array extra = OID_ARRAY_INIT;\n \tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n \tuint32_t mask = 1 << (cmd->index % 32);\n-\tint i;\n+\tsize_t i;\n \n \ttrace_printf_key(&trace_shallow,\n \t\t\t \"shallow: update_shallow_ref %s\\n\", cmd->ref_name);\n@@ -2303,7 +2303,9 @@ static const char *unpack_with_sideband(struct shallow_info *si)\n \n static void prepare_shallow_update(struct shallow_info *si)\n {\n-\tint i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tsize_t i, j, k;\n+\tsize_t bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tint l;\n \n \tALLOC_ARRAY(si->used_shallow, si->shallow->nr);\n \tassign_shallow_commits_to_refs(si, si->used_shallow, NULL);\n@@ -2312,8 +2314,8 @@ static void prepare_shallow_update(struct shallow_info *si)\n \tCALLOC_ARRAY(si->reachable, si->shallow->nr);\n \tCALLOC_ARRAY(si->shallow_ref, si->ref->nr);\n \n-\tfor (i = 0; i < si->nr_ours; i++)\n-\t\tsi->need_reachability_test[si->ours[i]] = 1;\n+\tfor (l = 0; l < si->nr_ours; l++)\n+\t\tsi->need_reachability_test[si->ours[l]] = 1;\n \n \tfor (i = 0; i < si->shallow->nr; i++) {\n \t\tif (!si->used_shallow[i])\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 729f6f3643a..93f8c9a2fad 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -161,7 +161,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tstruct remote *remote;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tconst char *name, *url;\n-\tint i;\n+\tsize_t i;\n \n \tstruct option options[] = {\n \t\tOPT_BOOL('f', \"fetch\", &fetch, N_(\"fetch the remote branches\")),\n@@ -862,7 +862,8 @@ static int rm(int argc, const char **argv, const char *prefix)\n \tstruct string_list branches = STRING_LIST_INIT_DUP;\n \tstruct string_list skipped = STRING_LIST_INIT_DUP;\n \tstruct branches_for_remote cb_data;\n-\tint i, result;\n+\tsize_t i;\n+\tint result;\n \n \tmemset(&cb_data, 0, sizeof(cb_data));\n \tcb_data.branches = &branches;\n@@ -1093,7 +1094,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \tstruct branch_info *branch_info = item->util;\n \tstruct string_list *merge = &branch_info->merge;\n \tint width = show_info->width + 4;\n-\tint i;\n+\tsize_t i;\n \n \tif (branch_info->rebase >= REBASE_TRUE && branch_info->merge.nr > 1) {\n \t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n@@ -1245,7 +1246,7 @@ static int show_all(void)\n \tresult = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tstring_list_sort(&list);\n \t\tfor (i = 0; i < list.nr; i++) {\n@@ -1370,7 +1371,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \n static int set_head(int argc, const char **argv, const char *prefix)\n {\n-\tint i, opt_a = 0, opt_d = 0, result = 0;\n+\tint opt_a = 0, opt_d = 0, result = 0;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tchar *head_name = NULL;\n \n@@ -1394,6 +1395,7 @@ static int set_head(int argc, const char **argv, const char *prefix)\n \t\tif (!states.heads.nr)\n \t\t\tresult |= error(_(\"Cannot determine remote HEAD\"));\n \t\telse if (states.heads.nr > 1) {\n+\t\t\tsize_t i;\n \t\t\tresult |= error(_(\"Multiple remote HEAD branches. \"\n \t\t\t\t\t  \"Please choose one explicitly with:\"));\n \t\t\tfor (i = 0; i < states.heads.nr; i++)\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex c1402ad038f..791b100f799 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -109,7 +109,7 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,\n \n \twhile ((e = readdir(dir)) != NULL) {\n \t\tsize_t len;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!strip_suffix(e->d_name, \".pack\", &len))\n \t\t\tcontinue;\n@@ -218,7 +218,7 @@ static struct generated_pack_data *populate_pack_exts(const char *name)\n \tstruct stat statbuf;\n \tstruct strbuf path = STRBUF_INIT;\n \tstruct generated_pack_data *data = xcalloc(1, sizeof(*data));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n \t\tstrbuf_reset(&path);\n@@ -744,7 +744,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)\n \tstruct pack_geometry *geometry = NULL;\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct tempfile *refs_snapshot = NULL;\n-\tint i, ext, ret;\n+\tsize_t i;\n+\tint ext, ret;\n \tFILE *out;\n \tint show_progress;\n \ndiff --git a/builtin/rerere.c b/builtin/rerere.c\nindex 94ffb8c21ab..7a0aeed3323 100644\n--- a/builtin/rerere.c\n+++ b/builtin/rerere.c\n@@ -51,7 +51,8 @@ static int diff_two(const char *file1, const char *label1,\n int cmd_rerere(int argc, const char **argv, const char *prefix)\n {\n \tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n-\tint i, autoupdate = -1, flags = 0;\n+\tsize_t i;\n+\tint autoupdate = -1, flags = 0;\n \n \tstruct option options[] = {\n \t\tOPT_SET_INT(0, \"rerere-autoupdate\", &autoupdate,\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex fea20a9ba0b..0e4f3ad104a 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -49,7 +49,7 @@ static inline int is_merge(void)\n \n static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)\n {\n-\tint i, nr = 0;\n+\tunsigned int i, nr = 0;\n \tstruct tree_desc desc[2];\n \tstruct tree *tree;\n \tstruct unpack_trees_options opts;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex e67999e5ebc..c235e67a099 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -707,7 +707,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \n \t\tif (!seen_end_of_options) {\n \t\t\tif (!strcmp(arg, \"--local-env-vars\")) {\n-\t\t\t\tint i;\n+\t\t\t\tsize_t i;\n \t\t\t\tfor (i = 0; local_repo_env[i]; i++)\n \t\t\t\t\tprintf(\"%s\\n\", local_repo_env[i]);\n \t\t\t\tcontinue;\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 4a4aec0d00e..db152cf1757 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -49,7 +49,7 @@ static void print_error_files(struct string_list *files_list,\n \t\t\t      int *errs)\n {\n \tif (files_list->nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct strbuf err_msg = STRBUF_INIT;\n \n \t\tstrbuf_addstr(&err_msg, main_msg);\n@@ -258,7 +258,9 @@ static struct option builtin_rm_options[] = {\n int cmd_rm(int argc, const char **argv, const char *prefix)\n {\n \tstruct lock_file lock_file = LOCK_INIT;\n-\tint i, ret = 0;\n+\tint i;\n+\tunsigned int j;\n+\tint ret = 0;\n \tstruct pathspec pathspec;\n \tchar *seen;\n \n@@ -302,8 +304,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \tif (pathspec_needs_expanded_index(&the_index, &pathspec))\n \t\tensure_full_index(&the_index);\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n-\t\tconst struct cache_entry *ce = the_index.cache[i];\n+\tfor (j = 0; j < the_index.cache_nr; j++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[j];\n \n \t\tif (!include_sparse &&\n \t\t    (ce_skip_worktree(ce) ||\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex c013abaf942..31eaeb2e462 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -109,9 +109,9 @@ static void name_parent(struct commit *commit, struct commit *parent)\n \t\t\t    commit_name->generation + 1);\n }\n \n-static int name_first_parent_chain(struct commit *c)\n+static size_t name_first_parent_chain(struct commit *c)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \twhile (c) {\n \t\tstruct commit *p;\n \t\tif (!commit_to_name(c))\n@@ -130,14 +130,12 @@ static int name_first_parent_chain(struct commit *c)\n \treturn i;\n }\n \n-static void name_commits(struct commit_list *list,\n-\t\t\t struct commit **rev,\n-\t\t\t char **ref_name,\n-\t\t\t int num_rev)\n+static void name_commits(struct commit_list *list, struct commit **rev,\n+\t\t\t char **ref_name, size_t num_rev)\n {\n \tstruct commit_list *cl;\n \tstruct commit *c;\n-\tint i;\n+\tsize_t i;\n \n \t/* First give names to the given heads */\n \tfor (cl = list; cl; cl = cl->next) {\n@@ -213,18 +211,17 @@ static int mark_seen(struct commit *commit, struct commit_list **seen_p)\n \treturn 0;\n }\n \n-static void join_revs(struct commit_list **list_p,\n-\t\t      struct commit_list **seen_p,\n-\t\t      int num_rev, int extra)\n+static void join_revs(struct commit_list **list_p, struct commit_list **seen_p,\n+\t\t      size_t num_rev, int extra)\n {\n-\tint all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n-\tint all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n+\tsize_t all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n+\tsize_t all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n \n \twhile (*list_p) {\n \t\tstruct commit_list *parents;\n \t\tint still_interesting = !!interesting(*list_p);\n \t\tstruct commit *commit = pop_commit(list_p);\n-\t\tint flags = commit->object.flags & all_mask;\n+\t\tunsigned int flags = commit->object.flags & all_mask;\n \n \t\tif (!still_interesting && extra <= 0)\n \t\t\tbreak;\n@@ -513,11 +510,10 @@ static int show_merge_base(struct commit_list *seen, int num_rev)\n \treturn exit_status;\n }\n \n-static int show_independent(struct commit **rev,\n-\t\t\t    int num_rev,\n+static int show_independent(struct commit **rev, size_t num_rev,\n \t\t\t    unsigned int *rev_mask)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < num_rev; i++) {\n \t\tstruct commit *commit = rev[i];\n@@ -625,7 +621,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \tchar *reflog_msg[MAX_REVS];\n \tstruct commit_list *list = NULL, *seen = NULL;\n \tunsigned int rev_mask[MAX_REVS];\n-\tint num_rev, i, extra = 0;\n+\tsize_t num_rev, i;\n+\tint extra = 0;\n \tint all_heads = 0, all_remotes = 0;\n \tint all_mask, all_revs;\n \tenum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -789,7 +786,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\t\t\tmsg);\n \t\t\tfree(logmsg);\n \n-\t\t\tnth_desc = xstrfmt(\"%s@{%d}\", *av, base+i);\n+\t\t\tnth_desc = xstrfmt(\"%s@{%lu}\", *av,\n+\t\t\t\t\t   (unsigned long)(base + i));\n \t\t\tappend_ref(nth_desc, &oid, 1);\n \t\t\tfree(nth_desc);\n \t\t}\ndiff --git a/builtin/show-index.c b/builtin/show-index.c\nindex 0e0b9fb95bc..92d5edcf77d 100644\n--- a/builtin/show-index.c\n+++ b/builtin/show-index.c\n@@ -10,7 +10,7 @@ static const char *const show_index_usage[] = {\n \n int cmd_show_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tunsigned nr;\n \tunsigned int version;\n \tstatic unsigned int top_index[256];\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 58a22503f04..09c6e61ecf0 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -78,7 +78,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (pl.use_cone_patterns) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct pattern_entry *pe;\n \t\tstruct hashmap_iter iter;\n \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n@@ -106,7 +106,8 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \n static void clean_tracked_sparse_directories(struct repository *r)\n {\n-\tint i, was_full = 0;\n+\tunsigned int i;\n+\tint was_full = 0;\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t pathlen;\n \tstruct string_list_item *item;\n@@ -263,7 +264,7 @@ static char *escaped_pattern(char *pattern)\n \n static void write_cone_to_file(FILE *fp, struct pattern_list *pl)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct pattern_entry *pe;\n \tstruct hashmap_iter iter;\n \tstruct string_list sl = STRING_LIST_INIT_DUP;\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex bb0fd861434..8b253209158 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -850,7 +850,7 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op\n \tstruct tree *tree[ARRAY_SIZE(oid)];\n \tstruct tree_desc tree_desc[ARRAY_SIZE(oid)];\n \tstruct unpack_trees_options unpack_tree_opt = { 0 };\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(oid); i++) {\n \t\ttree[i] = parse_tree_indirect(oid[i]);\n@@ -1517,7 +1517,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \n \trepo_read_index_preload(the_repository, NULL, 0);\n \tif (!include_untracked && ps->nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 450680fc708..d985f79dca9 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -185,7 +185,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\n@@ -251,7 +252,7 @@ static char *get_up_path(const char *path)\n \tint i;\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tfor (i = count_slashes(path); i; i--)\n+\tfor (i = count_slashes(path); i > 0; i--)\n \t\tstrbuf_addstr(&sb, \"../\");\n \n \t/*\n@@ -3212,7 +3213,7 @@ static void die_on_index_match(const char *path, int force)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (ps.nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps.nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 43789b8ef29..e337ca4129e 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -571,7 +571,7 @@ static void unpack_one(unsigned nr)\n \n static void unpack_all(void)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n \n \tnr_objects = ntohl(hdr->hdr_entries);\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex a84e7b47a20..ded6a67a07f 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -393,7 +393,7 @@ static void update_refs_stdin(void)\n \tstruct strbuf input = STRBUF_INIT, err = STRBUF_INIT;\n \tenum update_refs_state state = UPDATE_REFS_OPEN;\n \tstruct ref_transaction *transaction;\n-\tint i, j;\n+\tsize_t i;\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction)\n@@ -435,7 +435,7 @@ static void update_refs_stdin(void)\n \t\t * error in case there is an early EOF to let the command\n \t\t * handle missing arguments with a proper error message.\n \t\t */\n-\t\tfor (j = 1; line_termination == '\\0' && j < cmd->args; j++)\n+\t\tfor (i = 1; line_termination == '\\0' && i < cmd->args; i++)\n \t\t\tif (strbuf_appendwholeline(&input, stdin, line_termination))\n \t\t\t\tbreak;\n \ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 591d659faea..c6a5f6ce2ba 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -160,7 +160,7 @@ static int prune_cmp(const void *a, const void *b)\n \n static void prune_dups(struct string_list *l)\n {\n-\tint i;\n+\tsize_t i;\n \n \tQSORT(l->items, l->nr, prune_cmp);\n \tfor (i = 1; i < l->nr; i++) {\n@@ -785,7 +785,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \n static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; wt[i]; i++) {\n \t\tint sha1_len;\n@@ -925,7 +925,8 @@ static void validate_no_submodules(const struct worktree *wt)\n {\n \tstruct index_state istate = { NULL };\n \tstruct strbuf path = STRBUF_INIT;\n-\tint i, found_submodules = 0;\n+\tunsigned int i;\n+\tint found_submodules = 0;\n \n \tif (is_directory(worktree_git_path(wt, \"modules\"))) {\n \t\t/*\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 855b68ec23b..6bd0a15b671 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -48,7 +48,7 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n {\n \tunsigned char hash[GIT_MAX_RAWSZ];\n \tstruct strbuf packname = STRBUF_INIT;\n-\tint i;\n+\tuint32_t i;\n \n \tif (!state->f)\n \t\treturn;\n@@ -121,7 +121,7 @@ static void flush_batch_fsync(void)\n \n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n-\tint i;\n+\tuint32_t i;\n \n \t/* The object may already exist in the repository */\n \tif (has_object_file(oid))\ndiff --git a/bundle.c b/bundle.c\nindex 4ef7256aa11..c2fee8b4eab 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -55,7 +55,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n \n static int parse_bundle_signature(struct bundle_header *header, const char *line)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n \t\tif (!strcmp(line, bundle_sigs[i].signature)) {\n@@ -162,7 +162,7 @@ int is_bundle(const char *path, int quiet)\n \n static int list_refs(struct string_list *r, int argc, const char **argv)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < r->nr; i++) {\n \t\tstruct object_id *oid;\n@@ -199,7 +199,9 @@ int verify_bundle(struct repository *r,\n \tstruct rev_info revs = REV_INFO_INIT;\n \tconst char *argv[] = {NULL, \"--all\", NULL};\n \tstruct commit *commit;\n-\tint i, ret = 0, req_nr;\n+\tsize_t i;\n+\tint ret = 0;\n+\tunsigned int req_nr;\n \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n \n \tif (!r || !r->objects || !r->objects->odb)\n@@ -333,7 +335,7 @@ out:\n static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n {\n \tstruct child_process pack_objects = CHILD_PROCESS_INIT;\n-\tint i;\n+\tunsigned int i;\n \n \tstrvec_pushl(&pack_objects.args,\n \t\t     \"pack-objects\",\n@@ -387,7 +389,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n  */\n static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n {\n-\tint i;\n+\tunsigned int i;\n \tint ref_count = 0;\n \n \tfor (i = 0; i < revs->pending.nr; i++) {\n@@ -512,7 +514,7 @@ int create_bundle(struct repository *r, const char *path,\n \tstruct rev_info revs, revs_copy;\n \tint min_version = 2;\n \tstruct bundle_prerequisites_info bpi;\n-\tint i;\n+\tunsigned int i;\n \n \t/* init revs to list objects for pack-objects later */\n \tsave_commit_buffer = 0;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex c97111cccf2..84a64498a4c 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -694,7 +694,7 @@ struct tree* write_in_core_index_as_tree(struct repository *repo) {\n \n \tret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);\n \tif (ret == WRITE_TREE_UNMERGED_INDEX) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tbug(\"there are unmerged index entries:\");\n \t\tfor (i = 0; i < index_state->cache_nr; i++) {\n \t\t\tconst struct cache_entry *ce = index_state->cache[i];\n@@ -880,7 +880,8 @@ static int verify_one(struct repository *r,\n \t\t      struct cache_tree *it,\n \t\t      struct strbuf *path)\n {\n-\tint i, pos, len = path->len;\n+\tint i, pos;\n+\tsize_t len = path->len;\n \tstruct strbuf tree_buf = STRBUF_INIT;\n \tstruct object_id new_oid;\n \n@@ -953,8 +954,9 @@ static int verify_one(struct repository *r,\n \t\t\t &new_oid);\n \tif (!oideq(&new_oid, &it->oid))\n \t\tBUG(\"cache-tree for path %.*s does not match. \"\n-\t\t    \"Expected %s got %s\", len, path->buf,\n-\t\t    oid_to_hex(&new_oid), oid_to_hex(&it->oid));\n+\t\t    \"Expected %s got %s\",\n+\t\t    (int)len, path->buf, oid_to_hex(&new_oid),\n+\t\t    oid_to_hex(&it->oid));\n \tstrbuf_setlen(path, len);\n \tstrbuf_release(&tree_buf);\n \treturn 0;\ndiff --git a/cache.h b/cache.h\nindex 21ed9633b2a..e0543135f05 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1206,7 +1206,8 @@ void check_repository_format(struct repository_format *fmt);\n  */\n const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);\n #define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)\n-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);\n+unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n+\t\t\t\t       const struct object_id *oid, int len);\n #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)\n \n /* set default permissions by passing mode arguments to open(2) */\n@@ -1607,10 +1608,13 @@ int repo_interpret_branch_name(struct repository *r,\n \n int validate_headref(const char *ref);\n \n-int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n-int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n+int base_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t      const char *name2, size_t len2, int mode2);\n+int df_name_compare(const char *name1, size_t len1, int mode1,\n+\t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1820,8 +1824,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/chunk-format.c b/chunk-format.c\nindex 0275b74a895..6981c2afd57 100644\n--- a/chunk-format.c\n+++ b/chunk-format.c\n@@ -58,7 +58,8 @@ void add_chunk(struct chunkfile *cf,\n \n int write_chunkfile(struct chunkfile *cf, void *data)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tuint64_t cur_offset = hashfile_total(cf->f);\n \n \ttrace2_region_enter(\"chunkfile\", \"write\", the_repository);\n@@ -101,7 +102,7 @@ int read_table_of_contents(struct chunkfile *cf,\n \t\t\t   uint64_t toc_offset,\n \t\t\t   int toc_length)\n {\n-\tint i;\n+\tsize_t i;\n \tuint32_t chunk_id;\n \tconst unsigned char *table_of_contents = mfile + toc_offset;\n \n@@ -172,7 +173,7 @@ int read_chunk(struct chunkfile *cf,\n \t       chunk_read_fn fn,\n \t       void *data)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < cf->chunks_nr; i++) {\n \t\tif (cf->chunks[i].id == chunk_id)\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..caff618e9a2 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,14 +73,14 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n+\tunsigned int i;\n \tint color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -195,7 +195,7 @@ static int parse_attr(const char *name, size_t len)\n #undef ATTR\n \t};\n \tint negate = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (skip_prefix_mem(name, len, \"no\", &name, &len)) {\n \t\tskip_prefix_mem(name, len, \"-\", &name, &len);\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex 1261e18a72e..bb3e53e960d 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\n@@ -240,7 +241,7 @@ static int parse_option(const char *arg, int len, unsigned int *colopts,\n \t\t{ \"row\",    COL_ROW,      COL_LAYOUT_MASK },\n \t\t{ \"dense\",  COL_DENSE,    0 },\n \t};\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(opts); i++) {\n \t\tint set = 1, arg_len = len, name_len;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 1a39b5dde09..83924344964 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -40,7 +40,7 @@ static struct combine_diff_path *intersect_paths(\n \n \tif (!n) {\n \t\tfor (i = 0; i < q->nr; i++) {\n-\t\t\tint len;\n+\t\t\tsize_t len;\n \t\t\tconst char *path;\n \t\t\tif (diff_unmodified_pair(q->queue[i]))\n \t\t\t\tcontinue;\n@@ -251,7 +251,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \t/* At this point, baseend and newend point to the end of each lists */\n \ti--;\n \tj--;\n-\twhile (i != 0 || j != 0) {\n+\twhile (i > 0 || j > 0) {\n \t\tif (directions[i][j] == MATCH) {\n \t\t\tbaseend->parent_map |= 1<<parent;\n \t\t\tbaseend = baseend->prev;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex a7d87559328..d2680533353 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -501,7 +501,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct stat st;\n \tstruct object_id *oids;\n-\tint i = 0, valid = 1, count;\n+\tint i, valid = 1, count;\n \tchar *chain_name = get_commit_graph_chain_filename(odb);\n \tFILE *fp;\n \tint stat_res;\n@@ -1045,7 +1045,8 @@ static int write_graph_chunk_fanout(struct hashfile *f,\n \t\t\t\t    void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, count = 0;\n+\tunsigned int i;\n+\tuint32_t count = 0;\n \tstruct commit **list = ctx->commits.list;\n \n \t/*\n@@ -1195,7 +1196,7 @@ static int write_graph_chunk_generation_data(struct hashfile *f,\n \t\t\t\t\t     void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, num_generation_data_overflows = 0;\n+\tsize_t i, num_generation_data_overflows = 0;\n \n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n@@ -1219,7 +1220,7 @@ static int write_graph_chunk_generation_data_overflow(struct hashfile *f,\n \t\t\t\t\t\t      void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n \t\ttimestamp_t offset = commit_graph_data_at(c)->generation - c->date;\n@@ -1390,7 +1391,7 @@ static void add_missing_parents(struct write_commit_graph_context *ctx, struct c\n \n static void close_reachable(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *commit;\n \tenum commit_graph_split_flags flags = ctx->opts ?\n \t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n@@ -1448,7 +1449,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n static void compute_topological_levels(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1501,7 +1502,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n \n static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1582,10 +1583,10 @@ static void trace2_bloom_filter_write_statistics(struct write_commit_graph_conte\n \n static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct progress *progress = NULL;\n \tstruct commit **sorted_commits;\n-\tint max_new_filters;\n+\tsize_t max_new_filters;\n \n \tinit_bloom_filters();\n \ndiff --git a/commit-reach.c b/commit-reach.c\nindex c226ee3da46..4f790441f60 100644\n--- a/commit-reach.c\n+++ b/commit-reach.c\n@@ -723,7 +723,8 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\t timestamp_t min_generation)\n {\n \tstruct commit **list = NULL;\n-\tint i;\n+\tunsigned int i;\n+\tint j;\n \tint nr_commits;\n \tint result = 1;\n \n@@ -760,12 +761,12 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \n \tQSORT(list, nr_commits, compare_commits_by_gen);\n \n-\tfor (i = 0; i < nr_commits; i++) {\n+\tfor (j = 0; j < nr_commits; j++) {\n \t\t/* DFS from list[i] */\n \t\tstruct commit_list *stack = NULL;\n \n-\t\tlist[i]->object.flags |= assign_flag;\n-\t\tcommit_list_insert(list[i], &stack);\n+\t\tlist[j]->object.flags |= assign_flag;\n+\t\tcommit_list_insert(list[j], &stack);\n \n \t\twhile (stack) {\n \t\t\tstruct commit_list *parent;\n@@ -798,7 +799,7 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\tpop_commit(&stack);\n \t\t}\n \n-\t\tif (!(list[i]->object.flags & (with_flag | RESULT))) {\n+\t\tif (!(list[j]->object.flags & (with_flag | RESULT))) {\n \t\t\tresult = 0;\n \t\t\tgoto cleanup;\n \t\t}\ndiff --git a/commit.c b/commit.c\nindex 14538a811ae..e832ead185d 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -423,8 +423,8 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b\n \tstruct object_id parent;\n \tstruct commit_list **pptr;\n \tstruct commit_graft *graft;\n-\tconst int tree_entry_len = the_hash_algo->hexsz + 5;\n-\tconst int parent_entry_len = the_hash_algo->hexsz + 7;\n+\tconst size_t tree_entry_len = the_hash_algo->hexsz + 5;\n+\tconst size_t parent_entry_len = the_hash_algo->hexsz + 7;\n \tstruct tree *tree;\n \n \tif (item->object.parsed)\n@@ -1167,7 +1167,7 @@ int remove_signature(struct strbuf *buf)\n \t\tif (in_signature && line[0] == ' ')\n \t\t\tsigp->end = next;\n \t\telse if (starts_with(line, \"gpgsig\")) {\n-\t\t\tint i;\n+\t\t\tunsigned int i;\n \t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n \t\t\t\tconst char *p;\n \t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/compat/strcasestr.c b/compat/strcasestr.c\nindex 26896deca64..a5e69e06ba7 100644\n--- a/compat/strcasestr.c\n+++ b/compat/strcasestr.c\n@@ -2,16 +2,16 @@\n \n char *gitstrcasestr(const char *haystack, const char *needle)\n {\n-\tint nlen = strlen(needle);\n-\tint hlen = strlen(haystack) - nlen + 1;\n-\tint i;\n+\tsize_t nlen = strlen(needle);\n+\tsize_t hlen = strlen(haystack) - nlen + 1;\n+\tsize_t i;\n \n \tfor (i = 0; i < hlen; i++) {\n-\t\tint j;\n+\t\tsize_t j;\n \t\tfor (j = 0; j < nlen; j++) {\n \t\t\tunsigned char c1 = haystack[i+j];\n \t\t\tunsigned char c2 = needle[j];\n-\t\t\tif (toupper(c1) != toupper(c2))\n+\t\t\tif (tolower(c1) != tolower(c2))\n \t\t\t\tgoto next;\n \t\t}\n \t\treturn (char *) haystack + i;\ndiff --git a/compat/unsetenv.c b/compat/unsetenv.c\nindex b9d34af6136..8a7daff2699 100644\n--- a/compat/unsetenv.c\n+++ b/compat/unsetenv.c\n@@ -5,7 +5,7 @@ int gitunsetenv(const char *name)\n #if !defined(__MINGW32__)\n      extern char **environ;\n #endif\n-     int src, dst;\n+     size_t src, dst;\n      size_t nmln;\n \n      nmln = strlen(name);\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex 3abe8dd5a27..1cfacb0ceca 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -195,9 +195,9 @@ static void erase_in_line(void)\n \t\t&dummy);\n }\n \n-static void set_attr(char func, const int *params, int paramlen)\n+static void set_attr(char func, const int *params, size_t paramlen)\n {\n-\tint i;\n+\tsize_t i;\n \tswitch (func) {\n \tcase 'm':\n \t\tfor (i = 0; i < paramlen; i++) {\n@@ -344,7 +344,8 @@ static DWORD WINAPI console_thread(LPVOID unused)\n {\n \tunsigned char buffer[BUFFER_SIZE];\n \tDWORD bytes;\n-\tint start, end = 0, c, parampos = 0, state = TEXT;\n+\tint start, end = 0, c, state = TEXT;\n+\tsize_t parampos = 0;\n \tint params[MAX_PARAMS];\n \n \twhile (1) {\ndiff --git a/config.c b/config.c\nindex 27f38283add..97713244a9e 100644\n--- a/config.c\n+++ b/config.c\n@@ -721,7 +721,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \tif (env) {\n \t\tunsigned long count;\n \t\tchar *endp;\n-\t\tint i;\n+\t\tunsigned long i;\n \n \t\tcount = strtoul(env, &endp, 10);\n \t\tif (*endp) {\n@@ -736,7 +736,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\tfor (i = 0; i < count; i++) {\n \t\t\tconst char *key, *value;\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%lu\", i);\n \t\t\tkey = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!key) {\n \t\t\t\tret = error(_(\"missing config key %s\"), envvar.buf);\n@@ -744,7 +744,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\t\t}\n \t\t\tstrbuf_reset(&envvar);\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%lu\", i);\n \t\t\tvalue = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!value) {\n \t\t\t\tret = error(_(\"missing config value %s\"), envvar.buf);\n@@ -1372,7 +1372,7 @@ static enum fsync_component parse_fsync_components(const char *var, const char *\n \tenum fsync_component positive = 0, negative = 0;\n \n \twhile (string) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tsize_t len;\n \t\tconst char *ep;\n \t\tint negated = 0;\n@@ -2221,7 +2221,8 @@ int config_with_options(config_fn_t fn, void *data,\n \n static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)\n {\n-\tint i, value_index;\n+\tunsigned int i;\n+\tsize_t value_index;\n \tstruct string_list *values;\n \tstruct config_set_element *entry;\n \tstruct configset_list *list = &cs->list;\n@@ -3008,7 +3009,7 @@ static ssize_t write_section(int fd, const char *key,\n static ssize_t write_pair(int fd, const char *key, const char *value,\n \t\t\t  const struct config_store_data *store)\n {\n-\tint i;\n+\tsize_t i;\n \tssize_t ret;\n \tconst char *quote = \"\";\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -3065,17 +3066,19 @@ static ssize_t write_pair(int fd, const char *key, const char *value,\n  */\n static void maybe_remove_section(struct config_store_data *store,\n \t\t\t\t size_t *begin_offset, size_t *end_offset,\n-\t\t\t\t int *seen_ptr)\n+\t\t\t\t unsigned int *seen_ptr)\n {\n \tsize_t begin;\n-\tint i, seen, section_seen = 0;\n+\tunsigned int i;\n+\tunsigned int seen;\n+\tint section_seen = 0;\n \n \t/*\n \t * First, ensure that this is the first key, and that there are no\n \t * comments before the entry nor before the section header.\n \t */\n \tseen = *seen_ptr;\n-\tfor (i = store->seen[seen]; i > 0; i--) {\n+\tfor (i = store->seen[seen]; i; i--) {\n \t\tenum config_event_t type = store->parsed[i - 1].type;\n \n \t\tif (type == CONFIG_EVENT_COMMENT)\n@@ -3257,7 +3260,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t} else {\n \t\tstruct stat st;\n \t\tsize_t copy_begin, copy_end;\n-\t\tint i, new_line = 0;\n+\t\tunsigned int i;\n+\t\tint new_line = 0;\n \t\tstruct config_options opts;\n \n \t\tif (!value_pattern)\n@@ -3352,7 +3356,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \n \t\tfor (i = 0, copy_begin = 0; i < store.seen_nr; i++) {\n \t\t\tsize_t replace_end;\n-\t\t\tint j = store.seen[i];\n+\t\t\tunsigned int j = store.seen[i];\n \n \t\t\tnew_line = 0;\n \t\t\tif (!store.key_seen) {\n@@ -3487,9 +3491,10 @@ void git_config_set_multivar(const char *key, const char *value,\n \t\t\t\t\tflags);\n }\n \n-static int section_name_match (const char *buf, const char *name)\n+static unsigned int section_name_match(const char *buf, const char *name)\n {\n-\tint i = 0, j = 0, dot = 0;\n+\tunsigned int i = 0, j = 0;\n+\tint dot = 0;\n \tif (buf[i] != '[')\n \t\treturn 0;\n \tfor (i = 1; buf[i] && buf[i] != ']'; i++) {\ndiff --git a/config.h b/config.h\nindex ef9eade6414..a0b9273c8c4 100644\n--- a/config.h\n+++ b/config.h\n@@ -413,7 +413,7 @@ struct config_set_element {\n \n struct configset_list_item {\n \tstruct config_set_element *e;\n-\tint value_index;\n+\tsize_t value_index;\n };\n \n /*\ndiff --git a/connect.c b/connect.c\nindex 63e59641c0d..218c40df7bf 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -385,7 +385,7 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t\t  const char **unborn_head_target)\n {\n \tint ret = 1;\n-\tint i = 0;\n+\tsize_t i;\n \tstruct object_id old_oid;\n \tstruct ref *ref;\n \tstruct string_list line_sections = STRING_LIST_INIT_DUP;\n@@ -403,15 +403,14 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\tgoto out;\n \t}\n \n-\tif (!strcmp(\"unborn\", line_sections.items[i].string)) {\n-\t\ti++;\n+\tif (!strcmp(\"unborn\", line_sections.items[0].string)) {\n \t\tif (unborn_head_target &&\n-\t\t    !strcmp(\"HEAD\", line_sections.items[i++].string)) {\n+\t\t    !strcmp(\"HEAD\", line_sections.items[1].string)) {\n \t\t\t/*\n \t\t\t * Look for the symref target (if any). If found,\n \t\t\t * return it to the caller.\n \t\t\t */\n-\t\t\tfor (; i < line_sections.nr; i++) {\n+\t\t\tfor (i = 2; i < line_sections.nr; i++) {\n \t\t\t\tconst char *arg = line_sections.items[i].string;\n \n \t\t\t\tif (skip_prefix(arg, \"symref-target:\", &arg)) {\n@@ -422,19 +421,20 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t}\n \t\tgoto out;\n \t}\n-\tif (parse_oid_hex_algop(line_sections.items[i++].string, &old_oid, &end, reader->hash_algo) ||\n+\tif (parse_oid_hex_algop(line_sections.items[0].string, &old_oid, &end,\n+\t\t\t\treader->hash_algo) ||\n \t    *end) {\n \t\tret = 0;\n \t\tgoto out;\n \t}\n \n-\tref = alloc_ref(line_sections.items[i++].string);\n+\tref = alloc_ref(line_sections.items[1].string);\n \n \tmemcpy(ref->old_oid.hash, old_oid.hash, reader->hash_algo->rawsz);\n \t**list = ref;\n \t*list = &ref->next;\n \n-\tfor (; i < line_sections.nr; i++) {\n+\tfor (i = 2; i < line_sections.nr; i++) {\n \t\tconst char *arg = line_sections.items[i].string;\n \t\tif (skip_prefix(arg, \"symref-target:\", &arg))\n \t\t\tref->symref = xstrdup(arg);\n@@ -543,7 +543,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,\n \t\t\t     const struct string_list *server_options,\n \t\t\t     int stateless_rpc)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct strvec *ref_prefixes = transport_options ?\n \t\t&transport_options->ref_prefixes : NULL;\n \tconst char **unborn_head_target = transport_options ?\ndiff --git a/convert.c b/convert.c\nindex 9b676490320..ed7412b8a45 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -313,17 +313,15 @@ static void trace_encoding(const char *context, const char *path,\n {\n \tstatic struct trace_key coe = TRACE_KEY_INIT(WORKING_TREE_ENCODING);\n \tstruct strbuf trace = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tstrbuf_addf(&trace, \"%s (%s, considered %s):\\n\", context, path, encoding);\n \tfor (i = 0; i < len && buf; ++i) {\n-\t\tstrbuf_addf(\n-\t\t\t&trace, \"| \\033[2m%2i:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n-\t\t\ti,\n-\t\t\t(unsigned char) buf[i],\n-\t\t\t(buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n-\t\t\t((i+1) % 8 && (i+1) < len ? ' ' : '\\n')\n-\t\t);\n+\t\tstrbuf_addf(&trace,\n+\t\t\t    \"| \\033[2m%2u:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n+\t\t\t    (unsigned int)i, (unsigned char)buf[i],\n+\t\t\t    (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n+\t\t\t    ((i + 1) % 8 && (i + 1) < len ? ' ' : '\\n'));\n \t}\n \tstrbuf_addchars(&trace, '\\n', 1);\n \n@@ -1815,7 +1813,7 @@ struct ident_filter {\n \n static int is_foreign_ident(const char *str)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(str, \"$Id: \", &str))\n \t\treturn 0;\ndiff --git a/credential.c b/credential.c\nindex f6389a50684..f958c52d068 100644\n--- a/credential.c\n+++ b/credential.c\n@@ -333,7 +333,7 @@ static int credential_do(struct credential *c, const char *helper,\n \n void credential_fill(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->username && c->password)\n \t\treturn;\n@@ -356,7 +356,7 @@ void credential_fill(struct credential *c)\n \n void credential_approve(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->approved)\n \t\treturn;\n@@ -372,7 +372,7 @@ void credential_approve(struct credential *c)\n \n void credential_reject(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tcredential_apply_config(c);\n \ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..aa5ee229bd1 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1122,7 +1123,8 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s\n \tif (!listen_addr->nr)\n \t\tsetup_named_sock(NULL, listen_port, socklist);\n \telse {\n-\t\tint i, socknum;\n+\t\tsize_t i;\n+\t\tint socknum;\n \t\tfor (i = 0; i < listen_addr->nr; i++) {\n \t\t\tsocknum = setup_named_sock(listen_addr->items[i].string,\n \t\t\t\t\t\t   listen_port, socklist);\n@@ -1149,7 +1151,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/date.c b/date.c\nindex 53bd6a7932e..556591dd9c9 100644\n--- a/date.c\n+++ b/date.c\n@@ -421,12 +421,12 @@ static const struct {\n \n static int match_string(cons"},{"id":"473522","messageId":"pull.1399.v16.git.git.1678886439331.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v15.git.git.1673204590945.gitgitgadget@gmail.com","subject":"[PATCH v16] git: change variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-03-15T13:20:38Z","receivedAt":"2023-03-15T13:21:06Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nAs of right now, the current set of changes\nis too large to keep going, so future changes\nshould be in future patches. However, the codebase\nworks perfectly even if only these changes\nwere ever to be accepted. I just do not want\nto change too much at a time.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: change variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v16\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v16\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v15:\n\n 1:  0fd1aa406a0 ! 1:  8b4008fd55d git: change variable types to match what is assigned to them\n     @@ Commit message\n          were ever to be accepted. I just do not want\n          to change too much at a time.\n      \n     -    Signed-off-by: Seija Kijin <doremylover123@gmail.com\n     +    Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n       ## add-interactive.c ##\n      @@ add-interactive.c: static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n     @@ advice.c: void advise_if_enabled(enum advice_type type, const char *advice, ...)\n       \n       \tif (!strcmp(var, \"color.advice\")) {\n       \t\tadvice_use_color = git_config_colorbool(var, value);\n     +@@ advice.c: int git_default_advice_config(const char *var, const char *value)\n     + \n     + void list_config_advices(struct string_list *list, const char *prefix)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++)\n     + \t\tlist_config_item(list, prefix, advice_setting[i].key);\n      \n       ## apply.c ##\n      @@ apply.c: static int name_terminate(int c, int terminate)\n     @@ archive.c: int write_archive_entries(struct archiver_args *args,\n       \n      \n       ## attr.c ##\n     -@@ attr.c: struct attr_stack {\n     +@@ attr.c: static int attr_name_valid(const char *name, size_t namelen)\n     + \t * Attribute name cannot begin with '-' and must consist of\n     + \t * characters from [-A-Za-z0-9_.].\n     + \t */\n     +-\tif (namelen <= 0 || *name == '-')\n     ++\tif (namelen == 0 || *name == '-')\n     + \t\treturn 0;\n     +-\twhile (namelen--) {\n     ++\tdo {\n     + \t\tchar ch = *name++;\n     + \t\tif (! (ch == '-' || ch == '.' || ch == '_' ||\n     + \t\t       ('0' <= ch && ch <= '9') ||\n     + \t\t       ('a' <= ch && ch <= 'z') ||\n     + \t\t       ('A' <= ch && ch <= 'Z')) )\n     + \t\t\treturn 0;\n     +-\t}\n     ++\t} while (--namelen);\n     + \treturn 1;\n     + }\n     + \n     +@@ attr.c: static void check_vector_add(struct attr_check *c)\n       \n     - static void attr_stack_free(struct attr_stack *e)\n     + static void check_vector_remove(struct attr_check *check)\n       {\n      -\tint i;\n     -+\tunsigned int i, j;\n     - \tfree(e->origin);\n     - \tfor (i = 0; i < e->num_matches; i++) {\n     - \t\tstruct match_attr *a = e->attrs[i];\n     --\t\tint j;\n     - \t\tfor (j = 0; j < a->num_attr; j++) {\n     - \t\t\tconst char *setto = a->state[j].setto;\n     - \t\t\tif (setto == ATTR__TRUE ||\n     ++\tsize_t i;\n     + \n     + \tvector_lock();\n     + \n     +@@ attr.c: static void check_vector_remove(struct attr_check *check)\n     + /* Iterate through all attr_check instances and drop their stacks */\n     + static void drop_all_attr_stacks(void)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tvector_lock();\n     + \n      \n       ## base85.c ##\n      @@ base85.c: static void prep_base85(void)\n     @@ base85.c: void encode_85(char *buf, const unsigned char *data, int bytes)\n       \t\t}\n      \n       ## bisect.c ##\n     +@@ bisect.c: static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n     + \tstruct commit_list *p;\n     + \tstruct commit_dist *array = xcalloc(nr, sizeof(*array));\n     + \tstruct strbuf buf = STRBUF_INIT;\n     +-\tint cnt, i;\n     ++\tsize_t cnt, i;\n     + \n     + \tfor (p = list, cnt = 0; p; p = p->next) {\n     + \t\tint distance;\n      @@ bisect.c: static void read_bisect_paths(struct strvec *array)\n       static char *join_oid_array_hex(struct oid_array *array, char delim)\n       {\n     @@ bisect.c: static void read_bisect_paths(struct strvec *array)\n       \n       \tfor (i = 0; i < array->nr; i++) {\n       \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\n     +@@ bisect.c: static void bisect_rev_setup(struct repository *r, struct rev_info *revs,\n     + \tstruct setup_revision_opt opt = {\n     + \t\t.free_removed_argv_elements = 1,\n     + \t};\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \trepo_init_revisions(r, revs, prefix);\n     + \trevs->abbrev = 0;\n     +@@ bisect.c: static struct commit **get_bad_and_good_commits(struct repository *r,\n     + \t\t\t\t\t\tint *rev_nr)\n     + {\n     + \tstruct commit **rev;\n     +-\tint i, n = 0;\n     ++\tsize_t i, n = 0;\n     + \n     + \tALLOC_ARRAY(rev, 1 + good_revs.nr);\n     + \trev[n++] = get_commit_reference(r, current_bad_oid);\n      \n       ## blame.c ##\n      @@ blame.c: static void get_line_fingerprints(struct fingerprint *fingerprints,\n     @@ builtin/add.c: struct update_callback_data {\n       \tfor (i = 0; i < the_index.cache_nr; i++) {\n       \t\tstruct cache_entry *ce = the_index.cache[i];\n      \n     + ## builtin/clone.c ##\n     +@@ builtin/clone.c: int cmd_clone(int argc, const char **argv, const char *prefix)\n     + \t}\n     + \n     + \tif (mapped_refs) {\n     +-\t\tint hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n     ++\t\tunsigned hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n     + \n     + \t\t/*\n     + \t\t * Now that we know what algorithm the remote side is using,\n     +\n     + ## builtin/commit.c ##\n     +@@ builtin/commit.c: static int list_paths(struct string_list *list, const char *with_tree,\n     + \n     + static void add_remove_files(struct string_list *list)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < list->nr; i++) {\n     + \t\tstruct stat st;\n     + \t\tstruct string_list_item *p = &(list->items[i]);\n     +\n       ## builtin/fast-export.c ##\n      @@ builtin/fast-export.c: static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n       \n     @@ builtin/help.c: static void list_config_help(enum show_config_type type)\n       \tfor (p = config_name_list; *p; p++) {\n       \t\tconst char *var = *p;\n      \n     + ## builtin/index-pack.c ##\n     +@@ builtin/index-pack.c: int cmd_index_pack(int argc, const char **argv, const char *prefix)\n     + \tunsigned char pack_hash[GIT_MAX_RAWSZ];\n     + \tunsigned foreign_nr = 1;\t/* zero is a \"good\" value, assume bad */\n     + \tint report_end_of_input = 0;\n     +-\tint hash_algo = 0;\n     ++\tunsigned hash_algo = 0;\n     + \n     + \t/*\n     + \t * index-pack never needs to fetch missing objects except when\n     +\n     + ## builtin/init-db.c ##\n     +@@ builtin/init-db.c: static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n     + \treturn 1;\n     + }\n     + \n     +-void initialize_repository_version(int hash_algo, int reinit)\n     ++void initialize_repository_version(unsigned hash_algo, int reinit)\n     + {\n     + \tchar repo_version_string[10];\n     +-\tint repo_version = GIT_REPO_VERSION;\n     ++\tunsigned repo_version = GIT_REPO_VERSION;\n     + \n     + \tif (hash_algo != GIT_HASH_SHA1)\n     + \t\trepo_version = GIT_REPO_VERSION_READ;\n     + \n     + \t/* This forces creation of new config file */\n     + \txsnprintf(repo_version_string, sizeof(repo_version_string),\n     +-\t\t  \"%d\", repo_version);\n     ++\t\t  \"%u\", repo_version);\n     + \tgit_config_set(\"core.repositoryformatversion\", repo_version_string);\n     + \n     + \tif (hash_algo != GIT_HASH_SHA1)\n     +@@ builtin/init-db.c: static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash\n     + \telse if (hash != GIT_HASH_UNKNOWN)\n     + \t\trepo_fmt->hash_algo = hash;\n     + \telse if (env) {\n     +-\t\tint env_algo = hash_algo_by_name(env);\n     ++\t\tunsigned env_algo = hash_algo_by_name(env);\n     + \t\tif (env_algo == GIT_HASH_UNKNOWN)\n     + \t\t\tdie(_(\"unknown hash algorithm '%s'\"), env);\n     + \t\trepo_fmt->hash_algo = env_algo;\n     +@@ builtin/init-db.c: int cmd_init_db(int argc, const char **argv, const char *prefix)\n     + \tunsigned int flags = 0;\n     + \tconst char *object_format = NULL;\n     + \tconst char *initial_branch = NULL;\n     +-\tint hash_algo = GIT_HASH_UNKNOWN;\n     ++\tunsigned hash_algo = GIT_HASH_UNKNOWN;\n     + \tconst struct option init_db_options[] = {\n     + \t\tOPT_STRING(0, \"template\", &template_dir, N_(\"template-directory\"),\n     + \t\t\t\tN_(\"directory from which templates will be used\")),\n     +\n       ## builtin/log.c ##\n      @@ builtin/log.c: static void cmd_log_init_defaults(struct rev_info *rev)\n       \n     @@ builtin/merge.c: static struct strategy *get_strategy(const char *name)\n      +\t\t\tsize_t j;\n      +\t\t\tint found = 0;\n       \t\t\tstruct cmdname *ent = main_cmds.names[i];\n     - \t\t\tfor (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n     + \t\t\tfor (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)\n       \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\n      \n       ## builtin/name-rev.c ##\n     @@ builtin/pack-objects.c: static int want_object_in_pack(const struct object_id *o\n       \t\tconst char *p;\n       \n       \t\tif (ex) {\n     -@@ builtin/pack-objects.c: static void pbase_tree_put(struct pbase_tree_cache *cache)\n     - \tfree(cache);\n     - }\n     - \n     --static int name_cmp_len(const char *name)\n     -+static size_t name_cmp_len(const char *name)\n     - {\n     --\tint i;\n     -+\tsize_t i;\n     - \tfor (i = 0; name[i] && name[i] != '\\n' && name[i] != '/'; i++)\n     - \t\t;\n     - \treturn i;\n     - }\n     - \n     --static void add_pbase_object(struct tree_desc *tree,\n     --\t\t\t     const char *name,\n     --\t\t\t     int cmplen,\n     --\t\t\t     const char *fullname)\n     -+static void add_pbase_object(struct tree_desc *tree, const char *name,\n     -+\t\t\t     size_t cmplen, const char *fullname)\n     - {\n     - \tstruct name_entry entry;\n     - \tint cmp;\n     -@@ builtin/pack-objects.c: static void add_pbase_object(struct tree_desc *tree,\n     - \t\t\tstruct tree_desc sub;\n     - \t\t\tstruct pbase_tree_cache *tree;\n     - \t\t\tconst char *down = name+cmplen+1;\n     --\t\t\tint downlen = name_cmp_len(down);\n     -+\t\t\tsize_t downlen = name_cmp_len(down);\n     - \n     - \t\t\ttree = pbase_tree_get(&entry.oid);\n     - \t\t\tif (!tree)\n      @@ builtin/pack-objects.c: static void add_extra_kept_packs(const struct string_list *names)\n       \n       \tfor (p = get_all_packs(the_repository); p; p = p->next) {\n     @@ builtin/read-tree.c: static void debug_stage(const char *label, const struct cac\n       \treturn 0;\n      \n       ## builtin/rebase.c ##\n     -@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)\n     - \t\toptions.gpg_sign_opt = xstrfmt(\"-S%s\", gpg_sign);\n     - \n     - \tif (exec.nr) {\n     --\t\tint i;\n     -+\t\tsize_t j;\n     - \n     - \t\timply_merge(&options, \"--exec\");\n     - \n     - \t\tstrbuf_reset(&buf);\n     --\t\tfor (i = 0; i < exec.nr; i++)\n     --\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[i].string);\n     -+\t\tfor (j = 0; j < exec.nr; j++)\n     -+\t\t\tstrbuf_addf(&buf, \"exec %s\\n\", exec.items[j].string);\n     - \t\toptions.cmd = xstrdup(buf.buf);\n     - \t}\n     - \n      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)\n       \t}\n       \n     @@ builtin/show-index.c: static const char *const show_index_usage[] = {\n       \tunsigned nr;\n       \tunsigned int version;\n       \tstatic unsigned int top_index[256];\n     + \tunsigned hashsz;\n     + \tconst char *hash_name = NULL;\n     +-\tint hash_algo;\n     ++\tunsigned hash_algo;\n     + \tconst struct option show_index_options[] = {\n     + \t\tOPT_STRING(0, \"object-format\", &hash_name, N_(\"hash-algorithm\"),\n     + \t\t\t   N_(\"specify the hash algorithm to use\")),\n      \n       ## builtin/sparse-checkout.c ##\n      @@ builtin/sparse-checkout.c: static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n     @@ builtin/worktree.c: static void show_worktree(struct worktree *wt, int path_maxl\n       \t\tint sha1_len;\n      @@ builtin/worktree.c: static void validate_no_submodules(const struct worktree *wt)\n       {\n     - \tstruct index_state istate = { NULL };\n     + \tstruct index_state istate = INDEX_STATE_INIT(the_repository);\n       \tstruct strbuf path = STRBUF_INIT;\n      -\tint i, found_submodules = 0;\n      +\tunsigned int i;\n     @@ bulk-checkin.c: static void flush_batch_fsync(void)\n      \n       ## bundle.c ##\n      @@ bundle.c: static int parse_capability(struct bundle_header *header, const char *capability\n     + {\n     + \tconst char *arg;\n     + \tif (skip_prefix(capability, \"object-format=\", &arg)) {\n     +-\t\tint algo = hash_algo_by_name(arg);\n     ++\t\tunsigned algo = hash_algo_by_name(arg);\n     + \t\tif (algo == GIT_HASH_UNKNOWN)\n     + \t\t\treturn error(_(\"unrecognized bundle hash algorithm: %s\"), arg);\n     + \t\theader->hash_algo = &hash_algos[algo];\n     +@@ bundle.c: static int parse_capability(struct bundle_header *header, const char *capability\n       \n       static int parse_bundle_signature(struct bundle_header *header, const char *line)\n       {\n     @@ bundle.c: int is_bundle(const char *path, int quiet)\n       \tfor (i = 0; i < r->nr; i++) {\n       \t\tstruct object_id *oid;\n      @@ bundle.c: int verify_bundle(struct repository *r,\n     - \tstruct rev_info revs = REV_INFO_INIT;\n     - \tconst char *argv[] = {NULL, \"--all\", NULL};\n     - \tstruct commit *commit;\n     --\tint i, ret = 0, req_nr;\n     + \t * to be verbose about the errors\n     + \t */\n     + \tstruct string_list *p = &header->prerequisites;\n     +-\tint i, ret = 0;\n      +\tsize_t i;\n      +\tint ret = 0;\n     -+\tunsigned int req_nr;\n       \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n     - \n     - \tif (!r || !r->objects || !r->objects->odb)\n     + \tstruct string_list_iterator iter = {\n     + \t\t.list = p,\n      @@ bundle.c: out:\n       static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n       {\n     @@ cache-tree.c: static int verify_one(struct repository *r,\n       \treturn 0;\n      \n       ## cache.h ##\n     +@@ cache.h: int path_inside_repo(const char *prefix, const char *path);\n     + #define INIT_DB_EXIST_OK 0x0002\n     + \n     + int init_db(const char *git_dir, const char *real_git_dir,\n     +-\t    const char *template_dir, int hash_algo,\n     ++\t    const char *template_dir, unsigned int hash_algo,\n     + \t    const char *initial_branch, unsigned int flags);\n     +-void initialize_repository_version(int hash_algo, int reinit);\n     ++void initialize_repository_version(unsigned int hash_algo, int reinit);\n     + \n     + void sanitize_stdfds(void);\n     + int daemonize(void);\n     +@@ cache.h: struct repository_format {\n     + \tchar *partial_clone; /* value of extensions.partialclone */\n     + \tint worktree_config;\n     + \tint is_bare;\n     +-\tint hash_algo;\n     ++\tunsigned hash_algo;\n     + \tint sparse_index;\n     + \tchar *work_tree;\n     + \tstruct string_list unknown_extensions;\n      @@ cache.h: void check_repository_format(struct repository_format *fmt);\n        */\n       const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);\n     @@ cache.h: void check_repository_format(struct repository_format *fmt);\n       #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)\n       \n       /* set default permissions by passing mode arguments to open(2) */\n     -@@ cache.h: int repo_interpret_branch_name(struct repository *r,\n     - \n     - int validate_headref(const char *ref);\n     - \n     --int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     --int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);\n     -+int base_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t      const char *name2, size_t len2, int mode2);\n     -+int df_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t    const char *name2, size_t len2, int mode2);\n     +@@ cache.h: int base_name_compare(const char *name1, size_t len1, int mode1,\n     + int df_name_compare(const char *name1, size_t len1, int mode1,\n     + \t\t    const char *name2, size_t len2, int mode2);\n       int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n      -int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n      +int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n     @@ color.c: static int get_hex_color(const char *in, unsigned char *out)\n       \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n       \t};\n      -\tint i;\n     +-\tint color_offset = COLOR_FOREGROUND_ANSI;\n      +\tunsigned int i;\n     - \tint color_offset = COLOR_FOREGROUND_ANSI;\n     ++\tunsigned int color_offset = COLOR_FOREGROUND_ANSI;\n       \n       \tif (match_word(name, len, \"default\")) {\n     + \t\t/*\n      @@ color.c: static int parse_ansi_color(struct color *out, const char *name, int len)\n       \treturn -1;\n       }\n     @@ column.c: static int parse_option(const char *arg, int len, unsigned int *colopt\n       \t\tint set = 1, arg_len = len, name_len;\n      \n       ## combine-diff.c ##\n     +@@ combine-diff.c: static int filename_changed(char status)\n     + \n     + static struct combine_diff_path *intersect_paths(\n     + \tstruct combine_diff_path *curr,\n     +-\tint n,\n     +-\tint num_parent,\n     ++\tsize_t n,\n     ++\tsize_t num_parent,\n     + \tint combined_all_paths)\n     + {\n     + \tstruct diff_queue_struct *q = &diff_queued_diff;\n      @@ combine-diff.c: static struct combine_diff_path *intersect_paths(\n       \n       \tif (!n) {\n     @@ combine-diff.c: static struct lline *coalesce_lines(struct lline *base, int *len\n       \t\tif (directions[i][j] == MATCH) {\n       \t\t\tbaseend->parent_map |= 1<<parent;\n       \t\t\tbaseend = baseend->prev;\n     +@@ combine-diff.c: static void dump_sline(struct sline *sline, const char *line_prefix,\n     + \t\tprintf(\"%s\\n\", c_reset);\n     + \t\twhile (lno < hunk_end) {\n     + \t\t\tstruct lline *ll;\n     +-\t\t\tint j;\n     + \t\t\tunsigned long p_mask;\n     + \t\t\tstruct sline *sl = &sline[lno++];\n     + \t\t\tll = (sl->flag & no_pre_delete) ? NULL : sl->lost;\n     + \t\t\twhile (ll) {\n     + \t\t\t\tprintf(\"%s%s\", line_prefix, c_old);\n     +-\t\t\t\tfor (j = 0; j < num_parent; j++) {\n     +-\t\t\t\t\tif (ll->parent_map & (1UL<<j))\n     ++\t\t\t\tfor (i = 0; i < num_parent; i++) {\n     ++\t\t\t\t\tif (ll->parent_map & (1UL<<i))\n     + \t\t\t\t\t\tputchar('-');\n     + \t\t\t\t\telse\n     + \t\t\t\t\t\tputchar(' ');\n     +@@ combine-diff.c: static void dump_sline(struct sline *sline, const char *line_prefix,\n     + \t\t\t}\n     + \t\t\telse\n     + \t\t\t\tfputs(c_new, stdout);\n     +-\t\t\tfor (j = 0; j < num_parent; j++) {\n     ++\t\t\tfor (i = 0; i < num_parent; i++) {\n     + \t\t\t\tif (p_mask & sl->flag)\n     + \t\t\t\t\tputchar('+');\n     + \t\t\t\telse\n     +@@ combine-diff.c: static struct combine_diff_path *find_paths_generic(const struct object_id *oid,\n     + \tint combined_all_paths)\n     + {\n     + \tstruct combine_diff_path *paths = NULL;\n     +-\tint i, num_parent = parents->nr;\n     ++\tsize_t i, num_parent = parents->nr;\n     + \n     + \tint output_format = opt->output_format;\n     + \tconst char *orderfile = opt->orderfile;\n     +@@ combine-diff.c: static struct combine_diff_path *find_paths_multitree(\n     + \tconst struct object_id *oid, const struct oid_array *parents,\n     + \tstruct diff_options *opt)\n     + {\n     +-\tint i, nparent = parents->nr;\n     ++\tsize_t i, nparent = parents->nr;\n     + \tconst struct object_id **parents_oid;\n     + \tstruct combine_diff_path paths_head;\n     + \tstruct strbuf base;\n      \n       ## commit-graph.c ##\n      @@ commit-graph.c: static struct commit_graph *load_commit_graph_chain(struct repository *r,\n     @@ commit.c: int remove_signature(struct strbuf *buf)\n       \t\t\tsigp->end = next;\n       \t\telse if (starts_with(line, \"gpgsig\")) {\n      -\t\t\tint i;\n     -+\t\t\tunsigned int i;\n     - \t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n     +-\t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n     ++\t\t\tunsigned int j;\n     ++\t\t\tfor (j = 1; j < GIT_HASH_NALGOS; j++) {\n       \t\t\t\tconst char *p;\n     - \t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\n     +-\t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\n     ++\t\t\t\tif (skip_prefix(line, gpg_sig_headers[j], &p) &&\n     + \t\t\t\t    *p == ' ') {\n     + \t\t\t\t\tsigp->start = line;\n     + \t\t\t\t\tsigp->end = next;\n      \n       ## compat/compiler.h ##\n      @@\n     @@ config.h: struct config_set_element {\n       /*\n      \n       ## connect.c ##\n     +@@ connect.c: static void process_capabilities(struct packet_reader *reader, int *linelen)\n     + \tfeat_val = server_feature_value(\"object-format\", &feat_len);\n     + \tif (feat_val) {\n     + \t\tchar *hash_name = xstrndup(feat_val, feat_len);\n     +-\t\tint hash_algo = hash_algo_by_name(hash_name);\n     ++\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n     + \t\tif (hash_algo != GIT_HASH_UNKNOWN)\n     + \t\t\treader->hash_algo = &hash_algos[hash_algo];\n     + \t\tfree(hash_name);\n      @@ connect.c: static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n       \t\t\t  const char **unborn_head_target)\n       {\n     @@ connect.c: static int process_ref_v2(struct packet_reader *reader, struct ref **\n       \t\tconst char *arg = line_sections.items[i].string;\n       \t\tif (skip_prefix(arg, \"symref-target:\", &arg))\n       \t\t\tref->symref = xstrdup(arg);\n     +@@ connect.c: static void send_capabilities(int fd_out, struct packet_reader *reader)\n     + \t\tpacket_write_fmt(fd_out, \"agent=%s\", git_user_agent_sanitized());\n     + \n     + \tif (server_feature_v2(\"object-format\", &hash_name)) {\n     +-\t\tint hash_algo = hash_algo_by_name(hash_name);\n     ++\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n     + \t\tif (hash_algo == GIT_HASH_UNKNOWN)\n     + \t\t\tdie(_(\"unknown object format '%s' specified by server\"), hash_name);\n     + \t\treader->hash_algo = &hash_algos[hash_algo];\n      @@ connect.c: struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,\n       \t\t\t     const struct string_list *server_options,\n       \t\t\t     int stateless_rpc)\n     @@ diagnose.c: static struct diagnose_option diagnose_options[] = {\n       \tif (!arg) {\n      \n       ## diff-lib.c ##\n     +@@ diff-lib.c: static int match_stat_with_submodule(struct diff_options *diffopt,\n     + \n     + int run_diff_files(struct rev_info *revs, unsigned int option)\n     + {\n     +-\tint entries, i;\n     ++\tunsigned int entries, i;\n     + \tint diff_unmerged_stage = revs->max_count;\n     + \tunsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)\n     + \t\t\t      ? CE_MATCH_RACY_IS_DIRTY : 0);\n      @@ diff-lib.c: static int diff_cache(struct rev_info *revs,\n       \n       void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)\n     @@ dir.h: int fill_directory(struct dir_struct *dir,\n       \n       enum pattern_match_result {\n      \n     + ## fetch-pack.c ##\n     +@@ fetch-pack.c: static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n     + \tif (advertise_sid && server_supports_v2(\"session-id\"))\n     + \t\tpacket_buf_write(req_buf, \"session-id=%s\", trace2_session_id());\n     + \tif (server_options && server_options->nr) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tensure_server_supports_v2(\"server-option\");\n     + \t\tfor (i = 0; i < server_options->nr; i++)\n     + \t\t\tpacket_buf_write(req_buf, \"server-option=%s\",\n     +@@ fetch-pack.c: static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n     + \t}\n     + \n     + \tif (server_feature_v2(\"object-format\", &hash_name)) {\n     +-\t\tint hash_algo = hash_algo_by_name(hash_name);\n     ++\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n     + \t\tif (hash_algo_by_ptr(the_hash_algo) != hash_algo)\n     + \t\t\tdie(_(\"mismatched algorithms: client %s; server %s\"),\n     + \t\t\t    the_hash_algo->name, hash_name);\n     +\n       ## fsck.c ##\n      @@ fsck.c: static struct {\n       \n     @@ git.c: static void list_builtins(struct string_list *list, unsigned int exclude_\n       \twhile (i < list->nr) {\n       \t\tif (strstr(list->items[i].string, \"--\"))\n      \n     + ## hash.h ##\n     +@@ hash.h: extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];\n     +  * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if\n     +  * the name doesn't match a known algorithm.\n     +  */\n     +-int hash_algo_by_name(const char *name);\n     ++unsigned hash_algo_by_name(const char *name);\n     + /* Identical, except based on the format ID. */\n     +-int hash_algo_by_id(uint32_t format_id);\n     ++unsigned hash_algo_by_id(uint32_t format_id);\n     + /* Identical, except based on the length. */\n     +-int hash_algo_by_length(int len);\n     ++unsigned hash_algo_by_length(size_t len);\n     + /* Identical, except for a pointer to struct git_hash_algo. */\n     +-static inline int hash_algo_by_ptr(const struct git_hash_algo *p)\n     ++static inline unsigned hash_algo_by_ptr(const struct git_hash_algo *p)\n     + {\n     + \treturn p - hash_algos;\n     + }\n     +\n     + ## help.c ##\n     +@@ help.c: static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask)\n     + static void print_command_list(const struct cmdname_help *cmds,\n     + \t\t\t       uint32_t mask, int longest)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; cmds[i].name; i++) {\n     + \t\tif (cmds[i].category & mask) {\n     +@@ help.c: void list_all_other_cmds(struct string_list *list)\n     + void list_cmds_by_category(struct string_list *list,\n     + \t\t\t   const char *cat)\n     + {\n     +-\tint i, n = ARRAY_SIZE(command_list);\n     ++\tsize_t i, n = ARRAY_SIZE(command_list);\n     + \tuint32_t cat_id = 0;\n     + \n     + \tfor (i = 0; category_names[i]; i++) {\n     +@@ help.c: static int get_alias(const char *var, const char *value, void *data)\n     + static void list_all_cmds_help_external_commands(void)\n     + {\n     + \tstruct string_list others = STRING_LIST_INIT_DUP;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tlist_all_other_cmds(&others);\n     + \tif (others.nr)\n     +@@ help.c: static void list_all_cmds_help_aliases(int longest)\n     + {\n     + \tstruct string_list alias_list = STRING_LIST_INIT_DUP;\n     + \tstruct cmdname_help *aliases;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tgit_config(get_alias, &alias_list);\n     + \tstring_list_sort(&alias_list);\n     +@@ help.c: static struct string_list guess_refs(const char *ref)\n     + NORETURN void help_unknown_ref(const char *ref, const char *cmd,\n     + \t\t\t       const char *error)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct string_list suggested_refs = guess_refs(ref);\n     + \n     + \tfprintf_ln(stderr, _(\"%s: %s - %s\"), cmd, ref, error);\n     +\n     + ## help.h ##\n     +@@ help.h: static inline void list_config_item(struct string_list *list,\n     + #define define_list_config_array(array)\t\t\t\t\t\\\n     + void list_config_##array(struct string_list *list, const char *prefix)\t\\\n     + {\t\t\t\t\t\t\t\t\t\\\n     +-\tint i;\t\t\t\t\t\t\t\t\\\n     ++\tsize_t i;\t\t\t\t\t\t\t\t\\\n     + \tfor (i = 0; i < ARRAY_SIZE(array); i++)\t\t\t\t\\\n     + \t\tif (array[i])\t\t\t\t\t\t\\\n     + \t\t\tlist_config_item(list, prefix, array[i]);\t\\\n     +@@ help.h: struct string_list\n     + #define define_list_config_array_extra(array, values)\t\t\t\\\n     + void list_config_##array(struct string_list *list, const char *prefix)\t\\\n     + {\t\t\t\t\t\t\t\t\t\\\n     +-\tint i;\t\t\t\t\t\t\t\t\\\n     ++\tsize_t i;\t\t\t\t\t\t\t\t\\\n     + \tstatic const char *extra[] = values;\t\t\t\t\\\n     + \tfor (i = 0; i < ARRAY_SIZE(extra); i++)\t\t\t\t\\\n     + \t\tlist_config_item(list, prefix, extra[i]);\t\t\\\n     +\n     + ## hex.c ##\n     +@@ hex.c: int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)\n     + static int get_hash_hex_algop(const char *hex, unsigned char *hash,\n     + \t\t\t      const struct git_hash_algo *algop)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < algop->rawsz; i++) {\n     + \t\tint val = hex2chr(hex);\n     + \t\tif (val < 0)\n     +@@ hex.c: char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash,\n     + {\n     + \tstatic const char hex[] = \"0123456789abcdef\";\n     + \tchar *buf = buffer;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/*\n     + \t * Our struct object_id has been memset to 0, so default to printing\n     +\n     + ## http-backend.c ##\n     +@@ http-backend.c: static struct rpc_service *select_service(struct strbuf *hdr, const char *name)\n     + {\n     + \tconst char *svc_name;\n     + \tstruct rpc_service *svc = NULL;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!skip_prefix(name, \"git-\", &svc_name))\n     + \t\tforbidden(hdr, \"Unsupported service: '%s'\", name);\n     +@@ http-backend.c: int cmd_main(int argc, const char **argv)\n     + \tchar *dir;\n     + \tstruct service_cmd *cmd = NULL;\n     + \tchar *cmd_arg = NULL;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct strbuf hdr = STRBUF_INIT;\n     + \n     + \tset_die_routine(die_webcgi);\n     +\n     + ## http-push.c ##\n     +@@ http-push.c: static struct object_list **process_tree(struct tree *tree,\n     + \n     + static int get_delta(struct rev_info *revs, struct remote_lock *lock)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct commit *commit;\n     + \tstruct object_list **p = &objects;\n     + \tint count = 0;\n     +@@ http-push.c: static int delete_remote_branch(const char *pattern, int force)\n     + \tstruct object_id head_oid;\n     + \tchar *symref = NULL;\n     + \tint match;\n     +-\tint patlen = strlen(pattern);\n     +-\tint i;\n     ++\tsize_t patlen = strlen(pattern);\n     ++\tsize_t i;\n     + \tstruct active_request_slot *slot;\n     + \tstruct slot_results results;\n     + \tchar *url;\n     +@@ http-push.c: static int delete_remote_branch(const char *pattern, int force)\n     + \t/* Find the remote branch(es) matching the specified branch name */\n     + \tfor (match = 0; refs; refs = refs->next) {\n     + \t\tchar *name = refs->name;\n     +-\t\tint namelen = strlen(name);\n     ++\t\tsize_t namelen = strlen(name);\n     + \t\tif (namelen < patlen ||\n     + \t\t    memcmp(name + namelen - patlen, pattern, patlen))\n     + \t\t\tcontinue;\n     +\n     + ## http-walker.c ##\n     +@@ http-walker.c: static int is_alternate_allowed(const char *url)\n     + \tconst char *protocols[] = {\n     + \t\t\"http\", \"https\", \"ftp\", \"ftps\"\n     + \t};\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (http_follow_config != HTTP_FOLLOW_ALWAYS) {\n     + \t\twarning(\"alternate disabled by http.followRedirects: %s\", url);\n     +@@ http-walker.c: static void process_alternates_response(void *callback_data)\n     + \tconst char *base = alt_req->base;\n     + \tconst char null_byte = '\\0';\n     + \tchar *data;\n     +-\tint i = 0;\n     ++\tsize_t i = 0;\n     + \n     + \tnormalize_curl_result(&slot->curl_result, slot->http_code,\n     + \t\t\t      curl_errorstr, sizeof(curl_errorstr));\n     +@@ http-walker.c: static void process_alternates_response(void *callback_data)\n     + \tdata = alt_req->buffer->buf;\n     + \n     + \twhile (i < alt_req->buffer->len) {\n     +-\t\tint posn = i;\n     ++\t\tsize_t posn = i;\n     + \t\twhile (posn < alt_req->buffer->len && data[posn] != '\\n')\n     + \t\t\tposn++;\n     + \t\tif (data[posn] == '\\n') {\n     + \t\t\tint okay = 0;\n     +-\t\t\tint serverlen = 0;\n     ++\t\t\tsize_t serverlen = 0;\n     + \t\t\tstruct alt_base *newalt;\n     + \t\t\tif (data[i] == '/') {\n     + \t\t\t\t/*\n     +\n     + ## http.c ##\n     +@@ http.c: static void init_curl_proxy_auth(CURL *result)\n     + \tvar_override(&http_proxy_authmethod, getenv(\"GIT_HTTP_PROXY_AUTHMETHOD\"));\n     + \n     + \tif (http_proxy_authmethod) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) {\n     + \t\t\tif (!strcmp(http_proxy_authmethod, proxy_authmethods[i].name)) {\n     + \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYAUTH,\n     +@@ http.c: static long get_curl_allowed_protocols(int from_user, struct strbuf *list)\n     + #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n     + static int get_curl_http_version_opt(const char *version_string, long *opt)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstatic struct {\n     + \t\tconst char *name;\n     + \t\tlong opt_token;\n     +@@ http.c: static CURL *get_curl_handle(void)\n     + \n     + #ifdef CURLGSSAPI_DELEGATION_FLAG\n     + \tif (curl_deleg) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {\n     + \t\t\tif (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {\n     + \t\t\t\tcurl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,\n     +@@ http.c: static CURL *get_curl_handle(void)\n     + \tif (getenv(\"GIT_SSL_VERSION\"))\n     + \t\tssl_version = getenv(\"GIT_SSL_VERSION\");\n     + \tif (ssl_version && *ssl_version) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; i < ARRAY_SIZE(sslversions); i++) {\n     + \t\t\tif (!strcmp(ssl_version, sslversions[i].name)) {\n     + \t\t\t\tcurl_easy_setopt(result, CURLOPT_SSLVERSION,\n     +@@ http.c: void http_init(struct remote *remote, const char *url, int proactive_auth)\n     + \tif (http_ssl_backend) {\n     + \t\tconst curl_ssl_backend **backends;\n     + \t\tstruct strbuf buf = STRBUF_INIT;\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tswitch (curl_global_sslset(-1, http_ssl_backend, &backends)) {\n     + \t\tcase CURLSSLSET_UNKNOWN_BACKEND:\n     +@@ http.c: static void write_accept_language(struct strbuf *buf)\n     + \tconst int MAX_LANGUAGE_TAGS = 1000;\n     + \tconst int MAX_ACCEPT_LANGUAGE_HEADER_SIZE = 4000;\n     + \tchar **language_tags = NULL;\n     +-\tint num_langs = 0;\n     ++\tunsigned int num_langs = 0;\n     + \tconst char *s = get_preferred_languages();\n     +-\tint i;\n     ++\tunsigned int i;\n     + \tstruct strbuf tag = STRBUF_INIT;\n     + \n     + \t/* Don't add Accept-Language header if no language is preferred. */\n     +@@ http.c: static void write_accept_language(struct strbuf *buf)\n     + \t\t     decimal_places++, max_q *= 10)\n     + \t\t\t;\n     + \n     +-\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%dd\", decimal_places);\n     ++\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%ud\", decimal_places);\n     + \n     + \t\tstrbuf_addstr(buf, \"Accept-Language: \");\n     + \n     +\n     + ## line-log.c ##\n     +@@ line-log.c: static void range_set_map_across_diff(struct range_set *out,\n     + static struct commit *check_single_commit(struct rev_info *revs)\n     + {\n     + \tstruct object *commit = NULL;\n     +-\tint found = -1;\n     +-\tint i;\n     ++\tunsigned found = 0;\n     ++\tunsigned i;\n     + \n     + \tfor (i = 0; i < revs->pending.nr; i++) {\n     + \t\tstruct object *obj = revs->pending.objects[i].item;\n     +\n       ## list-objects-filter-options.c ##\n      @@ list-objects-filter-options.c: void list_objects_filter_copy(\n       \tstruct list_objects_filter_options *dest,\n     @@ list-objects-filter-options.c: void list_objects_filter_copy(\n       \t/* Copy everything. We will overwrite the pointers shortly. */\n       \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\n      \n     + ## list-objects.c ##\n     +@@ list-objects.c: void mark_edges_uninteresting(struct rev_info *revs,\n     + \t\t\t      int sparse)\n     + {\n     + \tstruct commit_list *list;\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tif (sparse) {\n     + \t\tstruct oidset set;\n     +@@ list-objects.c: static void add_pending_tree(struct rev_info *revs, struct tree *tree)\n     + static void traverse_non_commits(struct traversal_context *ctx,\n     + \t\t\t\t struct strbuf *base)\n     + {\n     +-\tint i;\n     ++\tunsigned int i;\n     + \n     + \tassert(base->len == 0);\n     + \n     +\n     + ## ll-merge.c ##\n     +@@ ll-merge.c: static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,\n     + \tstruct strbuf_expand_dict_entry dict[6];\n     + \tstruct strbuf path_sq = STRBUF_INIT;\n     + \tstruct child_process child = CHILD_PROCESS_INIT;\n     +-\tint status, fd, i;\n     ++\tint status, fd;\n     ++\tunsigned int i;\n     + \tstruct stat st;\n     + \tenum ll_merge_result ret;\n     + \tassert(opts);\n     +@@ ll-merge.c: static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr\n     + {\n     + \tstruct ll_merge_driver *fn;\n     + \tconst char *name;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tinitialize_ll_merge();\n     + \n     +\n     + ## lockfile.c ##\n     +@@\n     +  */\n     + static void trim_last_path_component(struct strbuf *path)\n     + {\n     +-\tint i = path->len;\n     ++\tsize_t i = path->len;\n     + \n     + \t/* back up past trailing slashes, if any */\n     + \twhile (i && path->buf[i - 1] == '/')\n     +\n     + ## log-tree.c ##\n     +@@ log-tree.c: static int add_ref_decoration(const char *refname, const struct object_id *oid,\n     + \t\t\t      int flags UNUSED,\n     + \t\t\t      void *cb_data)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct object *obj;\n     + \tenum object_type objtype;\n     + \tenum decoration_type deco_type = DECORATION_NONE;\n     +\n     + ## ls-refs.c ##\n     +@@ ls-refs.c: static void ensure_config_read(void)\n     +  */\n     + static int ref_match(const struct strvec *prefixes, const char *refname)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!prefixes->nr)\n     + \t\treturn 1; /* no restriction */\n     +\n     + ## mailinfo.c ##\n     +@@ mailinfo.c: check_header_out:\n     + static int is_inbody_header(const struct mailinfo *mi,\n     + \t\t\t    const struct strbuf *line)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tconst char *val;\n     + \tfor (i = 0; header[i]; i++)\n     + \t\tif (!mi->s_hdr_data[i] && skip_header(line, header[i], &val))\n     +@@ mailinfo.c: static int check_inbody_header(struct mailinfo *mi, const struct strbuf *line)\n     + \tif (starts_with(line->buf, \">From\") && isspace(line->buf[5]))\n     + \t\treturn is_format_patch_separator(line->buf + 1, line->len - 1);\n     + \tif (starts_with(line->buf, \"[PATCH]\") && isspace(line->buf[7])) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; header[i]; i++)\n     + \t\t\tif (!strcmp(\"Subject\", header[i])) {\n     + \t\t\t\thandle_header(&mi->s_hdr_data[i], line);\n     +@@ mailinfo.c: static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)\n     + \t\treturn 0; /* mi->input_error already set */\n     + \n     + \tif (mi->use_scissors && is_scissors_line(line->buf)) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tstrbuf_setlen(&mi->log_message, 0);\n     + \t\tmi->header_stage = 1;\n     +@@ mailinfo.c: static void output_header_lines(FILE *fout, const char *hdr, const struct strbuf\n     + static void handle_info(struct mailinfo *mi)\n     + {\n     + \tstruct strbuf *hdr;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; header[i]; i++) {\n     + \t\t/* only print inbody headers if we output a patch file */\n     +\n     + ## merge-ort.c ##\n     +@@ merge-ort.c: static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,\n     + \t\t/* Release and free each strbuf found in output */\n     + \t\tstrmap_for_each_entry(&opti->conflicts, &iter, e) {\n     + \t\t\tstruct string_list *list = e->value;\n     +-\t\t\tfor (int i = 0; i < list->nr; i++) {\n     ++\t\t\tfor (size_t j = 0; j < list->nr; j++) {\n     + \t\t\t\tstruct logical_conflict_info *info =\n     +-\t\t\t\t\tlist->items[i].util;\n     ++\t\t\t\t\tlist->items[j].util;\n     + \t\t\t\tstrvec_clear(&info->paths);\n     + \t\t\t}\n     + \t\t\t/*\n     +@@ merge-ort.c: static void path_msg(struct merge_options *opt,\n     + \tif (other_path_2)\n     + \t\tstrvec_push(&info->paths, other_path_2);\n     + \tif (other_paths)\n     +-\t\tfor (int i = 0; i < other_paths->nr; i++)\n     ++\t\tfor (size_t i = 0; i < other_paths->nr; i++)\n     + \t\tstrvec_push(&info->paths, other_paths->items[i].string);\n     + \n     + \t/* Handle message and its format, in normal case */\n     +@@ merge-ort.c: static void path_msg(struct merge_options *opt,\n     + \n     + \t/* Handle specialized formatting of message under --remerge-diff */\n     + \tif (opt->record_conflict_msgs_as_headers) {\n     +-\t\tint i_sb = 0, i_tmp = 0;\n     ++\t\tsize_t i_sb = 0, i_tmp = 0;\n     + \n     + \t\t/* Start with the specified prefix */\n     + \t\tif (opt->msg_header_prefix)\n     +@@ merge-ort.c: static void setup_path_info(struct merge_options *opt,\n     + \t\toidcpy(&mi->result.oid, &merged_version->oid);\n     + \t\tmi->is_null = !!is_null;\n     + \t} else {\n     +-\t\tint i;\n     ++\t\tunsigned i;\n     + \t\tstruct conflict_info *ci;\n     + \n     + \t\tASSIGN_AND_VERIFY_CI(ci, mi);\n     +@@ merge-ort.c: static int collect_merge_info_callback(int n,\n     + \t\tstruct tree_desc t[3];\n     + \t\tvoid *buf[3] = {NULL, NULL, NULL};\n     + \t\tconst char *original_dir_name;\n     +-\t\tint i, ret, side;\n     ++\t\tunsigned int i, side;\n     ++\t\tint ret;\n     + \n     + \t\t/*\n     + \t\t * Check for whether we can avoid recursing due to one side\n     +@@ merge-ort.c: static int handle_deferred_entries(struct merge_options *opt,\n     + \t\t\t\t\t    0);\n     + \t\tstrintmap_for_each_entry(&copy, &iter, entry) {\n     + \t\t\tconst char *path = entry->key;\n     +-\t\t\tunsigned dir_rename_mask = (intptr_t)entry->value;\n     ++\t\t\tunsigned dir_rename_mask = (uintptr_t)entry->value;\n     + \t\t\tstruct conflict_info *ci;\n     + \t\t\tunsigned dirmask;\n     + \t\t\tstruct tree_desc t[3];\n     + \t\t\tvoid *buf[3] = {NULL,};\n     +-\t\t\tint i;\n     ++\t\t\tunsigned i;\n     + \n     + \t\t\tci = strmap_get(&opt->priv->paths, path);\n     + \t\t\tVERIFY_CI(ci);\n     +@@ merge-ort.c: static int collect_merge_info(struct merge_options *opt,\n     + \n     + /*** Function Grouping: functions related to threeway content merges ***/\n     + \n     +-static int find_first_merges(struct repository *repo,\n     ++static unsigned find_first_merges(struct repository *repo,\n     + \t\t\t     const char *path,\n     + \t\t\t     struct commit *a,\n     + \t\t\t     struct commit *b,\n     + \t\t\t     struct object_array *result)\n     + {\n     +-\tint i, j;\n     ++\tunsigned i, j;\n     + \tstruct object_array merges = OBJECT_ARRAY_INIT;\n     + \tstruct commit *commit;\n     + \tint contains_another;\n     +@@ merge-ort.c: static int merge_submodule(struct merge_options *opt,\n     + \tstruct strbuf sb = STRBUF_INIT;\n     + \tint ret = 0;\n     + \tstruct commit *commit_o, *commit_a, *commit_b;\n     +-\tint parent_count;\n     ++\tunsigned parent_count;\n     + \tstruct object_array merges;\n     + \n     +-\tint i;\n     ++\tunsigned i;\n     + \tint search = !opt->priv->call_depth;\n     + \tint sub_not_initialized = 1;\n     + \tint sub_flag = CONFLICT_SUBMODULE_FAILED_TO_MERGE;\n     +@@ merge-ort.c: static void handle_directory_level_conflicts(struct merge_options *opt)\n     + \tstruct rename_info *renames = &opt->priv->renames;\n     + \tstruct strmap *side1_dir_renames = &renames->dir_renames[MERGE_SIDE1];\n     + \tstruct strmap *side2_dir_renames = &renames->dir_renames[MERGE_SIDE2];\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tstrmap_for_each_entry(side1_dir_renames, &iter, entry) {\n     + \t\tif (strmap_contains(side2_dir_renames, entry->key))\n     +@@ merge-ort.c: static int detect_and_process_renames(struct merge_options *opt,\n     + \tstruct diff_queue_struct combined = { 0 };\n     + \tstruct rename_info *renames = &opt->priv->renames;\n     + \tstruct strmap collisions[3];\n     +-\tint need_dir_renames, s, i, clean = 1;\n     +-\tunsigned detection_run = 0;\n     ++\tint need_dir_renames, s, clean = 1;\n     ++\tunsigned i;\n     ++\tint detection_run = 0;\n     + \n     + \tif (!possible_renames(renames))\n     + \t\tgoto cleanup;\n     +@@ merge-ort.c: static int detect_and_process_renames(struct merge_options *opt,\n     + \t\trenames->redo_after_renames = 0;\n     + \t}\n     + \tif (renames->redo_after_renames && detection_run) {\n     +-\t\tint i, side;\n     ++\t\tint side;\n     + \t\tstruct diff_filepair *p;\n     + \n     + \t\t/* Cache the renames, we found */\n     + \t\tfor (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) {\n     +-\t\t\tfor (i = 0; i < renames->pairs[side].nr; ++i) {\n     +-\t\t\t\tp = renames->pairs[side].queue[i];\n     ++\t\t\tfor (s = 0; s < renames->pairs[side].nr; ++s) {\n     ++\t\t\t\tp = renames->pairs[side].queue[s];\n     + \t\t\t\tpossibly_cache_new_pair(renames, p, side, NULL);\n     + \t\t\t}\n     + \t\t}\n     +@@ merge-ort.c: static int detect_and_process_renames(struct merge_options *opt,\n     + \t\t   renames->pairs[1].nr + renames->pairs[2].nr,\n     + \t\t   combined.alloc);\n     + \tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n     +-\t\tint other_side = 3 - i;\n     ++\t\tunsigned other_side = 3 - i;\n     + \t\tcompute_collisions(&collisions[i],\n     + \t\t\t\t   &renames->dir_renames[other_side],\n     + \t\t\t\t   &renames->pairs[i]);\n     +@@ merge-ort.c: cleanup:\n     + \t * Free now unneeded filepairs, which would have been handled\n     + \t * in collect_renames() normally but we skipped that code.\n     + \t */\n     +-\tfor (s = MERGE_SIDE1; s <= MERGE_SIDE2; s++) {\n     ++\tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n     + \t\tstruct diff_queue_struct *side_pairs;\n     +-\t\tint i;\n     + \n     +-\t\tside_pairs = &renames->pairs[s];\n     +-\t\tfor (i = 0; i < side_pairs->nr; ++i) {\n     +-\t\t\tstruct diff_filepair *p = side_pairs->queue[i];\n     ++\t\tside_pairs = &renames->pairs[i];\n     ++\t\tfor (s = 0; s < side_pairs->nr; ++s) {\n     ++\t\t\tstruct diff_filepair *p = side_pairs->queue[s];\n     + \t\t\tpool_diff_free_filepair(&opt->priv->pool, p);\n     + \t\t}\n     + \t}\n     + \n     + simple_cleanup:\n     + \t/* Free memory for renames->pairs[] and combined */\n     +-\tfor (s = MERGE_SIDE1; s <= MERGE_SIDE2; s++) {\n     +-\t\tfree(renames->pairs[s].queue);\n     +-\t\tDIFF_QUEUE_CLEAR(&renames->pairs[s]);\n     ++\tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n     ++\t\tfree(renames->pairs[i].queue);\n     ++\t\tDIFF_QUEUE_CLEAR(&renames->pairs[i]);\n     + \t}\n     +-\tfor (i = 0; i < combined.nr; i++)\n     +-\t\tpool_diff_free_filepair(&opt->priv->pool, combined.queue[i]);\n     ++\tfor (s = 0; i < combined.nr; s++)\n     ++\t\tpool_diff_free_filepair(&opt->priv->pool, combined.queue[s]);\n     + \tfree(combined.queue);\n     + \n     + \treturn clean;\n     +@@ merge-ort.c: static int tree_entry_order(const void *a_, const void *b_)\n     + \n     + static int write_tree(struct object_id *result_oid,\n     + \t\t      struct string_list *versions,\n     +-\t\t      unsigned int offset,\n     ++\t\t      size_t offset,\n     + \t\t      size_t hash_size)\n     + {\n     + \tsize_t maxlen = 0, extra;\n     +-\tunsigned int nr;\n     ++\tsize_t nr;\n     + \tstruct strbuf buf = STRBUF_INIT;\n     +-\tint i, ret = 0;\n     ++\tsize_t i;\n     ++\tint ret = 0;\n     + \n     + \tassert(offset <= versions->nr);\n     + \tnr = versions->nr - offset;\n     +@@ merge-ort.c: static int write_completed_directory(struct merge_options *opt,\n     + {\n     + \tconst char *prev_dir;\n     + \tstruct merged_info *dir_info = NULL;\n     +-\tunsigned int offset, ret = 0;\n     ++\tsize_t offset;\n     ++\tint ret = 0;\n     + \n     + \t/*\n     + \t * Some explanation of info->versions and info->offsets...\n     +@@ merge-ort.c: static int write_completed_directory(struct merge_options *opt,\n     + \tif (info->last_directory == NULL ||\n     + \t    !strncmp(new_directory_name, info->last_directory,\n     + \t\t     info->last_directory_len)) {\n     +-\t\tuintptr_t offset = info->versions.nr;\n     ++\t\toffset = (uintptr_t)info->versions.nr;\n     + \n     + \t\tinfo->last_directory = new_directory_name;\n     + \t\tinfo->last_directory_len = strlen(info->last_directory);\n     +@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     + \t}\n     + \n     + \tif (ci->df_conflict && ci->merged.result.mode == 0) {\n     +-\t\tint i;\n     ++\t\tunsigned i;\n     + \n     + \t\t/*\n     + \t\t * directory no longer in the way, but we do have a file we\n     +@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     + \t\tstruct conflict_info *new_ci;\n     + \t\tconst char *branch;\n     + \t\tconst char *old_path = path;\n     +-\t\tint i;\n     ++\t\tunsigned i;\n     + \n     + \t\tassert(ci->merged.result.mode == S_IFDIR);\n     + \n     +@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     + \t\t} else {\n     + \t\t\t/* determine the mask of the side that didn't match */\n     + \t\t\tunsigned int othermask = 7 & ~ci->match_mask;\n     +-\t\t\tint side = (othermask == 4) ? 2 : 1;\n     ++\t\t\tunsigned int side = (othermask == 4) ? 2 : 1;\n     + \n     + \t\t\tci->merged.result.mode = ci->stages[side].mode;\n     + \t\t\tci->merged.is_null = !ci->merged.result.mode;\n     +@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     + \t} else if (ci->filemask == 3 || ci->filemask == 5) {\n     + \t\t/* Modify/delete */\n     + \t\tconst char *modify_branch, *delete_branch;\n     +-\t\tint side = (ci->filemask == 5) ? 2 : 1;\n     +-\t\tint index = opt->priv->call_depth ? 0 : side;\n     ++\t\tunsigned side = (ci->filemask == 5) ? 2 : 1;\n     ++\t\tunsigned index = opt->priv->call_depth ? 0 : side;\n     + \n     + \t\tci->merged.result.mode = ci->stages[index].mode;\n     + \t\toidcpy(&ci->merged.result.oid, &ci->stages[index].oid);\n     +@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     + \t\t}\n     + \t} else if (ci->filemask == 2 || ci->filemask == 4) {\n     + \t\t/* Added on one side */\n     +-\t\tint side = (ci->filemask == 4) ? 2 : 1;\n     ++\t\tunsigned side = (ci->filemask == 4) ? 2 : 1;\n     + \t\tci->merged.result.mode = ci->stages[side].mode;\n     + \t\toidcpy(&ci->merged.result.oid, &ci->stages[side].oid);\n     + \t\tci->merged.clean = !ci->df_conflict && !ci->path_conflict;\n     +@@ merge-ort.c: static void prefetch_for_content_merges(struct merge_options *opt,\n     + \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n     + \t\t/* char *path = e->string; */\n     + \t\tstruct conflict_info *ci = e->util;\n     +-\t\tint i;\n     ++\t\tunsigned i;\n     + \n     + \t\t/* Ignore clean entries */\n     + \t\tif (ci->merged.clean)\n     +@@ merge-ort.c: void merge_display_update_messages(struct merge_options *opt,\n     + \tstring_list_sort(&olist);\n     + \n     + \t/* Iterate over the items, printing them */\n     +-\tfor (int path_nr = 0; path_nr < olist.nr; ++path_nr) {\n     ++\tfor (size_t path_nr = 0; path_nr < olist.nr; ++path_nr) {\n     + \t\tstruct string_list *conflicts = olist.items[path_nr].util;\n     +-\t\tfor (int i = 0; i < conflicts->nr; i++) {\n     ++\t\tfor (size_t i = 0; i < conflicts->nr; i++) {\n     + \t\t\tstruct logical_conflict_info *info =\n     + \t\t\t\tconflicts->items[i].util;\n     + \n     + \t\t\tif (detailed) {\n     + \t\t\t\tprintf(\"%lu\", (unsigned long)info->paths.nr);\n     + \t\t\t\tputchar('\\0');\n     +-\t\t\t\tfor (int n = 0; n < info->paths.nr; n++) {\n     ++\t\t\t\tfor (size_t n = 0; n < info->paths.nr; n++) {\n     + \t\t\t\t\tfputs(info->paths.v[n], stdout);\n     + \t\t\t\t\tputchar('\\0');\n     + \t\t\t\t}\n     +@@ merge-ort.c: static struct commit *make_virtual_commit(struct repository *repo,\n     + static void merge_start(struct merge_options *opt, struct merge_result *result)\n     + {\n     + \tstruct rename_info *renames;\n     +-\tint i;\n     ++\tunsigned i;\n     + \tstruct mem_pool *pool = NULL;\n     + \n     + \t/* Sanity checks on opt */\n     +\n       ## merge-recursive.c ##\n     +@@ merge-recursive.c: static struct stage_data *insert_stage_data(struct repository *r,\n     + static struct string_list *get_unmerged(struct index_state *istate)\n     + {\n     + \tstruct string_list *unmerged = xmalloc(sizeof(struct string_list));\n     +-\tint i;\n     ++\tunsigned i;\n     + \n     + \tstring_list_init_dup(unmerged);\n     + \n     +@@ merge-recursive.c: static void record_df_conflict_files(struct merge_options *opt,\n     + \t */\n     + \tstruct string_list df_sorted_entries = STRING_LIST_INIT_NODUP;\n     + \tconst char *last_file = NULL;\n     +-\tint last_len = 0;\n     +-\tint i;\n     ++\tsize_t last_len = 0;\n     ++\tsize_t i;\n     + \n     + \t/*\n     + \t * If we're merging merge-bases, we don't want to bother with\n     +@@ merge-recursive.c: static void record_df_conflict_files(struct merge_options *opt,\n     + \tstring_list_clear(&opt->priv->df_conflict_file_set, 1);\n     + \tfor (i = 0; i < df_sorted_entries.nr; i++) {\n     + \t\tconst char *path = df_sorted_entries.items[i].string;\n     +-\t\tint len = strlen(path);\n     ++\t\tsize_t len = strlen(path);\n     + \t\tstruct stage_data *e = df_sorted_entries.items[i].util;\n     + \n     + \t\t/*\n      @@ merge-recursive.c: static int was_dirty(struct merge_options *opt, const char *path)\n       \n       static int make_room_for_path(struct merge_options *opt, const char *path)\n     @@ merge-recursive.c: static int was_dirty(struct merge_options *opt, const char *p\n       \tconst char *msg = _(\"failed to create path '%s'%s\");\n       \n       \t/* Unlink any D/F conflict files that are in the way */\n     +@@ merge-recursive.c: static int merge_3way(struct merge_options *opt,\n     + \treturn merge_status;\n     + }\n     + \n     +-static int find_first_merges(struct repository *repo,\n     ++static unsigned find_first_merges(struct repository *repo,\n     + \t\t\t     struct object_array *result, const char *path,\n     + \t\t\t     struct commit *a, struct commit *b)\n     + {\n     +-\tint i, j;\n     ++\tunsigned i, j;\n     + \tstruct object_array merges = OBJECT_ARRAY_INIT;\n     + \tstruct commit *commit;\n     + \tint contains_another;\n     +@@ merge-recursive.c: static int merge_submodule(struct merge_options *opt,\n     + \tstruct repository subrepo;\n     + \tint ret = 0;\n     + \tstruct commit *commit_base, *commit_a, *commit_b;\n     +-\tint parent_count;\n     ++\tunsigned parent_count;\n     + \tstruct object_array merges;\n     + \n     +-\tint i;\n     ++\tunsigned i;\n     + \tint search = !opt->priv->call_depth;\n     + \n     + \t/* store a in result in case we fail */\n     +@@ merge-recursive.c: static void get_renamed_dir_portion(const char *old_path, const char *new_path,\n     + static void remove_hashmap_entries(struct hashmap *dir_renames,\n     + \t\t\t\t   struct string_list *items_to_remove)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstruct dir_rename_entry *entry;\n     + \n     + \tfor (i = 0; i < items_to_remove->nr; i++) {\n     +@@ merge-recursive.c: cleanup:\n     + static void final_cleanup_rename(struct string_list *rename)\n     + {\n     + \tconst struct rename *re;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!rename)\n     + \t\treturn;\n      @@ merge-recursive.c: static struct commit *get_ref(struct repository *repo,\n       int merge_recursive_generic(struct merge_options *opt,\n       \t\t\t    const struct object_id *head,\n     @@ merge-recursive.h: int merge_recursive(struct merge_options *opt,\n       \t\t\t    struct commit **result);\n       \n      \n     + ## merge.c ##\n     +@@ merge.c: int try_merge_command(struct repository *r,\n     + \t\t      const char *head_arg, struct commit_list *remotes)\n     + {\n     + \tstruct child_process cmd = CHILD_PROCESS_INIT;\n     +-\tint i, ret;\n     ++\tsize_t i;\n     ++\tint ret;\n     + \tstruct commit_list *j;\n     + \n     + \tstrvec_pushf(&cmd.args, \"merge-%s\", strategy);\n     +@@ merge.c: int checkout_fast_forward(struct repository *r,\n     + \tstruct tree *trees[MAX_UNPACK_TREES];\n     + \tstruct unpack_trees_options opts;\n     + \tstruct tree_desc t[MAX_UNPACK_TREES];\n     +-\tint i, nr_trees = 0;\n     ++\tunsigned int i, nr_trees = 0;\n     + \tstruct lock_file lock_file = LOCK_INIT;\n     + \n     + \trefresh_index(r->index, REFRESH_QUIET, NULL, NULL, NULL);\n     +\n     + ## mergesort.h ##\n     +@@ mergesort.h: scope void name(type **listp,\t\t\t\t\t\t\\\n     + \t\treturn;\t\t\t\t\t\t\t\\\n     + \t\t\t\t\t\t\t\t\t\\\n     + \tfor (;;) {\t\t\t\t\t\t\t\\\n     +-\t\tint i;\t\t\t\t\t\t\t\\\n     ++\t\tsize_t i;\t\t\t\t\t\t\t\\\n     + \t\tsize_t m;\t\t\t\t\t\t\\\n     + \t\ttype *next = name##__get_next(list);\t\t\t\\\n     + \t\tif (next)\t\t\t\t\t\t\\\n     +\n     + ## name-hash.c ##\n     +@@\n     + struct dir_entry {\n     + \tstruct hashmap_entry ent;\n     + \tstruct dir_entry *parent;\n     +-\tint nr;\n     ++\tunsigned int nr;\n     + \tunsigned int namelen;\n     + \tchar name[FLEX_ARRAY];\n     + };\n     +@@ name-hash.c: struct lazy_name_thread_data {\n     + static void *lazy_name_thread_proc(void *_data)\n     + {\n     + \tstruct lazy_name_thread_data *d = _data;\n     +-\tint k;\n     ++\tunsigned int k;\n     + \n     + \tfor (k = 0; k < d->istate->cache_nr; k++) {\n     + \t\tstruct cache_entry *ce_k = d->istate->cache[k];\n     +@@ name-hash.c: static inline void lazy_update_dir_ref_counts(\n     + \tstruct index_state *istate,\n     + \tstruct lazy_entry *lazy_entries)\n     + {\n     +-\tint k;\n     ++\tunsigned int k;\n     + \n     + \tfor (k = 0; k < istate->cache_nr; k++) {\n     + \t\tif (lazy_entries[k].dir)\n     +\n     + ## notes-utils.c ##\n     +@@ notes-utils.c: int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n     + \t\t\t  const struct object_id *from_obj, const struct object_id *to_obj)\n     + {\n     + \tint ret = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; c->trees[i]; i++)\n     + \t\tret = copy_note(c->trees[i], from_obj, to_obj, 1, c->combine) || ret;\n     + \treturn ret;\n     +@@ notes-utils.c: void finish_copy_notes_for_rewrite(struct repository *r,\n     + \t\t\t\t   struct notes_rewrite_cfg *c,\n     + \t\t\t\t   const char *msg)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; c->trees[i]; i++) {\n     + \t\tcommit_notes(r, c->trees[i], msg);\n     + \t\tfree_notes(c->trees[i]);\n     +\n       ## notes.c ##\n      @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       {\n     @@ notes.c: void string_list_add_refs_from_colon_sep(struct string_list *list,\n       \n       \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n       \tstring_list_remove_empty_items(&split, 0);\n     +@@ notes.c: static void format_note(struct notes_tree *t, const struct object_id *object_oid\n     + void format_display_notes(const struct object_id *object_oid,\n     + \t\t\t  struct strbuf *sb, const char *output_encoding, int raw)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tassert(display_notes_trees);\n     + \tfor (i = 0; display_notes_trees[i]; i++)\n     + \t\tformat_note(display_notes_trees[i], object_oid, sb,\n     +\n     + ## object-file.c ##\n     +@@ object-file.c: const char *empty_blob_oid_hex(void)\n     + \treturn oid_to_hex_r(buf, the_hash_algo->empty_blob);\n     + }\n     + \n     +-int hash_algo_by_name(const char *name)\n     ++unsigned hash_algo_by_name(const char *name)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \tif (!name)\n     + \t\treturn GIT_HASH_UNKNOWN;\n     + \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n     +@@ object-file.c: int hash_algo_by_name(const char *name)\n     + \treturn GIT_HASH_UNKNOWN;\n     + }\n     + \n     +-int hash_algo_by_id(uint32_t format_id)\n     ++unsigned hash_algo_by_id(uint32_t format_id)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n     + \t\tif (format_id == hash_algos[i].format_id)\n     + \t\t\treturn i;\n     + \treturn GIT_HASH_UNKNOWN;\n     + }\n     + \n     +-int hash_algo_by_length(int len)\n     ++unsigned hash_algo_by_length(size_t len)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n     + \t\tif (len == hash_algos[i].rawsz)\n     + \t\t\treturn i;\n      \n       ## object-name.c ##\n      @@ object-name.c: static void find_abbrev_len_packed(struct min_abbrev_data *mad)\n     @@ object-name.c: const char *repo_find_unique_abbrev(struct repository *r,\n       \tchar *hex = hexbuffer[bufno];\n       \tbufno = (bufno + 1) % ARRAY_SIZE(hexbuffer);\n      \n     + ## path.c ##\n     +@@ path.c: const char *enter_repo(const char *path, int strict)\n     + \t\t\t\"/.git\", \"\", \".git/.git\", \".git\", NULL,\n     + \t\t};\n     + \t\tconst char *gitfile;\n     +-\t\tint len = strlen(path);\n     +-\t\tint i;\n     ++\t\tsize_t len = strlen(path);\n     ++\t\tsize_t i;\n     + \t\twhile ((1 < len) && (path[len-1] == '/'))\n     + \t\t\tlen--;\n     + \n     +\n     + ## pathspec.c ##\n     +@@ pathspec.c: char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec)\n     + {\n     + \tstruct index_state *istate = the_repository->index;\n     + \tchar *seen = xcalloc(pathspec->nr, 1);\n     +-\tint i;\n     ++\tunsigned i;\n     + \n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     + \t\tstruct cache_entry *ce = istate->cache[i];\n     +@@ pathspec.c: static struct pathspec_magic {\n     + \n     + static void prefix_magic(struct strbuf *sb, int prefixlen, unsigned magic)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tstrbuf_addstr(sb, \":(\");\n     + \tfor (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)\n     + \t\tif (magic & pathspec_magic[i].bit) {\n     +@@ pathspec.c: static const char *parse_long_magic(unsigned *magic, int *prefix_len,\n     + \n     + \tfor (pos = elem + 2; *pos && *pos != ')'; pos = nextat) {\n     + \t\tsize_t len = strcspn_escaped(pos, \",)\");\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tif (pos[len] == ',')\n     + \t\t\tnextat = pos + len + 1; /* handle ',' */\n     +@@ pathspec.c: static const char *parse_short_magic(unsigned *magic, const char *elem)\n     + \n     + \tfor (pos = elem + 1; *pos && *pos != ':'; pos++) {\n     + \t\tchar ch = *pos;\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\t/* Special case alias for '!' */\n     + \t\tif (ch == '^') {\n     +@@ pathspec.c: static void NORETURN unsupported_magic(const char *pattern,\n     + \t\t\t\t       unsigned magic)\n     + {\n     + \tstruct strbuf sb = STRBUF_INIT;\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < ARRAY_SIZE(pathspec_magic); i++) {\n     + \t\tconst struct pathspec_magic *m = pathspec_magic + i;\n     + \t\tif (!(magic & m->bit))\n     +@@ pathspec.c: void parse_pathspec(struct pathspec *pathspec,\n     + {\n     + \tstruct pathspec_item *item;\n     + \tconst char *entry = argv ? *argv : NULL;\n     +-\tint i, n, prefixlen, nr_exclude = 0;\n     ++\tsize_t i, n;\n     ++\tint prefixlen, nr_exclude = 0;\n     + \n     + \tmemset(pathspec, 0, sizeof(*pathspec));\n     + \n     +@@ pathspec.c: void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,\n     + \n     + void copy_pathspec(struct pathspec *dst, const struct pathspec *src)\n     + {\n     +-\tint i, j;\n     ++\tsize_t i, j;\n     + \n     + \t*dst = *src;\n     + \tDUP_ARRAY(dst->items, src->items, dst->nr);\n     +@@ pathspec.c: void copy_pathspec(struct pathspec *dst, const struct pathspec *src)\n     + \n     + void clear_pathspec(struct pathspec *pathspec)\n     + {\n     +-\tint i, j;\n     ++\tsize_t i, j;\n     + \n     + \tfor (i = 0; i < pathspec->nr; i++) {\n     + \t\tfree(pathspec->items[i].match);\n     +@@ pathspec.c: int match_pathspec_attrs(struct index_state *istate,\n     + \t\t\t const char *name, int namelen,\n     + \t\t\t const struct pathspec_item *item)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tchar *to_free = NULL;\n     + \n     + \tif (name[namelen])\n     +@@ pathspec.c: int match_pathspec_attrs(struct index_state *istate,\n     + int pathspec_needs_expanded_index(struct index_state *istate,\n     + \t\t\t\t  const struct pathspec *pathspec)\n     + {\n     +-\tunsigned int i, pos;\n     ++\tsize_t i;\n     ++\tunsigned int pos;\n     + \tint res = 0;\n     + \tchar *skip_worktree_seen = NULL;\n     + \n     +\n     + ## pathspec.h ##\n     +@@ pathspec.h: struct index_state;\n     +  * prepared by parse_pathspec().\n     +  */\n     + struct pathspec {\n     +-\tint nr;\n     ++\tsize_t nr;\n     + \tunsigned int has_wildcard:1;\n     + \tunsigned int recursive:1;\n     + \tunsigned int recurse_submodules:1;\n     +@@ pathspec.h: struct pathspec {\n     + \t\tint len, prefix;\n     + \t\tint nowildcard_len;\n     + \t\tint flags;\n     +-\t\tint attr_match_nr;\n     ++\t\tsize_t attr_match_nr;\n     + \t\tstruct attr_match {\n     + \t\t\tchar *value;\n     + \t\t\tenum attr_match_mode {\n     +\n     + ## pkt-line.c ##\n     +@@ pkt-line.c: static int packet_trace_pack(const char *buf, unsigned int len, int sideband)\n     + \n     + static void packet_trace(const char *buf, unsigned int len, int write)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \tstruct strbuf out;\n     + \tstatic int in_pack, sideband;\n     + \n     +\n     + ## pretty.c ##\n     +@@ pretty.c: static int git_pretty_formats_config(const char *var, const char *value,\n     + \tstruct cmt_fmt_map *commit_format = NULL;\n     + \tconst char *name;\n     + \tconst char *fmt;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (!skip_prefix(var, \"pretty.\", &name))\n     + \t\treturn 0;\n     +@@ pretty.c: static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,\n     + {\n     + \tstruct cmt_fmt_map *found = NULL;\n     + \tsize_t found_match_len = 0;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tif (num_redirections >= commit_formats_len)\n     + \t\tdie(\"invalid --pretty format: \"\n     +@@ pretty.c: static int is_rfc822_special(char ch)\n     + \t}\n     + }\n     + \n     +-static int needs_rfc822_quoting(const char *s, int len)\n     ++static int needs_rfc822_quoting(const char *s, size_t len)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \tfor (i = 0; i < len; i++)\n     + \t\tif (is_rfc822_special(s[i]))\n     + \t\t\treturn 1;\n     +@@ pretty.c: static int last_line_length(struct strbuf *sb)\n     + \treturn sb->len - (i + 1);\n     + }\n     + \n     +-static void add_rfc822_quoted(struct strbuf *out, const char *s, int len)\n     ++static void add_rfc822_quoted(struct strbuf *out, const char *s, size_t len)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \t/* just a guess, we may have to also backslash-quote */\n     + \tstrbuf_grow(out, len + 2);\n     +@@ pretty.c: static int is_rfc2047_special(char ch, enum rfc2047_type type)\n     + \treturn !(isalnum(ch) || ch == '!' || ch == '*' || ch == '+' || ch == '-' || ch == '/');\n     + }\n     + \n     +-static int needs_rfc2047_encoding(const char *line, int len)\n     ++static int needs_rfc2047_encoding(const char *line, size_t len)\n     + {\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < len; i++) {\n     + \t\tint ch = line[i];\n     +@@ pretty.c: struct format_commit_context {\n     + static void parse_commit_header(struct format_commit_context *context)\n     + {\n     + \tconst char *msg = context->message;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; msg[i]; i++) {\n     + \t\tconst char *name;\n     +-\t\tint eol;\n     ++\t\tsize_t eol;\n     + \t\tfor (eol = i; msg[eol] && msg[eol] != '\\n'; eol++)\n     + \t\t\t; /* do nothing */\n     + \n     +@@ pretty.c: void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)\n     + \tsize_t trimlen;\n     + \tsize_t start_len = sb->len;\n     + \tint space = 2;\n     +-\tint i;\n     ++\tsize_t i;\n     + \n     + \tfor (i = 0; i < len; i++) {\n     + \t\tif (istitlechar(msg[i])) {\n     +@@ pretty.c: static size_t parse_describe_args(const char *start, struct strvec *args)\n     + \t\tconst char *argval;\n     + \t\tsize_t arglen = 0;\n     + \t\tint optval = 0;\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \n     + \t\tfor (i = 0; !found && i < ARRAY_SIZE(option); i++) {\n     + \t\t\tswitch (option[i].type) {\n     +@@ pretty.c: void pp_title_line(struct pretty_print_context *pp,\n     + \tstrbuf_addch(sb, '\\n');\n     + \n     + \tif (need_8bit_cte == 0) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; i < pp->in_body_headers.nr; i++) {\n     + \t\t\tif (has_non_ascii(pp->in_body_headers.items[i].string)) {\n     + \t\t\t\tneed_8bit_cte = 1;\n     +@@ pretty.c: void pp_title_line(struct pretty_print_context *pp,\n     + \t}\n     + \n     + \tif (pp->in_body_headers.nr) {\n     +-\t\tint i;\n     ++\t\tsize_t i;\n     + \t\tfor (i = 0; i < pp->in_body_headers.nr; i++) {\n     + \t\t\tstrbuf_addstr(sb, pp->in_body_headers.items[i].string);\n     + \t\t\tfree(pp->in_body_headers.items[i].string);\n     +\n       ## range-diff.c ##\n      @@ range-diff.c: static int read_patches(const char *range, struct string_list *list,\n       \tstruct patch_util *util = NULL;\n     @@ read-cache.c: static void set_index_entry(struct index_state *istate, int nr, st\n       {\n       \tstruct cache_entry *old = istate->cache[nr];\n       \n     -@@ read-cache.c: int ie_modified(struct index_state *istate,\n     - \treturn 0;\n     - }\n     - \n     --int base_name_compare(const char *name1, int len1, int mode1,\n     --\t\t      const char *name2, int len2, int mode2)\n     -+int base_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t      const char *name2, size_t len2, int mode2)\n     - {\n     - \tunsigned char c1, c2;\n     --\tint len = len1 < len2 ? len1 : len2;\n     -+\tsize_t len = len1 < len2 ? len1 : len2;\n     - \tint cmp;\n     - \n     - \tcmp = memcmp(name1, name2, len);\n     -@@ read-cache.c: int base_name_compare(const char *name1, int len1, int mode1,\n     -  * This is used by routines that want to traverse the git namespace\n     -  * but then handle conflicting entries together when possible.\n     -  */\n     --int df_name_compare(const char *name1, int len1, int mode1,\n     --\t\t    const char *name2, int len2, int mode2)\n     -+int df_name_compare(const char *name1, size_t len1, int mode1,\n     -+\t\t    const char *name2, size_t len2, int mode2)\n     - {\n     --\tint len = len1 < len2 ? len1 : len2, cmp;\n     -+\tsize_t len = len1 < len2 ? len1 : len2, cmp;\n     - \tunsigned char c1, c2;\n     - \n     - \tcmp = memcmp(name1, name2, len);\n      @@ read-cache.c: int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n       \treturn 0;\n       }\n     @@ read-cache.c: int refresh_index(struct index_state *istate, unsigned int flags,\n       \tint has_errors = 0;\n       \tint really = (flags & REFRESH_REALLY) != 0;\n       \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n     +@@ read-cache.c: void discard_index(struct index_state *istate)\n     +  */\n     + void validate_cache_entries(const struct index_state *istate)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \n     + \tif (!should_validate_cache_entries() ||!istate || !istate->initialized)\n     + \t\treturn;\n     +@@ read-cache.c: void validate_cache_entries(const struct index_state *istate)\n     + \n     + int unmerged_index(const struct index_state *istate)\n     + {\n     +-\tint i;\n     ++\tunsigned i;\n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     + \t\tif (ce_stage(istate->cache[i]))\n     + \t\t\treturn 1;\n      @@ read-cache.c: static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n       \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n       \n     @@ read-cache.c: static int repo_verify_index(struct repository *repo)\n       \n       \tfor (i = 0; i < entries; i++) {\n       \t\tstruct cache_entry *ce = istate->cache[i];\n     +@@ read-cache.c: out:\n     + int repo_read_index_unmerged(struct repository *repo)\n     + {\n     + \tstruct index_state *istate;\n     +-\tint i;\n     ++\tunsigned i;\n     + \tint unmerged = 0;\n     + \n     + \trepo_read_index(repo);\n      @@ read-cache.c: int repo_read_index_unmerged(struct repository *repo)\n       \tfor (i = 0; i < istate->cache_nr; i++) {\n       \t\tstruct cache_entry *ce = istate->cache[i];\n     @@ read-cache.c: int repo_read_index_unmerged(struct repository *repo)\n       \n       \t\tif (!ce_stage(ce))\n       \t\t\tcontinue;\n     -\n     - ## run-command.c ##\n     -@@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n     - \t\t\t     const struct run_process_parallel_opts *opts,\n     - \t\t\t     int output_timeout)\n     +@@ read-cache.c: static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta\n     + void prefetch_cache_entries(const struct index_state *istate,\n     + \t\t\t    must_prefetch_predicate must_prefetch)\n       {\n      -\tint i;\n     -+\tsize_t i;\n     ++\tunsigned i;\n     + \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n       \n     --\twhile ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {\n     -+\twhile (poll(pp->pfd, opts->processes, output_timeout) < 0) {\n     - \t\tif (errno == EINTR)\n     - \t\t\tcontinue;\n     - \t\tpp_cleanup(pp, opts);\n     -@@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n     - \t}\n     + \tfor (i = 0; i < istate->cache_nr; i++) {\n     +\n     + ## remote-curl.c ##\n     +@@ remote-curl.c: static int set_option(const char *name, const char *value)\n     + \t\toptions.filter = xstrdup(value);\n     + \t\treturn 0;\n     + \t} else if (!strcmp(name, \"object-format\")) {\n     +-\t\tint algo;\n     ++\t\tunsigned algo;\n     + \t\toptions.object_format = 1;\n     + \t\tif (strcmp(value, \"true\")) {\n     + \t\t\talgo = hash_algo_by_name(value);\n     +\n     + ## repository.c ##\n     +@@ repository.c: void repo_set_gitdir(struct repository *repo,\n     + \t\t\trepo->gitdir, \"index\");\n     + }\n       \n     - \t/* Buffer output from all pipes. */\n     --\tfor (size_t i = 0; i < opts->processes; i++) {\n     -+\tfor (i = 0; i < opts->processes; i++) {\n     +-void repo_set_hash_algo(struct repository *repo, int hash_algo)\n     ++void repo_set_hash_algo(struct repository *repo, unsigned hash_algo)\n     + {\n     + \trepo->hash_algo = &hash_algos[hash_algo];\n     + }\n     +\n     + ## repository.h ##\n     +@@ repository.h: struct set_gitdir_args {\n     + void repo_set_gitdir(struct repository *repo, const char *root,\n     + \t\t     const struct set_gitdir_args *extra_args);\n     + void repo_set_worktree(struct repository *repo, const char *path);\n     +-void repo_set_hash_algo(struct repository *repo, int algo);\n     ++void repo_set_hash_algo(struct repository *repo, unsigned algo);\n     + void initialize_the_repository(void);\n     + RESULT_MUST_BE_USED\n     + int repo_init(struct repository *r, const char *gitdir, const char *worktree);\n     +\n     + ## run-command.c ##\n     +@@ run-command.c: static void pp_buffer_stderr(struct parallel_processes *pp,\n     + \tfor (size_t i = 0; i < opts->processes; i++) {\n       \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n       \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n      -\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n     @@ transport-helper.c: static int get_exporter(struct transport *transport,\n       \n       \tchild_process_init(fastexport);\n       \n     +@@ transport-helper.c: static struct ref *get_refs_list_using_list(struct transport *transport,\n     + \t\telse if (buf.buf[0] == ':') {\n     + \t\t\tconst char *value;\n     + \t\t\tif (skip_prefix(buf.buf, \":object-format \", &value)) {\n     +-\t\t\t\tint algo = hash_algo_by_name(value);\n     ++\t\t\t\tunsigned algo = hash_algo_by_name(value);\n     + \t\t\t\tif (algo == GIT_HASH_UNKNOWN)\n     + \t\t\t\t\tdie(_(\"unsupported object format '%s'\"),\n     + \t\t\t\t\t    value);\n      \n       ## transport.c ##\n      @@ transport.c: static int transport_color_config(void)\n\n\n add-interactive.c             | 29 ++++++-----\n add-patch.c                   |  3 +-\n advice.c                      |  4 +-\n apply.c                       | 64 +++++++++++-------------\n apply.h                       |  8 +--\n archive-tar.c                 |  8 +--\n archive.c                     |  2 +-\n attr.c                        | 10 ++--\n base85.c                      | 11 +++--\n bisect.c                      |  8 +--\n blame.c                       | 20 ++++----\n block-sha1/sha1.c             |  2 +-\n bloom.c                       | 10 ++--\n branch.c                      |  4 +-\n builtin/add.c                 |  3 +-\n builtin/clone.c               |  2 +-\n builtin/commit.c              |  2 +-\n builtin/fast-export.c         |  4 +-\n builtin/fast-import.c         |  2 +-\n builtin/fetch-pack.c          |  2 +-\n builtin/fetch.c               |  7 +--\n builtin/for-each-repo.c       |  3 +-\n builtin/fsck.c                |  2 +-\n builtin/gc.c                  | 43 +++++++++-------\n builtin/grep.c                |  5 +-\n builtin/help.c                |  2 +-\n builtin/index-pack.c          |  2 +-\n builtin/init-db.c             | 10 ++--\n builtin/log.c                 |  4 +-\n builtin/ls-files.c            | 24 ++++-----\n builtin/ls-remote.c           |  1 -\n builtin/mailsplit.c           |  2 +-\n builtin/merge-file.c          |  3 +-\n builtin/merge.c               |  3 +-\n builtin/name-rev.c            |  4 +-\n builtin/pack-objects.c        |  4 +-\n builtin/pack-redundant.c      |  6 +--\n builtin/patch-id.c            | 14 +++---\n builtin/pull.c                |  2 +-\n builtin/read-tree.c           |  6 +--\n builtin/rebase.c              |  6 +--\n builtin/receive-pack.c        | 12 +++--\n builtin/remote.c              | 12 +++--\n builtin/repack.c              |  7 +--\n builtin/rerere.c              |  3 +-\n builtin/reset.c               |  2 +-\n builtin/rev-parse.c           |  2 +-\n builtin/rm.c                  | 10 ++--\n builtin/show-branch.c         | 34 ++++++-------\n builtin/show-index.c          |  4 +-\n builtin/sparse-checkout.c     |  7 +--\n builtin/stash.c               |  4 +-\n builtin/submodule--helper.c   |  7 +--\n builtin/unpack-objects.c      |  2 +-\n builtin/update-ref.c          |  4 +-\n builtin/worktree.c            |  7 +--\n bulk-checkin.c                |  4 +-\n bundle.c                      | 15 +++---\n cache-tree.c                  | 10 ++--\n cache.h                       | 16 +++---\n chunk-format.c                |  7 +--\n color.c                       | 34 +++++++------\n color.h                       |  2 +-\n column.c                      |  9 ++--\n combine-diff.c                | 19 ++++---\n commit-graph.c                | 19 +++----\n commit-reach.c                | 11 +++--\n commit.c                      | 10 ++--\n compat/compiler.h             |  9 ++--\n compat/strcasestr.c           | 10 ++--\n compat/unsetenv.c             |  2 +-\n compat/winansi.c              |  7 +--\n config.c                      | 31 +++++++-----\n config.h                      |  2 +-\n connect.c                     | 22 ++++-----\n convert.c                     | 16 +++---\n credential.c                  |  6 +--\n daemon.c                      | 14 +++---\n date.c                        |  4 +-\n decorate.c                    |  6 +--\n delta-islands.c               | 10 ++--\n diagnose.c                    |  2 +-\n diff-lib.c                    |  4 +-\n diff-no-index.c               |  3 +-\n diff.c                        | 35 ++++++-------\n dir.c                         |  3 +-\n dir.h                         |  2 +-\n fetch-pack.c                  |  4 +-\n fsck.c                        |  4 +-\n git.c                         |  2 +-\n hash.h                        |  8 +--\n help.c                        | 10 ++--\n help.h                        |  4 +-\n hex.c                         |  4 +-\n http-backend.c                |  4 +-\n http-push.c                   |  8 +--\n http-walker.c                 |  8 +--\n http.c                        | 16 +++---\n line-log.c                    |  4 +-\n list-objects-filter-options.c |  2 +-\n list-objects.c                |  4 +-\n ll-merge.c                    |  5 +-\n lockfile.c                    |  2 +-\n log-tree.c                    |  2 +-\n ls-refs.c                     |  2 +-\n mailinfo.c                    |  8 +--\n merge-ort.c                   | 93 ++++++++++++++++++-----------------\n merge-recursive.c             | 27 +++++-----\n merge-recursive.h             |  2 +-\n merge.c                       |  5 +-\n mergesort.h                   |  2 +-\n name-hash.c                   |  6 +--\n notes-utils.c                 |  4 +-\n notes.c                       |  4 +-\n object-file.c                 | 12 ++---\n object-name.c                 |  6 +--\n path.c                        |  4 +-\n pathspec.c                    | 22 +++++----\n pathspec.h                    |  4 +-\n pkt-line.c                    |  2 +-\n pretty.c                      | 28 +++++------\n range-diff.c                  | 15 +++---\n read-cache.c                  | 45 +++++++++--------\n remote-curl.c                 |  2 +-\n repository.c                  |  2 +-\n repository.h                  |  2 +-\n run-command.c                 |  5 +-\n shallow.c                     |  2 +-\n shallow.h                     |  2 +-\n strbuf.c                      |  4 +-\n string-list.c                 |  3 +-\n string-list.h                 |  3 +-\n sub-process.c                 |  4 +-\n submodule.c                   | 16 +++---\n submodule.h                   |  2 +-\n trailer.c                     |  2 +-\n transport-helper.c            | 10 ++--\n transport.c                   |  8 +--\n unpack-trees.c                | 16 +++---\n unpack-trees.h                |  2 +-\n wt-status.c                   | 29 +++++------\n xdiff-interface.c             |  6 +--\n 142 files changed, 687 insertions(+), 627 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..5ece4dab996 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -218,7 +218,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n struct list_options {\n \tint columns;\n \tconst char *header;\n-\tvoid (*print_item)(int i, int selected, struct string_list_item *item,\n+\tvoid (*print_item)(size_t i, int selected,\n+\t\t\t   struct string_list_item *item,\n \t\t\t   void *print_item_data);\n \tvoid *print_item_data;\n };\n@@ -226,7 +227,8 @@ struct list_options {\n static void list(struct add_i_state *s, struct string_list *list, int *selected,\n \t\t struct list_options *opts)\n {\n-\tint i, last_lf = 0;\n+\tsize_t i;\n+\tint last_lf = 0;\n \n \tif (!list->nr)\n \t\treturn;\n@@ -469,7 +471,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\n@@ -528,7 +530,7 @@ static int get_modified_files(struct repository *r,\n \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t     &head_oid, NULL);\n \tstruct collection_status s = { 0 };\n-\tint i;\n+\tunsigned int i;\n \n \tdiscard_index(r->index);\n \tif (repo_read_index_preload(r, ps, 0) < 0)\n@@ -617,12 +619,14 @@ struct print_file_item_data {\n \tunsigned only_names:1;\n };\n \n-static void print_file_item(int i, int selected, struct string_list_item *item,\n+static void print_file_item(size_t i, int selected,\n+\t\t\t    struct string_list_item *item,\n \t\t\t    void *print_file_item_data)\n {\n \tstruct file_item *c = item->util;\n \tstruct print_file_item_data *d = print_file_item_data;\n \tconst char *highlighted = NULL;\n+\tunsigned int e = (unsigned int)i + 1;\n \n \tstrbuf_reset(&d->index);\n \tstrbuf_reset(&d->worktree);\n@@ -639,7 +643,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \t}\n \n \tif (d->only_names) {\n-\t\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1,\n+\t\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e,\n \t\t       highlighted ? highlighted : item->string);\n \t\treturn;\n \t}\n@@ -650,7 +654,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \tstrbuf_addf(&d->buf, d->modified_fmt, d->index.buf, d->worktree.buf,\n \t\t    highlighted ? highlighted : item->string);\n \n-\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1, d->buf.buf);\n+\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e, d->buf.buf);\n }\n \n static int run_status(struct add_i_state *s, const struct pathspec *ps,\n@@ -1067,20 +1071,21 @@ struct print_command_item_data {\n \tconst char *color, *reset;\n };\n \n-static void print_command_item(int i, int selected,\n+static void print_command_item(size_t i, int selected,\n \t\t\t       struct string_list_item *item,\n \t\t\t       void *print_command_item_data)\n {\n+\tunsigned int e = (unsigned int)(i + 1);\n \tstruct print_command_item_data *d = print_command_item_data;\n \tstruct command_item *util = item->util;\n \n \tif (!util->prefix_length ||\n \t    !is_valid_prefix(item->string, util->prefix_length))\n-\t\tprintf(\" %2d: %s\", i + 1, item->string);\n+\t\tprintf(\" %2u: %s\", e, item->string);\n \telse\n-\t\tprintf(\" %2d: %s%.*s%s%s\", i + 1,\n-\t\t       d->color, (int)util->prefix_length, item->string,\n-\t\t       d->reset, item->string + util->prefix_length);\n+\t\tprintf(\" %2u: %s%.*s%s%s\", e, d->color,\n+\t\t       (int)util->prefix_length, item->string, d->reset,\n+\t\t       item->string + util->prefix_length);\n }\n \n static void command_prompt_help(struct add_i_state *s)\ndiff --git a/add-patch.c b/add-patch.c\nindex a86a92e1646..be049301bb1 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -377,9 +377,10 @@ static int is_octal(const char *p, size_t len)\n \tif (!len)\n \t\treturn 0;\n \n-\twhile (len--)\n+\tdo {\n \t\tif (*p < '0' || *(p++) > '7')\n \t\t\treturn 0;\n+\t} while (--len);\n \treturn 1;\n }\n \ndiff --git a/advice.c b/advice.c\nindex fd189689437..74ae3020dab 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -138,7 +138,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)\n int git_default_advice_config(const char *var, const char *value)\n {\n \tconst char *k, *slot_name;\n-\tint i;\n+\tsize_t i;\n \n \tif (!strcmp(var, \"color.advice\")) {\n \t\tadvice_use_color = git_config_colorbool(var, value);\n@@ -169,7 +169,7 @@ int git_default_advice_config(const char *var, const char *value)\n \n void list_config_advices(struct string_list *list, const char *prefix)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++)\n \t\tlist_config_item(list, prefix, advice_setting[i].key);\ndiff --git a/apply.c b/apply.c\nindex 5cc5479c9c3..0881bda6f50 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1068,7 +1068,7 @@ static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n \t\t\t\t const char *line,\n \t\t\t\t struct patch *patch)\n {\n-\tunsigned long val = strtoul(line, NULL, 10);\n+\tint val = atoi(line);\n \tif (val <= 100)\n \t\tpatch->score = val;\n \treturn 0;\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -1125,12 +1125,10 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n  * Skip p_value leading components from \"line\"; as we do not accept\n  * absolute paths, return NULL in that case.\n  */\n-static const char *skip_tree_prefix(int p_value,\n-\t\t\t\t    const char *line,\n-\t\t\t\t    int llen)\n+static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n {\n \tint nslash;\n-\tint i;\n+\tsize_t i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n@@ -1152,9 +1150,7 @@ static const char *skip_tree_prefix(int p_value,\n  * creation or deletion of an empty file.  In any of these cases,\n  * both sides are the same name under a/ and b/ respectively.\n  */\n-static char *git_header_name(int p_value,\n-\t\t\t     const char *line,\n-\t\t\t     int llen)\n+static char *git_header_name(int p_value, const char *line, size_t llen)\n {\n \tconst char *name;\n \tconst char *second = NULL;\n@@ -1302,12 +1298,8 @@ static int check_header_line(int linenr, struct patch *patch)\n \treturn 0;\n }\n \n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch)\n {\n \tunsigned long offset;\n@@ -1360,14 +1352,14 @@ int parse_git_diff_header(struct strbuf *root,\n \t\t\t{ \"index \", gitdiff_index },\n \t\t\t{ \"\", gitdiff_unrecognized },\n \t\t};\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tlen = linelen(line, size);\n \t\tif (!len || line[len-1] != '\\n')\n \t\t\tbreak;\n \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n \t\t\tconst struct opentry *p = optable + i;\n-\t\t\tint oplen = strlen(p->str);\n+\t\t\tsize_t oplen = strlen(p->str);\n \t\t\tint res;\n \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n \t\t\t\tcontinue;\n@@ -1391,7 +1383,7 @@ done:\n \t\t\t\t \"%d leading pathname components (line %d)\",\n \t\t\t\t parse_hdr_state.p_value),\n \t\t\t      parse_hdr_state.p_value, *linenr);\n-\t\t\treturn -128;\n+\t\t\treturn -1;\n \t\t}\n \t\tpatch->old_name = xstrdup(patch->def_name);\n \t\tpatch->new_name = xstrdup(patch->def_name);\n@@ -1400,7 +1392,7 @@ done:\n \t    (!patch->old_name && !patch->is_new)) {\n \t\terror(_(\"git diff header lacks filename information \"\n \t\t\t\"(line %d)\"), *linenr);\n-\t\treturn -128;\n+\t\treturn -1;\n \t}\n \tpatch->is_toplevel_relative = 1;\n \treturn offset;\n@@ -1454,22 +1446,23 @@ static int parse_range(const char *line, int len, int offset, const char *expect\n \treturn offset + ex;\n }\n \n-static void recount_diff(const char *line, int size, struct fragment *fragment)\n+static void recount_diff(const char *line, size_t size,\n+\t\t\t struct fragment *fragment)\n {\n \tint oldlines = 0, newlines = 0, ret = 0;\n \n-\tif (size < 1) {\n+\tif (size == 0) {\n \t\twarning(\"recount: ignore empty hunk\");\n \t\treturn;\n \t}\n \n \tfor (;;) {\n-\t\tint len = linelen(line, size);\n-\t\tsize -= len;\n-\t\tline += len;\n+\t\tsize_t len = linelen(line, size);\n \n-\t\tif (size < 1)\n+\t\tif (size <= len)\n \t\t\tbreak;\n+\t\tsize -= len;\n+\t\tline += len;\n \n \t\tswitch (*line) {\n \t\tcase ' ': case '\\n':\n@@ -2086,7 +2079,7 @@ static void add_name_limit(struct apply_state *state,\n static int use_patch(struct apply_state *state, struct patch *p)\n {\n \tconst char *pathname = p->new_name ? p->new_name : p->old_name;\n-\tint i;\n+\tsize_t i;\n \n \t/* Paths outside are not touched regardless of \"--include\" */\n \tif (state->prefix && *state->prefix) {\n@@ -2172,9 +2165,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\n@@ -2384,8 +2377,9 @@ static void update_pre_post_images(struct image *preimage,\n \tif (postlen\n \t    ? postlen < new_buf - postimage->buf\n \t    : postimage->len < new_buf - postimage->buf)\n-\t\tBUG(\"caller miscounted postlen: asked %d, orig = %d, used = %d\",\n-\t\t    (int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));\n+\t\tBUG(\"caller miscounted postlen: asked %u, orig = %u, used = %u\",\n+\t\t    (unsigned int)postlen, (unsigned int)postimage->len,\n+\t\t    (unsigned int)(new_buf - postimage->buf));\n \n \t/* Fix the length of the whole thing */\n \tpostimage->len = new_buf - postimage->buf;\ndiff --git a/apply.h b/apply.h\nindex b9f18ce87d1..7e6b6eb5d2d 100644\n--- a/apply.h\n+++ b/apply.h\n@@ -165,12 +165,8 @@ int check_apply_state(struct apply_state *state, int force_apply);\n  *\n  * Returns -1 on failure, the length of the parsed header otherwise.\n  */\n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch);\n \n void release_patch(struct patch *patch);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/archive.c b/archive.c\nindex 9aeaf2bd87d..2db9b0b56eb 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -275,7 +275,7 @@ int write_archive_entries(struct archiver_args *args,\n \tstruct strbuf path_in_archive = STRBUF_INIT;\n \tstruct strbuf content = STRBUF_INIT;\n \tstruct object_id fake_oid;\n-\tint i;\n+\tsize_t i;\n \n \toidcpy(&fake_oid, null_oid());\n \ndiff --git a/attr.c b/attr.c\nindex 1053dfcd4b6..acdd74775f6 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -180,16 +180,16 @@ static int attr_name_valid(const char *name, size_t namelen)\n \t * Attribute name cannot begin with '-' and must consist of\n \t * characters from [-A-Za-z0-9_.].\n \t */\n-\tif (namelen <= 0 || *name == '-')\n+\tif (namelen == 0 || *name == '-')\n \t\treturn 0;\n-\twhile (namelen--) {\n+\tdo {\n \t\tchar ch = *name++;\n \t\tif (! (ch == '-' || ch == '.' || ch == '_' ||\n \t\t       ('0' <= ch && ch <= '9') ||\n \t\t       ('a' <= ch && ch <= 'z') ||\n \t\t       ('A' <= ch && ch <= 'Z')) )\n \t\t\treturn 0;\n-\t}\n+\t} while (--namelen);\n \treturn 1;\n }\n \n@@ -515,7 +515,7 @@ static void check_vector_add(struct attr_check *c)\n \n static void check_vector_remove(struct attr_check *check)\n {\n-\tint i;\n+\tsize_t i;\n \n \tvector_lock();\n \n@@ -539,7 +539,7 @@ static void check_vector_remove(struct attr_check *check)\n /* Iterate through all attr_check instances and drop their stacks */\n static void drop_all_attr_stacks(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tvector_lock();\n \ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/bisect.c b/bisect.c\nindex ef5ee5a6436..618739689fc 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -218,7 +218,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n \tstruct commit_list *p;\n \tstruct commit_dist *array = xcalloc(nr, sizeof(*array));\n \tstruct strbuf buf = STRBUF_INIT;\n-\tint cnt, i;\n+\tsize_t cnt, i;\n \n \tfor (p = list, cnt = 0; p; p = p->next) {\n \t\tint distance;\n@@ -493,7 +493,7 @@ static void read_bisect_paths(struct strvec *array)\n static char *join_oid_array_hex(struct oid_array *array, char delim)\n {\n \tstruct strbuf joined_hexs = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < array->nr; i++) {\n \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\n@@ -653,7 +653,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,\n \tstruct setup_revision_opt opt = {\n \t\t.free_removed_argv_elements = 1,\n \t};\n-\tint i;\n+\tsize_t i;\n \n \trepo_init_revisions(r, revs, prefix);\n \trevs->abbrev = 0;\n@@ -771,7 +771,7 @@ static struct commit **get_bad_and_good_commits(struct repository *r,\n \t\t\t\t\t\tint *rev_nr)\n {\n \tstruct commit **rev;\n-\tint i, n = 0;\n+\tsize_t i, n = 0;\n \n \tALLOC_ARRAY(rev, 1 + good_revs.nr);\n \trev[n++] = get_commit_reference(r, current_bad_oid);\ndiff --git a/blame.c b/blame.c\nindex 8bfeaa1c63a..b050ba7f893 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -493,7 +493,7 @@ static void get_line_fingerprints(struct fingerprint *fingerprints,\n \t\t\t\t  const char *content, const int *line_starts,\n \t\t\t\t  long first_line, long line_count)\n {\n-\tint i;\n+\tlong i;\n \tconst char *linestart, *lineend;\n \n \tline_starts += first_line;\n@@ -1496,7 +1496,7 @@ static void split_overlap(struct blame_entry *split,\n \t\t\t  struct blame_origin *parent)\n {\n \tint chunk_end_lno;\n-\tint i;\n+\tunsigned int i;\n \tmemset(split, 0, sizeof(struct blame_entry [3]));\n \n \tfor (i = 0; i < 3; i++) {\n@@ -1583,7 +1583,7 @@ static void split_blame(struct blame_entry ***blamed,\n  */\n static void decref_split(struct blame_entry *split)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < 3; i++)\n \t\tblame_origin_decref(split[i].suspect);\n@@ -2001,7 +2001,7 @@ static void copy_split_if_better(struct blame_scoreboard *sb,\n \t\t\t\t struct blame_entry *best_so_far,\n \t\t\t\t struct blame_entry *potential)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tif (!potential[1].suspect)\n \t\treturn;\n@@ -2193,10 +2193,10 @@ struct blame_list {\n  * and prepare a list of entry and the best split.\n  */\n static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n-\t\t\t\t\t   int *num_ents_p)\n+\t\t\t\t\t   size_t *num_ents_p)\n {\n \tstruct blame_entry *e;\n-\tint num_ents, i;\n+\tsize_t num_ents, i;\n \tstruct blame_list *blame_list = NULL;\n \n \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n@@ -2224,9 +2224,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t\tint opt)\n {\n \tstruct diff_options diff_opts;\n-\tint i, j;\n+\tsize_t i, j;\n \tstruct blame_list *blame_list;\n-\tint num_ents;\n+\tsize_t num_ents;\n \tstruct blame_entry *unblamed = target->suspects;\n \tstruct blame_entry *leftover = NULL;\n \n@@ -2645,7 +2645,7 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2708,7 +2708,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 80cebd27564..a08be63bc63 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -214,7 +214,7 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)\n {\n \tstatic const unsigned char pad[64] = { 0x80 };\n \tunsigned int padlen[2];\n-\tint i;\n+\tsize_t i;\n \n \t/* Pad with a binary 1 (ie 0x80), then zeroes, then length */\n \tpadlen[0] = htonl((uint32_t)(ctx->size >> 29));\ndiff --git a/bloom.c b/bloom.c\nindex d0730525da5..d38064e257f 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -73,11 +73,11 @@ uint32_t murmur3_seeded(uint32_t seed, const char *data, size_t len)\n \tconst uint32_t r2 = 13;\n \tconst uint32_t m = 5;\n \tconst uint32_t n = 0xe6546b64;\n-\tint i;\n+\tsize_t i;\n \tuint32_t k1 = 0;\n \tconst char *tail;\n \n-\tint len4 = len / sizeof(uint32_t);\n+\tsize_t len4 = len / sizeof(uint32_t);\n \n \tuint32_t k;\n \tfor (i = 0; i < len4; i++) {\n@@ -127,7 +127,7 @@ void fill_bloom_key(const char *data,\n \t\t    struct bloom_key *key,\n \t\t    const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tconst uint32_t seed0 = 0x293ae76f;\n \tconst uint32_t seed1 = 0x7e646e2c;\n \tconst uint32_t hash0 = murmur3_seeded(seed0, data, len);\n@@ -147,7 +147,7 @@ void add_key_to_filter(const struct bloom_key *key,\n \t\t       struct bloom_filter *filter,\n \t\t       const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tfor (i = 0; i < settings->num_hashes; i++) {\n@@ -310,7 +310,7 @@ int bloom_filter_contains(const struct bloom_filter *filter,\n \t\t\t  const struct bloom_key *key,\n \t\t\t  const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tif (!mod)\ndiff --git a/branch.c b/branch.c\nindex e5614b53b36..f8193de41be 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -375,7 +375,7 @@ static struct strmap current_checked_out_branches = STRMAP_INIT;\n \n static void prepare_checked_out_branches(void)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \tstruct worktree **worktrees;\n \n \tif (initialized_checked_out_branches)\n@@ -836,7 +836,7 @@ int replace_each_worktree_head_symref(const char *oldref, const char *newref,\n {\n \tint ret = 0;\n \tstruct worktree **worktrees = get_worktrees();\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; worktrees[i]; i++) {\n \t\tstruct ref_store *refs;\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 61dd386d109..124ecf1001c 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 65b5b7db6de..b55962692a5 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1298,7 +1298,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (mapped_refs) {\n-\t\tint hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n+\t\tunsigned hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n \n \t\t/*\n \t\t * Now that we know what algorithm the remote side is using,\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 985a0445b78..bcf55081d1e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -292,7 +292,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \n static void add_remove_files(struct string_list *list)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < list->nr; i++) {\n \t\tstruct stat st;\n \t\tstruct string_list_item *p = &(list->items[i]);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 39a890fc005..43da493eb4b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -906,7 +906,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < info->nr; i++) {\n \t\tstruct rev_cmdline_entry *e = info->rev + i;\n@@ -1230,7 +1230,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"the option '%s' requires '%s'\"), \"--anonymize-map\", \"--anonymize\");\n \n \tif (refspecs_list.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tfor (i = 0; i < refspecs_list.nr; i++)\n \t\t\trefspec_append(&refspecs, refspecs_list.items[i].string);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 7134683ab93..068c218ca61 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -860,7 +860,7 @@ static void end_packfile(void)\n \t\tstruct packed_git *new_p;\n \t\tstruct object_id cur_pack_oid;\n \t\tchar *idx_name;\n-\t\tint i;\n+\t\tunsigned long i;\n \t\tstruct branch *b;\n \t\tstruct tag *t;\n \ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex afe679368de..9758d067b73 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -239,7 +239,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \tref = fetch_pack(&args, fd, ref, sought, nr_sought,\n \t\t\t &shallow, pack_lockfiles_ptr, version);\n \tif (pack_lockfiles.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tprintf(\"lock %s\\n\", pack_lockfiles.items[0].string);\n \t\tfflush(stdout);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex a09606b4726..12d7a067d36 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1480,11 +1480,11 @@ static int add_oid(const char *refname UNUSED,\n static void add_negotiation_tips(struct git_transport_options *smart_options)\n {\n \tstruct oid_array *oids = xcalloc(1, sizeof(*oids));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < negotiation_tip.nr; i++) {\n \t\tconst char *s = negotiation_tip.items[i].string;\n-\t\tint old_nr;\n+\t\tsize_t old_nr;\n \t\tif (!has_glob_specials(s)) {\n \t\t\tstruct object_id oid;\n \t\t\tif (get_oid(s, &oid))\n@@ -1939,7 +1939,8 @@ static int fetch_finished(int result, struct strbuf *out,\n \n static int fetch_multiple(struct string_list *list, int max_children)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tstruct strvec argv = STRVEC_INIT;\n \n \tif (!append && write_fetch_head) {\ndiff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c\nindex 6aeac371488..ababcbef101 100644\n--- a/builtin/for-each-repo.c\n+++ b/builtin/for-each-repo.c\n@@ -30,7 +30,8 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)\n int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n {\n \tstatic const char *config_key = NULL;\n-\tint i, result = 0;\n+\tint result = 0;\n+\tsize_t i;\n \tconst struct string_list *values;\n \n \tconst struct option options[] = {\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex d207bd909b4..3b411735a58 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_object(struct object *obj)\n \n static void check_connectivity(void)\n {\n-\tint i, max;\n+\tunsigned int i, max;\n \n \t/* Traverse the pending reachable objects */\n \ttraverse_reachable();\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 02455fdcd73..511419ba417 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -68,7 +68,7 @@ static struct string_list pack_garbage = STRING_LIST_INIT_DUP;\n \n static void clean_pack_garbage(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < pack_garbage.nr; i++)\n \t\tunlink_or_warn(pack_garbage.items[i].string);\n \tstring_list_clear(&pack_garbage, 0);\n@@ -1288,7 +1288,8 @@ static int compare_tasks_by_selection(const void *a_, const void *b_)\n \n static int maintenance_run_tasks(struct maintenance_run_opts *opts)\n {\n-\tint i, found_selected = 0;\n+\tunsigned int i;\n+\tint found_selected = 0;\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n@@ -1367,7 +1368,7 @@ static void initialize_maintenance_strategy(void)\n \n static void initialize_task_config(int schedule)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf config_name = STRBUF_INIT;\n \tgc_config();\n \n@@ -1401,7 +1402,8 @@ static void initialize_task_config(int schedule)\n static int task_option_parse(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n-\tint i, num_selected = 0;\n+\tunsigned int i;\n+\tint num_selected = 0;\n \tstruct maintenance_task *task = NULL;\n \n \tBUG_ON_OPT_NEG(unset);\n@@ -1431,7 +1433,7 @@ static int task_option_parse(const struct option *opt,\n \n static int maintenance_run(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct maintenance_run_opts opts;\n \tstruct option builtin_maintenance_run_options[] = {\n \t\tOPT_BOOL(0, \"auto\", &opts.auto_flag,\n@@ -1810,8 +1812,9 @@ static int launchctl_list_contains_plist(const char *name, const char *cmd)\n \n static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule)\n {\n-\tint i, fd;\n-\tconst char *preamble, *repeat;\n+\tunsigned int i;\n+\tint fd;\n+\tconst char *preamble;\n \tconst char *frequency = get_frequency(schedule);\n \tchar *name = launchctl_service_name(frequency);\n \tchar *filename = launchctl_service_filename(name);\n@@ -1843,22 +1846,24 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n \n \tswitch (schedule) {\n \tcase SCHEDULE_HOURLY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Hour</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 23; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_DAILY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 6; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Day</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_WEEKLY:\n@@ -2553,7 +2558,7 @@ static void validate_scheduler(enum scheduler scheduler)\n static int update_background_schedule(const struct maintenance_start_opts *opts,\n \t\t\t\t      int enable)\n {\n-\tunsigned int i;\n+\tsize_t i;\n \tint result = 0;\n \tstruct lock_file lk;\n \tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex f7821c5fbba..75cc21f632e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -174,7 +174,7 @@ static void work_done(struct work_item *w)\n \n static void free_repos(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < repos_to_free_nr; i++) {\n \t\trepo_clear(repos_to_free[i]);\n@@ -409,7 +409,8 @@ static void run_pager(struct grep_opt *opt, const char *prefix)\n {\n \tstruct string_list *path_list = opt->output_priv;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint i, status;\n+\tsize_t i;\n+\tint status;\n \n \tfor (i = 0; i < path_list->nr; i++)\n \t\tstrvec_push(&child.args, path_list->items[i].string);\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 53f2812dfb1..fd227be20f1 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -124,7 +124,7 @@ static void list_config_help(enum show_config_type type)\n \tstruct string_list keys = STRING_LIST_INIT_DUP;\n \tstruct string_list keys_uniq = STRING_LIST_INIT_DUP;\n \tstruct string_list_item *item;\n-\tint i;\n+\tsize_t i;\n \n \tfor (p = config_name_list; *p; p++) {\n \t\tconst char *var = *p;\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 6648f2daef5..eb383e2fe75 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1726,7 +1726,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tunsigned char pack_hash[GIT_MAX_RAWSZ];\n \tunsigned foreign_nr = 1;\t/* zero is a \"good\" value, assume bad */\n \tint report_end_of_input = 0;\n-\tint hash_algo = 0;\n+\tunsigned hash_algo = 0;\n \n \t/*\n \t * index-pack never needs to fetch missing objects except when\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex dcaaf102eaf..6431c8855f4 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -167,17 +167,17 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n \treturn 1;\n }\n \n-void initialize_repository_version(int hash_algo, int reinit)\n+void initialize_repository_version(unsigned hash_algo, int reinit)\n {\n \tchar repo_version_string[10];\n-\tint repo_version = GIT_REPO_VERSION;\n+\tunsigned repo_version = GIT_REPO_VERSION;\n \n \tif (hash_algo != GIT_HASH_SHA1)\n \t\trepo_version = GIT_REPO_VERSION_READ;\n \n \t/* This forces creation of new config file */\n \txsnprintf(repo_version_string, sizeof(repo_version_string),\n-\t\t  \"%d\", repo_version);\n+\t\t  \"%u\", repo_version);\n \tgit_config_set(\"core.repositoryformatversion\", repo_version_string);\n \n \tif (hash_algo != GIT_HASH_SHA1)\n@@ -374,7 +374,7 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash\n \telse if (hash != GIT_HASH_UNKNOWN)\n \t\trepo_fmt->hash_algo = hash;\n \telse if (env) {\n-\t\tint env_algo = hash_algo_by_name(env);\n+\t\tunsigned env_algo = hash_algo_by_name(env);\n \t\tif (env_algo == GIT_HASH_UNKNOWN)\n \t\t\tdie(_(\"unknown hash algorithm '%s'\"), env);\n \t\trepo_fmt->hash_algo = env_algo;\n@@ -537,7 +537,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tunsigned int flags = 0;\n \tconst char *object_format = NULL;\n \tconst char *initial_branch = NULL;\n-\tint hash_algo = GIT_HASH_UNKNOWN;\n+\tunsigned hash_algo = GIT_HASH_UNKNOWN;\n \tconst struct option init_db_options[] = {\n \t\tOPT_STRING(0, \"template\", &template_dir, N_(\"template-directory\"),\n \t\t\t\tN_(\"directory from which templates will be used\")),\ndiff --git a/builtin/log.c b/builtin/log.c\nindex a70fba198f9..db640058328 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -179,7 +179,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n static void set_default_decoration_filter(struct decoration_filter *decoration_filter)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *value = NULL;\n \tstruct string_list *include = decoration_filter->include_ref_pattern;\n \tconst struct string_list *config_exclude =\n@@ -386,7 +386,7 @@ static struct itimerval early_output_timer;\n \n static void log_show_early(struct rev_info *revs, struct commit_list *list)\n {\n-\tint i = revs->early_output;\n+\tunsigned int i = revs->early_output;\n \tint show_header = 1;\n \tint no_free = revs->diffopt.no_free;\n \ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex a03b559ecaa..c369e95c30e 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -348,7 +348,8 @@ static void show_ru_info(struct index_state *istate)\n \tfor_each_string_list_item(item, istate->resolve_undo) {\n \t\tconst char *path = item->string;\n \t\tstruct resolve_undo_info *ui = item->util;\n-\t\tint i, len;\n+\t\tunsigned int i;\n+\t\tint len;\n \n \t\tlen = strlen(path);\n \t\tif (len < max_prefix_len)\n@@ -359,9 +360,8 @@ static void show_ru_info(struct index_state *istate)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n-\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev),\n-\t\t\t       i + 1);\n+\t\t\tprintf(\"%s%06o %s %u\\t\", tag_resolve_undo, ui->mode[i],\n+\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev), i + 1);\n \t\t\twrite_name(path);\n \t\t}\n \t}\n@@ -385,7 +385,7 @@ static void construct_fullname(struct strbuf *out, const struct repository *repo\n \n static void show_files(struct repository *repo, struct dir_struct *dir)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf fullname = STRBUF_INIT;\n \n \t/* For cached/deleted files we don't need to even do the readdir */\n@@ -449,12 +449,12 @@ static void show_files(struct repository *repo, struct dir_struct *dir)\n \n skip_to_next_name:\n \t\t{\n-\t\t\tint j;\n-\t\t\tstruct cache_entry **cache = repo->index->cache;\n-\t\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n-\t\t\t\tif (strcmp(ce->name, cache[j]->name))\n-\t\t\t\t\tbreak;\n-\t\t\ti = j - 1; /* compensate for the for loop */\n+\t\tunsigned int j;\n+\t\tstruct cache_entry **cache = repo->index->cache;\n+\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n+\t\t\tif (strcmp(ce->name, cache[j]->name))\n+\t\t\t\tbreak;\n+\t\ti = j - 1; /* compensate for the for loop */\n \t\t}\n \t}\n \n@@ -571,7 +571,7 @@ void overlay_tree_on_index(struct index_state *istate,\n \tstruct object_id oid;\n \tstruct pathspec pathspec;\n \tstruct cache_entry *last_stage0 = NULL;\n-\tint i;\n+\tunsigned int i;\n \tread_tree_fn_t fn = NULL;\n \tint err;\n \ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 65161773489..0e72f28b53a 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -87,7 +87,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tpacket_trace_identity(\"ls-remote\");\n \n \tif (argc > 1) {\n-\t\tint i;\n \t\tCALLOC_ARRAY(pattern, argc);\n \t\tfor (i = 1; i < argc; i++) {\n \t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 73509f651bd..053c9eecb30 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -172,7 +172,7 @@ static int split_maildir(const char *maildir, const char *dir,\n \tchar *file = NULL;\n \tFILE *f = NULL;\n \tint ret = -1;\n-\tint i;\n+\tsize_t i;\n \tstruct string_list list = STRING_LIST_INIT_DUP;\n \n \tlist.cmp = maildir_filename_cmp;\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..e4655e8541c 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tsize_t i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 0a3c10a0966..7b42e7440f8 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -186,7 +186,8 @@ static struct strategy *get_strategy(const char *name)\n \t\tmemset(&not_strategies, 0, sizeof(struct cmdnames));\n \t\tload_command_list(\"git-merge-\", &main_cmds, &other_cmds);\n \t\tfor (i = 0; i < main_cmds.cnt; i++) {\n-\t\t\tint j, found = 0;\n+\t\t\tsize_t j;\n+\t\t\tint found = 0;\n \t\t\tstruct cmdname *ent = main_cmds.names[i];\n \t\t\tfor (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)\n \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 97959bfaf9e..c5a9fe74448 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -653,7 +653,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tstrbuf_release(&sb);\n \t} else if (all) {\n-\t\tint i, max;\n+\t\tunsigned int i, max;\n \n \t\tmax = get_max_object_index();\n \t\tfor (i = 0; i < max; i++) {\n@@ -664,7 +664,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t  always, allow_undefined, data.name_only);\n \t\t}\n \t} else {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < revs.nr; i++)\n \t\t\tshow_name(revs.objects[i].item, revs.objects[i].name,\n \t\t\t\t  always, allow_undefined, data.name_only);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 74a167a180c..a939b89cd30 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1511,7 +1511,7 @@ static int want_object_in_pack(const struct object_id *oid,\n \tif (uri_protocols.nr) {\n \t\tstruct configured_exclusion *ex =\n \t\t\toidmap_get(&configured_exclusions, oid);\n-\t\tint i;\n+\t\tsize_t i;\n \t\tconst char *p;\n \n \t\tif (ex) {\n@@ -4084,7 +4084,7 @@ static void add_extra_kept_packs(const struct string_list *names)\n \n \tfor (p = get_all_packs(the_repository); p; p = p->next) {\n \t\tconst char *name = basename(p->pack_name);\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!p->pack_local)\n \t\t\tcontinue;\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex ecd49ca268f..0f6c827faca 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -51,9 +51,9 @@ static inline struct llist_item *llist_item_get(void)\n \t\tnew_item = free_nodes;\n \t\tfree_nodes = free_nodes->next;\n \t} else {\n-\t\tint i = 1;\n+\t\tsize_t i;\n \t\tALLOC_ARRAY(new_item, BLKSIZE);\n-\t\tfor (; i < BLKSIZE; i++)\n+\t\tfor (i = 1; i < BLKSIZE; i++)\n \t\t\tllist_item_put(&new_item[i]);\n \t}\n \treturn new_item;\n@@ -366,7 +366,7 @@ static int cmp_remaining_objects(const void *a, const void *b)\n static void sort_pack_list(struct pack_list **pl)\n {\n \tstruct pack_list **ary, *p;\n-\tint i;\n+\tsize_t i;\n \tsize_t n = pack_list_size(*pl);\n \n \tif (n < 2)\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex f840fbf1c7e..8fed7935e9a 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -10,7 +10,7 @@ static void flush_current_id(int patchlen, struct object_id *id, struct object_i\n \t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n }\n \n-static int remove_space(char *line)\n+static size_t remove_space(char *line)\n {\n \tchar *src = line;\n \tchar *dst = line;\n@@ -57,10 +57,12 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n-\t\t\t   struct strbuf *line_buf, int stable, int verbatim)\n+static size_t get_one_patchid(struct object_id *next_oid,\n+\t\t\t      struct object_id *result, struct strbuf *line_buf,\n+\t\t\t      int stable, int verbatim)\n {\n-\tint patchlen = 0, found_next = 0;\n+\tsize_t patchlen = 0;\n+\tint found_next = 0;\n \tint before = -1, after = -1;\n \tint diff_is_binary = 0;\n \tchar pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];\n@@ -72,7 +74,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n \twhile (strbuf_getwholeline(line_buf, stdin, '\\n') != EOF) {\n \t\tchar *line = line_buf->buf;\n \t\tconst char *p = line;\n-\t\tint len;\n+\t\tsize_t len;\n \n \t\t/* Possibly skip over the prefix added by \"log\" or \"format-patch\" */\n \t\tif (!skip_prefix(line, \"commit \", &p) &&\n@@ -173,7 +175,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n static void generate_id_list(int stable, int verbatim)\n {\n \tstruct object_id oid, n, result;\n-\tint patchlen;\n+\tsize_t patchlen;\n \tstruct strbuf line_buf = STRBUF_INIT;\n \n \toidclr(&oid);\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 1ab4de0005d..115b4bd8819 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -941,7 +941,7 @@ static int get_can_ff(struct object_id *orig_head,\n static int already_up_to_date(struct object_id *orig_head,\n \t\t\t      struct oid_array *merge_heads)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *ours;\n \n \tours = lookup_commit_reference(the_repository, orig_head);\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 3ce75417833..444939c70dc 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -85,13 +85,13 @@ static void debug_stage(const char *label, const struct cache_entry *ce,\n static int debug_merge(const struct cache_entry * const *stages,\n \t\t       struct unpack_trees_options *o)\n {\n-\tint i;\n+\tunsigned int i;\n \n-\tprintf(\"* %d-way merge\\n\", o->merge_size);\n+\tprintf(\"* %u-way merge\\n\", o->merge_size);\n \tdebug_stage(\"index\", stages[0], o);\n \tfor (i = 1; i <= o->merge_size; i++) {\n \t\tchar buf[24];\n-\t\txsnprintf(buf, sizeof(buf), \"ent#%d\", i);\n+\t\txsnprintf(buf, sizeof(buf), \"ent#%u\", i);\n \t\tdebug_stage(buf, stages[i], o);\n \t}\n \treturn 0;\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 6635f10d529..e12edfa84af 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1465,15 +1465,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (strategy_options.nr) {\n-\t\tint i;\n+\t\tsize_t j;\n \n \t\tif (!options.strategy)\n \t\t\toptions.strategy = \"ort\";\n \n \t\tstrbuf_reset(&buf);\n-\t\tfor (i = 0; i < strategy_options.nr; i++)\n+\t\tfor (j = 0; j < strategy_options.nr; j++)\n \t\t\tstrbuf_addf(&buf, \" --%s\",\n-\t\t\t\t    strategy_options.items[i].string);\n+\t\t\t\t    strategy_options.items[j].string);\n \t\toptions.strategy_opts = xstrdup(buf.buf);\n \t}\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex cd5c7a28eff..5ff421061c7 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -536,7 +536,7 @@ static void hmac_hash(unsigned char *out,\n \tunsigned char key[GIT_MAX_BLKSZ];\n \tunsigned char k_ipad[GIT_MAX_BLKSZ];\n \tunsigned char k_opad[GIT_MAX_BLKSZ];\n-\tint i;\n+\tsize_t i;\n \tgit_hash_ctx ctx;\n \n \t/* RFC 2104 2. (1) */\n@@ -1302,7 +1302,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \tstruct oid_array extra = OID_ARRAY_INIT;\n \tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n \tuint32_t mask = 1 << (cmd->index % 32);\n-\tint i;\n+\tsize_t i;\n \n \ttrace_printf_key(&trace_shallow,\n \t\t\t \"shallow: update_shallow_ref %s\\n\", cmd->ref_name);\n@@ -2313,7 +2313,9 @@ static const char *unpack_with_sideband(struct shallow_info *si)\n \n static void prepare_shallow_update(struct shallow_info *si)\n {\n-\tint i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tsize_t i, j, k;\n+\tsize_t bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tint l;\n \n \tALLOC_ARRAY(si->used_shallow, si->shallow->nr);\n \tassign_shallow_commits_to_refs(si, si->used_shallow, NULL);\n@@ -2322,8 +2324,8 @@ static void prepare_shallow_update(struct shallow_info *si)\n \tCALLOC_ARRAY(si->reachable, si->shallow->nr);\n \tCALLOC_ARRAY(si->shallow_ref, si->ref->nr);\n \n-\tfor (i = 0; i < si->nr_ours; i++)\n-\t\tsi->need_reachability_test[si->ours[i]] = 1;\n+\tfor (l = 0; l < si->nr_ours; l++)\n+\t\tsi->need_reachability_test[si->ours[l]] = 1;\n \n \tfor (i = 0; i < si->shallow->nr; i++) {\n \t\tif (!si->used_shallow[i])\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 729f6f3643a..93f8c9a2fad 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -161,7 +161,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tstruct remote *remote;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tconst char *name, *url;\n-\tint i;\n+\tsize_t i;\n \n \tstruct option options[] = {\n \t\tOPT_BOOL('f', \"fetch\", &fetch, N_(\"fetch the remote branches\")),\n@@ -862,7 +862,8 @@ static int rm(int argc, const char **argv, const char *prefix)\n \tstruct string_list branches = STRING_LIST_INIT_DUP;\n \tstruct string_list skipped = STRING_LIST_INIT_DUP;\n \tstruct branches_for_remote cb_data;\n-\tint i, result;\n+\tsize_t i;\n+\tint result;\n \n \tmemset(&cb_data, 0, sizeof(cb_data));\n \tcb_data.branches = &branches;\n@@ -1093,7 +1094,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \tstruct branch_info *branch_info = item->util;\n \tstruct string_list *merge = &branch_info->merge;\n \tint width = show_info->width + 4;\n-\tint i;\n+\tsize_t i;\n \n \tif (branch_info->rebase >= REBASE_TRUE && branch_info->merge.nr > 1) {\n \t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n@@ -1245,7 +1246,7 @@ static int show_all(void)\n \tresult = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tstring_list_sort(&list);\n \t\tfor (i = 0; i < list.nr; i++) {\n@@ -1370,7 +1371,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \n static int set_head(int argc, const char **argv, const char *prefix)\n {\n-\tint i, opt_a = 0, opt_d = 0, result = 0;\n+\tint opt_a = 0, opt_d = 0, result = 0;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tchar *head_name = NULL;\n \n@@ -1394,6 +1395,7 @@ static int set_head(int argc, const char **argv, const char *prefix)\n \t\tif (!states.heads.nr)\n \t\t\tresult |= error(_(\"Cannot determine remote HEAD\"));\n \t\telse if (states.heads.nr > 1) {\n+\t\t\tsize_t i;\n \t\t\tresult |= error(_(\"Multiple remote HEAD branches. \"\n \t\t\t\t\t  \"Please choose one explicitly with:\"));\n \t\t\tfor (i = 0; i < states.heads.nr; i++)\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex f6493795318..7d2031506de 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -109,7 +109,7 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,\n \n \twhile ((e = readdir(dir)) != NULL) {\n \t\tsize_t len;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!strip_suffix(e->d_name, \".pack\", &len))\n \t\t\tcontinue;\n@@ -218,7 +218,7 @@ static struct generated_pack_data *populate_pack_exts(const char *name)\n \tstruct stat statbuf;\n \tstruct strbuf path = STRBUF_INIT;\n \tstruct generated_pack_data *data = xcalloc(1, sizeof(*data));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n \t\tstrbuf_reset(&path);\n@@ -744,7 +744,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)\n \tstruct pack_geometry *geometry = NULL;\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct tempfile *refs_snapshot = NULL;\n-\tint i, ext, ret;\n+\tsize_t i;\n+\tint ext, ret;\n \tFILE *out;\n \tint show_progress;\n \ndiff --git a/builtin/rerere.c b/builtin/rerere.c\nindex 94ffb8c21ab..7a0aeed3323 100644\n--- a/builtin/rerere.c\n+++ b/builtin/rerere.c\n@@ -51,7 +51,8 @@ static int diff_two(const char *file1, const char *label1,\n int cmd_rerere(int argc, const char **argv, const char *prefix)\n {\n \tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n-\tint i, autoupdate = -1, flags = 0;\n+\tsize_t i;\n+\tint autoupdate = -1, flags = 0;\n \n \tstruct option options[] = {\n \t\tOPT_SET_INT(0, \"rerere-autoupdate\", &autoupdate,\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 0697fa89de2..580fbfea217 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -50,7 +50,7 @@ static inline int is_merge(void)\n \n static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)\n {\n-\tint i, nr = 0;\n+\tunsigned int i, nr = 0;\n \tstruct tree_desc desc[2];\n \tstruct tree *tree;\n \tstruct unpack_trees_options opts;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex e67999e5ebc..c235e67a099 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -707,7 +707,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \n \t\tif (!seen_end_of_options) {\n \t\t\tif (!strcmp(arg, \"--local-env-vars\")) {\n-\t\t\t\tint i;\n+\t\t\t\tsize_t i;\n \t\t\t\tfor (i = 0; local_repo_env[i]; i++)\n \t\t\t\t\tprintf(\"%s\\n\", local_repo_env[i]);\n \t\t\t\tcontinue;\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 8844f906557..d70610a3faf 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -49,7 +49,7 @@ static void print_error_files(struct string_list *files_list,\n \t\t\t      int *errs)\n {\n \tif (files_list->nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct strbuf err_msg = STRBUF_INIT;\n \n \t\tstrbuf_addstr(&err_msg, main_msg);\n@@ -258,7 +258,9 @@ static struct option builtin_rm_options[] = {\n int cmd_rm(int argc, const char **argv, const char *prefix)\n {\n \tstruct lock_file lock_file = LOCK_INIT;\n-\tint i, ret = 0;\n+\tint i;\n+\tunsigned int j;\n+\tint ret = 0;\n \tstruct pathspec pathspec;\n \tchar *seen;\n \n@@ -302,8 +304,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \tif (pathspec_needs_expanded_index(&the_index, &pathspec))\n \t\tensure_full_index(&the_index);\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n-\t\tconst struct cache_entry *ce = the_index.cache[i];\n+\tfor (j = 0; j < the_index.cache_nr; j++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[j];\n \n \t\tif (!include_sparse &&\n \t\t    (ce_skip_worktree(ce) ||\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 358ac3e519a..470927ed4d3 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -109,9 +109,9 @@ static void name_parent(struct commit *commit, struct commit *parent)\n \t\t\t    commit_name->generation + 1);\n }\n \n-static int name_first_parent_chain(struct commit *c)\n+static size_t name_first_parent_chain(struct commit *c)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \twhile (c) {\n \t\tstruct commit *p;\n \t\tif (!commit_to_name(c))\n@@ -130,14 +130,12 @@ static int name_first_parent_chain(struct commit *c)\n \treturn i;\n }\n \n-static void name_commits(struct commit_list *list,\n-\t\t\t struct commit **rev,\n-\t\t\t char **ref_name,\n-\t\t\t int num_rev)\n+static void name_commits(struct commit_list *list, struct commit **rev,\n+\t\t\t char **ref_name, size_t num_rev)\n {\n \tstruct commit_list *cl;\n \tstruct commit *c;\n-\tint i;\n+\tsize_t i;\n \n \t/* First give names to the given heads */\n \tfor (cl = list; cl; cl = cl->next) {\n@@ -213,18 +211,17 @@ static int mark_seen(struct commit *commit, struct commit_list **seen_p)\n \treturn 0;\n }\n \n-static void join_revs(struct commit_list **list_p,\n-\t\t      struct commit_list **seen_p,\n-\t\t      int num_rev, int extra)\n+static void join_revs(struct commit_list **list_p, struct commit_list **seen_p,\n+\t\t      size_t num_rev, int extra)\n {\n-\tint all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n-\tint all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n+\tsize_t all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n+\tsize_t all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n \n \twhile (*list_p) {\n \t\tstruct commit_list *parents;\n \t\tint still_interesting = !!interesting(*list_p);\n \t\tstruct commit *commit = pop_commit(list_p);\n-\t\tint flags = commit->object.flags & all_mask;\n+\t\tunsigned int flags = commit->object.flags & all_mask;\n \n \t\tif (!still_interesting && extra <= 0)\n \t\t\tbreak;\n@@ -513,11 +510,10 @@ static int show_merge_base(struct commit_list *seen, int num_rev)\n \treturn exit_status;\n }\n \n-static int show_independent(struct commit **rev,\n-\t\t\t    int num_rev,\n+static int show_independent(struct commit **rev, size_t num_rev,\n \t\t\t    unsigned int *rev_mask)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < num_rev; i++) {\n \t\tstruct commit *commit = rev[i];\n@@ -625,7 +621,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \tchar *reflog_msg[MAX_REVS];\n \tstruct commit_list *list = NULL, *seen = NULL;\n \tunsigned int rev_mask[MAX_REVS];\n-\tint num_rev, i, extra = 0;\n+\tsize_t num_rev, i;\n+\tint extra = 0;\n \tint all_heads = 0, all_remotes = 0;\n \tint all_mask, all_revs;\n \tenum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -789,7 +786,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\t\t\tmsg);\n \t\t\tfree(logmsg);\n \n-\t\t\tnth_desc = xstrfmt(\"%s@{%d}\", *av, base+i);\n+\t\t\tnth_desc = xstrfmt(\"%s@{%lu}\", *av,\n+\t\t\t\t\t   (unsigned long)(base + i));\n \t\t\tappend_ref(nth_desc, &oid, 1);\n \t\t\tfree(nth_desc);\n \t\t}\ndiff --git a/builtin/show-index.c b/builtin/show-index.c\nindex 0e0b9fb95bc..608d0908c98 100644\n--- a/builtin/show-index.c\n+++ b/builtin/show-index.c\n@@ -10,13 +10,13 @@ static const char *const show_index_usage[] = {\n \n int cmd_show_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tunsigned nr;\n \tunsigned int version;\n \tstatic unsigned int top_index[256];\n \tunsigned hashsz;\n \tconst char *hash_name = NULL;\n-\tint hash_algo;\n+\tunsigned hash_algo;\n \tconst struct option show_index_options[] = {\n \t\tOPT_STRING(0, \"object-format\", &hash_name, N_(\"hash-algorithm\"),\n \t\t\t   N_(\"specify the hash algorithm to use\")),\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex c3738154918..89b86d933af 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -78,7 +78,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (pl.use_cone_patterns) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct pattern_entry *pe;\n \t\tstruct hashmap_iter iter;\n \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n@@ -106,7 +106,8 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \n static void clean_tracked_sparse_directories(struct repository *r)\n {\n-\tint i, was_full = 0;\n+\tunsigned int i;\n+\tint was_full = 0;\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t pathlen;\n \tstruct string_list_item *item;\n@@ -264,7 +265,7 @@ static char *escaped_pattern(char *pattern)\n \n static void write_cone_to_file(FILE *fp, struct pattern_list *pl)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct pattern_entry *pe;\n \tstruct hashmap_iter iter;\n \tstruct string_list sl = STRING_LIST_INIT_DUP;\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 3a4f9fd566d..855076a287e 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -853,7 +853,7 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op\n \tstruct tree *tree[ARRAY_SIZE(oid)];\n \tstruct tree_desc tree_desc[ARRAY_SIZE(oid)];\n \tstruct unpack_trees_options unpack_tree_opt = { 0 };\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(oid); i++) {\n \t\ttree[i] = parse_tree_indirect(oid[i]);\n@@ -1521,7 +1521,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \n \trepo_read_index_preload(the_repository, NULL, 0);\n \tif (!include_untracked && ps->nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 4c173d8b37a..664edde6517 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -185,7 +185,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\n@@ -251,7 +252,7 @@ static char *get_up_path(const char *path)\n \tint i;\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tfor (i = count_slashes(path); i; i--)\n+\tfor (i = count_slashes(path); i > 0; i--)\n \t\tstrbuf_addstr(&sb, \"../\");\n \n \t/*\n@@ -3212,7 +3213,7 @@ static void die_on_index_match(const char *path, int force)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (ps.nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps.nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 43789b8ef29..e337ca4129e 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -571,7 +571,7 @@ static void unpack_one(unsigned nr)\n \n static void unpack_all(void)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n \n \tnr_objects = ntohl(hdr->hdr_entries);\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex a84e7b47a20..ded6a67a07f 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -393,7 +393,7 @@ static void update_refs_stdin(void)\n \tstruct strbuf input = STRBUF_INIT, err = STRBUF_INIT;\n \tenum update_refs_state state = UPDATE_REFS_OPEN;\n \tstruct ref_transaction *transaction;\n-\tint i, j;\n+\tsize_t i;\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction)\n@@ -435,7 +435,7 @@ static void update_refs_stdin(void)\n \t\t * error in case there is an early EOF to let the command\n \t\t * handle missing arguments with a proper error message.\n \t\t */\n-\t\tfor (j = 1; line_termination == '\\0' && j < cmd->args; j++)\n+\t\tfor (i = 1; line_termination == '\\0' && i < cmd->args; i++)\n \t\t\tif (strbuf_appendwholeline(&input, stdin, line_termination))\n \t\t\t\tbreak;\n \ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 254283aa6f5..0f05fa7df20 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -160,7 +160,7 @@ static int prune_cmp(const void *a, const void *b)\n \n static void prune_dups(struct string_list *l)\n {\n-\tint i;\n+\tsize_t i;\n \n \tQSORT(l->items, l->nr, prune_cmp);\n \tfor (i = 1; i < l->nr; i++) {\n@@ -785,7 +785,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \n static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; wt[i]; i++) {\n \t\tint sha1_len;\n@@ -925,7 +925,8 @@ static void validate_no_submodules(const struct worktree *wt)\n {\n \tstruct index_state istate = INDEX_STATE_INIT(the_repository);\n \tstruct strbuf path = STRBUF_INIT;\n-\tint i, found_submodules = 0;\n+\tunsigned int i;\n+\tint found_submodules = 0;\n \n \tif (is_directory(worktree_git_path(wt, \"modules\"))) {\n \t\t/*\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 855b68ec23b..6bd0a15b671 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -48,7 +48,7 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n {\n \tunsigned char hash[GIT_MAX_RAWSZ];\n \tstruct strbuf packname = STRBUF_INIT;\n-\tint i;\n+\tuint32_t i;\n \n \tif (!state->f)\n \t\treturn;\n@@ -121,7 +121,7 @@ static void flush_batch_fsync(void)\n \n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n-\tint i;\n+\tuint32_t i;\n \n \t/* The object may already exist in the repository */\n \tif (has_object_file(oid))\ndiff --git a/bundle.c b/bundle.c\nindex 6ab6cd7378d..cc3c820de67 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -41,7 +41,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n {\n \tconst char *arg;\n \tif (skip_prefix(capability, \"object-format=\", &arg)) {\n-\t\tint algo = hash_algo_by_name(arg);\n+\t\tunsigned algo = hash_algo_by_name(arg);\n \t\tif (algo == GIT_HASH_UNKNOWN)\n \t\t\treturn error(_(\"unrecognized bundle hash algorithm: %s\"), arg);\n \t\theader->hash_algo = &hash_algos[algo];\n@@ -56,7 +56,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n \n static int parse_bundle_signature(struct bundle_header *header, const char *line)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n \t\tif (!strcmp(line, bundle_sigs[i].signature)) {\n@@ -163,7 +163,7 @@ int is_bundle(const char *path, int quiet)\n \n static int list_refs(struct string_list *r, int argc, const char **argv)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < r->nr; i++) {\n \t\tstruct object_id *oid;\n@@ -212,7 +212,8 @@ int verify_bundle(struct repository *r,\n \t * to be verbose about the errors\n \t */\n \tstruct string_list *p = &header->prerequisites;\n-\tint i, ret = 0;\n+\tsize_t i;\n+\tint ret = 0;\n \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n \tstruct string_list_iterator iter = {\n \t\t.list = p,\n@@ -316,7 +317,7 @@ out:\n static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n {\n \tstruct child_process pack_objects = CHILD_PROCESS_INIT;\n-\tint i;\n+\tunsigned int i;\n \n \tstrvec_pushl(&pack_objects.args,\n \t\t     \"pack-objects\",\n@@ -370,7 +371,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n  */\n static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n {\n-\tint i;\n+\tunsigned int i;\n \tint ref_count = 0;\n \n \tfor (i = 0; i < revs->pending.nr; i++) {\n@@ -495,7 +496,7 @@ int create_bundle(struct repository *r, const char *path,\n \tstruct rev_info revs, revs_copy;\n \tint min_version = 2;\n \tstruct bundle_prerequisites_info bpi;\n-\tint i;\n+\tunsigned int i;\n \n \t/* init revs to list objects for pack-objects later */\n \tsave_commit_buffer = 0;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 88c2c04f87f..5b03a036fbb 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -694,7 +694,7 @@ struct tree* write_in_core_index_as_tree(struct repository *repo) {\n \n \tret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);\n \tif (ret == WRITE_TREE_UNMERGED_INDEX) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tbug(\"there are unmerged index entries:\");\n \t\tfor (i = 0; i < index_state->cache_nr; i++) {\n \t\t\tconst struct cache_entry *ce = index_state->cache[i];\n@@ -879,7 +879,8 @@ static int verify_one(struct repository *r,\n \t\t      struct cache_tree *it,\n \t\t      struct strbuf *path)\n {\n-\tint i, pos, len = path->len;\n+\tint i, pos;\n+\tsize_t len = path->len;\n \tstruct strbuf tree_buf = STRBUF_INIT;\n \tstruct object_id new_oid;\n \n@@ -952,8 +953,9 @@ static int verify_one(struct repository *r,\n \t\t\t &new_oid);\n \tif (!oideq(&new_oid, &it->oid))\n \t\tBUG(\"cache-tree for path %.*s does not match. \"\n-\t\t    \"Expected %s got %s\", len, path->buf,\n-\t\t    oid_to_hex(&new_oid), oid_to_hex(&it->oid));\n+\t\t    \"Expected %s got %s\",\n+\t\t    (int)len, path->buf, oid_to_hex(&new_oid),\n+\t\t    oid_to_hex(&it->oid));\n \tstrbuf_setlen(path, len);\n \tstrbuf_release(&tree_buf);\n \treturn 0;\ndiff --git a/cache.h b/cache.h\nindex 12789903e88..c46a99448ee 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -649,9 +649,9 @@ int path_inside_repo(const char *prefix, const char *path);\n #define INIT_DB_EXIST_OK 0x0002\n \n int init_db(const char *git_dir, const char *real_git_dir,\n-\t    const char *template_dir, int hash_algo,\n+\t    const char *template_dir, unsigned int hash_algo,\n \t    const char *initial_branch, unsigned int flags);\n-void initialize_repository_version(int hash_algo, int reinit);\n+void initialize_repository_version(unsigned int hash_algo, int reinit);\n \n void sanitize_stdfds(void);\n int daemonize(void);\n@@ -1132,7 +1132,7 @@ struct repository_format {\n \tchar *partial_clone; /* value of extensions.partialclone */\n \tint worktree_config;\n \tint is_bare;\n-\tint hash_algo;\n+\tunsigned hash_algo;\n \tint sparse_index;\n \tchar *work_tree;\n \tstruct string_list unknown_extensions;\n@@ -1212,7 +1212,8 @@ void check_repository_format(struct repository_format *fmt);\n  */\n const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);\n #define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)\n-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);\n+unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n+\t\t\t\t       const struct object_id *oid, int len);\n #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)\n \n /* set default permissions by passing mode arguments to open(2) */\n@@ -1618,7 +1619,8 @@ int base_name_compare(const char *name1, size_t len1, int mode1,\n int df_name_compare(const char *name1, size_t len1, int mode1,\n \t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1828,8 +1830,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/chunk-format.c b/chunk-format.c\nindex 0275b74a895..6981c2afd57 100644\n--- a/chunk-format.c\n+++ b/chunk-format.c\n@@ -58,7 +58,8 @@ void add_chunk(struct chunkfile *cf,\n \n int write_chunkfile(struct chunkfile *cf, void *data)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tuint64_t cur_offset = hashfile_total(cf->f);\n \n \ttrace2_region_enter(\"chunkfile\", \"write\", the_repository);\n@@ -101,7 +102,7 @@ int read_table_of_contents(struct chunkfile *cf,\n \t\t\t   uint64_t toc_offset,\n \t\t\t   int toc_length)\n {\n-\tint i;\n+\tsize_t i;\n \tuint32_t chunk_id;\n \tconst unsigned char *table_of_contents = mfile + toc_offset;\n \n@@ -172,7 +173,7 @@ int read_chunk(struct chunkfile *cf,\n \t       chunk_read_fn fn,\n \t       void *data)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < cf->chunks_nr; i++) {\n \t\tif (cf->chunks[i].id == chunk_id)\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..e3e1d3a04a6 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,15 +73,15 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n-\tint color_offset = COLOR_FOREGROUND_ANSI;\n+\tunsigned int i;\n+\tunsigned int color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n \t\t/*\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -195,7 +195,7 @@ static int parse_attr(const char *name, size_t len)\n #undef ATTR\n \t};\n \tint negate = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (skip_prefix_mem(name, len, \"no\", &name, &len)) {\n \t\tskip_prefix_mem(name, len, \"-\", &name, &len);\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex fbf88639aae..01db21d535c 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\n@@ -240,7 +241,7 @@ static int parse_option(const char *arg, int len, unsigned int *colopts,\n \t\t{ \"row\",    COL_ROW,      COL_LAYOUT_MASK },\n \t\t{ \"dense\",  COL_DENSE,    0 },\n \t};\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(opts); i++) {\n \t\tint set = 1, arg_len = len, name_len;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 1a39b5dde09..ae0073472bb 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -30,8 +30,8 @@ static int filename_changed(char status)\n \n static struct combine_diff_path *intersect_paths(\n \tstruct combine_diff_path *curr,\n-\tint n,\n-\tint num_parent,\n+\tsize_t n,\n+\tsize_t num_parent,\n \tint combined_all_paths)\n {\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n@@ -40,7 +40,7 @@ static struct combine_diff_path *intersect_paths(\n \n \tif (!n) {\n \t\tfor (i = 0; i < q->nr; i++) {\n-\t\t\tint len;\n+\t\t\tsize_t len;\n \t\t\tconst char *path;\n \t\t\tif (diff_unmodified_pair(q->queue[i]))\n \t\t\t\tcontinue;\n@@ -251,7 +251,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \t/* At this point, baseend and newend point to the end of each lists */\n \ti--;\n \tj--;\n-\twhile (i != 0 || j != 0) {\n+\twhile (i > 0 || j > 0) {\n \t\tif (directions[i][j] == MATCH) {\n \t\t\tbaseend->parent_map |= 1<<parent;\n \t\t\tbaseend = baseend->prev;\n@@ -836,14 +836,13 @@ static void dump_sline(struct sline *sline, const char *line_prefix,\n \t\tprintf(\"%s\\n\", c_reset);\n \t\twhile (lno < hunk_end) {\n \t\t\tstruct lline *ll;\n-\t\t\tint j;\n \t\t\tunsigned long p_mask;\n \t\t\tstruct sline *sl = &sline[lno++];\n \t\t\tll = (sl->flag & no_pre_delete) ? NULL : sl->lost;\n \t\t\twhile (ll) {\n \t\t\t\tprintf(\"%s%s\", line_prefix, c_old);\n-\t\t\t\tfor (j = 0; j < num_parent; j++) {\n-\t\t\t\t\tif (ll->parent_map & (1UL<<j))\n+\t\t\t\tfor (i = 0; i < num_parent; i++) {\n+\t\t\t\t\tif (ll->parent_map & (1UL<<i))\n \t\t\t\t\t\tputchar('-');\n \t\t\t\t\telse\n \t\t\t\t\t\tputchar(' ');\n@@ -866,7 +865,7 @@ static void dump_sline(struct sline *sline, const char *line_prefix,\n \t\t\t}\n \t\t\telse\n \t\t\t\tfputs(c_new, stdout);\n-\t\t\tfor (j = 0; j < num_parent; j++) {\n+\t\t\tfor (i = 0; i < num_parent; i++) {\n \t\t\t\tif (p_mask & sl->flag)\n \t\t\t\t\tputchar('+');\n \t\t\t\telse\n@@ -1383,7 +1382,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,\n \tint combined_all_paths)\n {\n \tstruct combine_diff_path *paths = NULL;\n-\tint i, num_parent = parents->nr;\n+\tsize_t i, num_parent = parents->nr;\n \n \tint output_format = opt->output_format;\n \tconst char *orderfile = opt->orderfile;\n@@ -1431,7 +1430,7 @@ static struct combine_diff_path *find_paths_multitree(\n \tconst struct object_id *oid, const struct oid_array *parents,\n \tstruct diff_options *opt)\n {\n-\tint i, nparent = parents->nr;\n+\tsize_t i, nparent = parents->nr;\n \tconst struct object_id **parents_oid;\n \tstruct combine_diff_path paths_head;\n \tstruct strbuf base;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex c11b59f28b3..9683618d3ef 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -501,7 +501,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct stat st;\n \tstruct object_id *oids;\n-\tint i = 0, valid = 1, count;\n+\tint i, valid = 1, count;\n \tchar *chain_name = get_commit_graph_chain_filename(odb);\n \tFILE *fp;\n \tint stat_res;\n@@ -1045,7 +1045,8 @@ static int write_graph_chunk_fanout(struct hashfile *f,\n \t\t\t\t    void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, count = 0;\n+\tunsigned int i;\n+\tuint32_t count = 0;\n \tstruct commit **list = ctx->commits.list;\n \n \t/*\n@@ -1195,7 +1196,7 @@ static int write_graph_chunk_generation_data(struct hashfile *f,\n \t\t\t\t\t     void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, num_generation_data_overflows = 0;\n+\tsize_t i, num_generation_data_overflows = 0;\n \n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n@@ -1219,7 +1220,7 @@ static int write_graph_chunk_generation_data_overflow(struct hashfile *f,\n \t\t\t\t\t\t      void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n \t\ttimestamp_t offset = commit_graph_data_at(c)->generation - c->date;\n@@ -1390,7 +1391,7 @@ static void add_missing_parents(struct write_commit_graph_context *ctx, struct c\n \n static void close_reachable(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *commit;\n \tenum commit_graph_split_flags flags = ctx->opts ?\n \t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n@@ -1448,7 +1449,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n static void compute_topological_levels(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1501,7 +1502,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n \n static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1582,10 +1583,10 @@ static void trace2_bloom_filter_write_statistics(struct write_commit_graph_conte\n \n static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct progress *progress = NULL;\n \tstruct commit **sorted_commits;\n-\tint max_new_filters;\n+\tsize_t max_new_filters;\n \n \tinit_bloom_filters();\n \ndiff --git a/commit-reach.c b/commit-reach.c\nindex 2e33c599a82..9220c5753cf 100644\n--- a/commit-reach.c\n+++ b/commit-reach.c\n@@ -722,7 +722,8 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\t timestamp_t min_generation)\n {\n \tstruct commit **list = NULL;\n-\tint i;\n+\tunsigned int i;\n+\tint j;\n \tint nr_commits;\n \tint result = 1;\n \n@@ -759,12 +760,12 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \n \tQSORT(list, nr_commits, compare_commits_by_gen);\n \n-\tfor (i = 0; i < nr_commits; i++) {\n+\tfor (j = 0; j < nr_commits; j++) {\n \t\t/* DFS from list[i] */\n \t\tstruct commit_list *stack = NULL;\n \n-\t\tlist[i]->object.flags |= assign_flag;\n-\t\tcommit_list_insert(list[i], &stack);\n+\t\tlist[j]->object.flags |= assign_flag;\n+\t\tcommit_list_insert(list[j], &stack);\n \n \t\twhile (stack) {\n \t\t\tstruct commit_list *parent;\n@@ -797,7 +798,7 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\tpop_commit(&stack);\n \t\t}\n \n-\t\tif (!(list[i]->object.flags & (with_flag | RESULT))) {\n+\t\tif (!(list[j]->object.flags & (with_flag | RESULT))) {\n \t\t\tresult = 0;\n \t\t\tgoto cleanup;\n \t\t}\ndiff --git a/commit.c b/commit.c\nindex e433c33bb01..fde358d75ce 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -423,8 +423,8 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b\n \tstruct object_id parent;\n \tstruct commit_list **pptr;\n \tstruct commit_graft *graft;\n-\tconst int tree_entry_len = the_hash_algo->hexsz + 5;\n-\tconst int parent_entry_len = the_hash_algo->hexsz + 7;\n+\tconst size_t tree_entry_len = the_hash_algo->hexsz + 5;\n+\tconst size_t parent_entry_len = the_hash_algo->hexsz + 7;\n \tstruct tree *tree;\n \n \tif (item->object.parsed)\n@@ -1168,10 +1168,10 @@ int remove_signature(struct strbuf *buf)\n \t\tif (in_signature && line[0] == ' ')\n \t\t\tsigp->end = next;\n \t\telse if (starts_with(line, \"gpgsig\")) {\n-\t\t\tint i;\n-\t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n+\t\t\tunsigned int j;\n+\t\t\tfor (j = 1; j < GIT_HASH_NALGOS; j++) {\n \t\t\t\tconst char *p;\n-\t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\n+\t\t\t\tif (skip_prefix(line, gpg_sig_headers[j], &p) &&\n \t\t\t\t    *p == ' ') {\n \t\t\t\t\tsigp->start = line;\n \t\t\t\t\tsigp->end = next;\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/compat/strcasestr.c b/compat/strcasestr.c\nindex 26896deca64..a5e69e06ba7 100644\n--- a/compat/strcasestr.c\n+++ b/compat/strcasestr.c\n@@ -2,16 +2,16 @@\n \n char *gitstrcasestr(const char *haystack, const char *needle)\n {\n-\tint nlen = strlen(needle);\n-\tint hlen = strlen(haystack) - nlen + 1;\n-\tint i;\n+\tsize_t nlen = strlen(needle);\n+\tsize_t hlen = strlen(haystack) - nlen + 1;\n+\tsize_t i;\n \n \tfor (i = 0; i < hlen; i++) {\n-\t\tint j;\n+\t\tsize_t j;\n \t\tfor (j = 0; j < nlen; j++) {\n \t\t\tunsigned char c1 = haystack[i+j];\n \t\t\tunsigned char c2 = needle[j];\n-\t\t\tif (toupper(c1) != toupper(c2))\n+\t\t\tif (tolower(c1) != tolower(c2))\n \t\t\t\tgoto next;\n \t\t}\n \t\treturn (char *) haystack + i;\ndiff --git a/compat/unsetenv.c b/compat/unsetenv.c\nindex b9d34af6136..8a7daff2699 100644\n--- a/compat/unsetenv.c\n+++ b/compat/unsetenv.c\n@@ -5,7 +5,7 @@ int gitunsetenv(const char *name)\n #if !defined(__MINGW32__)\n      extern char **environ;\n #endif\n-     int src, dst;\n+     size_t src, dst;\n      size_t nmln;\n \n      nmln = strlen(name);\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex f83610f684d..5aec44a94e6 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -195,9 +195,9 @@ static void erase_in_line(void)\n \t\t&dummy);\n }\n \n-static void set_attr(char func, const int *params, int paramlen)\n+static void set_attr(char func, const int *params, size_t paramlen)\n {\n-\tint i;\n+\tsize_t i;\n \tswitch (func) {\n \tcase 'm':\n \t\tfor (i = 0; i < paramlen; i++) {\n@@ -344,7 +344,8 @@ static DWORD WINAPI console_thread(LPVOID unused)\n {\n \tunsigned char buffer[BUFFER_SIZE];\n \tDWORD bytes;\n-\tint start, end = 0, c, parampos = 0, state = TEXT;\n+\tint start, end = 0, c, state = TEXT;\n+\tsize_t parampos = 0;\n \tint params[MAX_PARAMS];\n \n \twhile (1) {\ndiff --git a/config.c b/config.c\nindex 00090a32fc3..7e7efb5cbbc 100644\n--- a/config.c\n+++ b/config.c\n@@ -721,7 +721,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \tif (env) {\n \t\tunsigned long count;\n \t\tchar *endp;\n-\t\tint i;\n+\t\tunsigned long i;\n \n \t\tcount = strtoul(env, &endp, 10);\n \t\tif (*endp) {\n@@ -736,7 +736,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\tfor (i = 0; i < count; i++) {\n \t\t\tconst char *key, *value;\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%lu\", i);\n \t\t\tkey = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!key) {\n \t\t\t\tret = error(_(\"missing config key %s\"), envvar.buf);\n@@ -744,7 +744,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\t\t}\n \t\t\tstrbuf_reset(&envvar);\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%lu\", i);\n \t\t\tvalue = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!value) {\n \t\t\t\tret = error(_(\"missing config value %s\"), envvar.buf);\n@@ -1372,7 +1372,7 @@ static enum fsync_component parse_fsync_components(const char *var, const char *\n \tenum fsync_component positive = 0, negative = 0;\n \n \twhile (string) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tsize_t len;\n \t\tconst char *ep;\n \t\tint negated = 0;\n@@ -2221,7 +2221,8 @@ int config_with_options(config_fn_t fn, void *data,\n \n static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)\n {\n-\tint i, value_index;\n+\tunsigned int i;\n+\tsize_t value_index;\n \tstruct string_list *values;\n \tstruct config_set_element *entry;\n \tstruct configset_list *list = &cs->list;\n@@ -3008,7 +3009,7 @@ static ssize_t write_section(int fd, const char *key,\n static ssize_t write_pair(int fd, const char *key, const char *value,\n \t\t\t  const struct config_store_data *store)\n {\n-\tint i;\n+\tsize_t i;\n \tssize_t ret;\n \tconst char *quote = \"\";\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -3065,17 +3066,19 @@ static ssize_t write_pair(int fd, const char *key, const char *value,\n  */\n static void maybe_remove_section(struct config_store_data *store,\n \t\t\t\t size_t *begin_offset, size_t *end_offset,\n-\t\t\t\t int *seen_ptr)\n+\t\t\t\t unsigned int *seen_ptr)\n {\n \tsize_t begin;\n-\tint i, seen, section_seen = 0;\n+\tunsigned int i;\n+\tunsigned int seen;\n+\tint section_seen = 0;\n \n \t/*\n \t * First, ensure that this is the first key, and that there are no\n \t * comments before the entry nor before the section header.\n \t */\n \tseen = *seen_ptr;\n-\tfor (i = store->seen[seen]; i > 0; i--) {\n+\tfor (i = store->seen[seen]; i; i--) {\n \t\tenum config_event_t type = store->parsed[i - 1].type;\n \n \t\tif (type == CONFIG_EVENT_COMMENT)\n@@ -3257,7 +3260,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t} else {\n \t\tstruct stat st;\n \t\tsize_t copy_begin, copy_end;\n-\t\tint i, new_line = 0;\n+\t\tunsigned int i;\n+\t\tint new_line = 0;\n \t\tstruct config_options opts;\n \n \t\tif (!value_pattern)\n@@ -3352,7 +3356,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \n \t\tfor (i = 0, copy_begin = 0; i < store.seen_nr; i++) {\n \t\t\tsize_t replace_end;\n-\t\t\tint j = store.seen[i];\n+\t\t\tunsigned int j = store.seen[i];\n \n \t\t\tnew_line = 0;\n \t\t\tif (!store.key_seen) {\n@@ -3487,9 +3491,10 @@ void git_config_set_multivar(const char *key, const char *value,\n \t\t\t\t\tflags);\n }\n \n-static int section_name_match (const char *buf, const char *name)\n+static unsigned int section_name_match(const char *buf, const char *name)\n {\n-\tint i = 0, j = 0, dot = 0;\n+\tunsigned int i = 0, j = 0;\n+\tint dot = 0;\n \tif (buf[i] != '[')\n \t\treturn 0;\n \tfor (i = 1; buf[i] && buf[i] != ']'; i++) {\ndiff --git a/config.h b/config.h\nindex 7606246531a..d420035f5cb 100644\n--- a/config.h\n+++ b/config.h\n@@ -413,7 +413,7 @@ struct config_set_element {\n \n struct configset_list_item {\n \tstruct config_set_element *e;\n-\tint value_index;\n+\tsize_t value_index;\n };\n \n /*\ndiff --git a/connect.c b/connect.c\nindex 63e59641c0d..858fa2f891c 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -238,7 +238,7 @@ static void process_capabilities(struct packet_reader *reader, int *linelen)\n \tfeat_val = server_feature_value(\"object-format\", &feat_len);\n \tif (feat_val) {\n \t\tchar *hash_name = xstrndup(feat_val, feat_len);\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo != GIT_HASH_UNKNOWN)\n \t\t\treader->hash_algo = &hash_algos[hash_algo];\n \t\tfree(hash_name);\n@@ -385,7 +385,7 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t\t  const char **unborn_head_target)\n {\n \tint ret = 1;\n-\tint i = 0;\n+\tsize_t i;\n \tstruct object_id old_oid;\n \tstruct ref *ref;\n \tstruct string_list line_sections = STRING_LIST_INIT_DUP;\n@@ -403,15 +403,14 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\tgoto out;\n \t}\n \n-\tif (!strcmp(\"unborn\", line_sections.items[i].string)) {\n-\t\ti++;\n+\tif (!strcmp(\"unborn\", line_sections.items[0].string)) {\n \t\tif (unborn_head_target &&\n-\t\t    !strcmp(\"HEAD\", line_sections.items[i++].string)) {\n+\t\t    !strcmp(\"HEAD\", line_sections.items[1].string)) {\n \t\t\t/*\n \t\t\t * Look for the symref target (if any). If found,\n \t\t\t * return it to the caller.\n \t\t\t */\n-\t\t\tfor (; i < line_sections.nr; i++) {\n+\t\t\tfor (i = 2; i < line_sections.nr; i++) {\n \t\t\t\tconst char *arg = line_sections.items[i].string;\n \n \t\t\t\tif (skip_prefix(arg, \"symref-target:\", &arg)) {\n@@ -422,19 +421,20 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t}\n \t\tgoto out;\n \t}\n-\tif (parse_oid_hex_algop(line_sections.items[i++].string, &old_oid, &end, reader->hash_algo) ||\n+\tif (parse_oid_hex_algop(line_sections.items[0].string, &old_oid, &end,\n+\t\t\t\treader->hash_algo) ||\n \t    *end) {\n \t\tret = 0;\n \t\tgoto out;\n \t}\n \n-\tref = alloc_ref(line_sections.items[i++].string);\n+\tref = alloc_ref(line_sections.items[1].string);\n \n \tmemcpy(ref->old_oid.hash, old_oid.hash, reader->hash_algo->rawsz);\n \t**list = ref;\n \t*list = &ref->next;\n \n-\tfor (; i < line_sections.nr; i++) {\n+\tfor (i = 2; i < line_sections.nr; i++) {\n \t\tconst char *arg = line_sections.items[i].string;\n \t\tif (skip_prefix(arg, \"symref-target:\", &arg))\n \t\t\tref->symref = xstrdup(arg);\n@@ -484,7 +484,7 @@ static void send_capabilities(int fd_out, struct packet_reader *reader)\n \t\tpacket_write_fmt(fd_out, \"agent=%s\", git_user_agent_sanitized());\n \n \tif (server_feature_v2(\"object-format\", &hash_name)) {\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo == GIT_HASH_UNKNOWN)\n \t\t\tdie(_(\"unknown object format '%s' specified by server\"), hash_name);\n \t\treader->hash_algo = &hash_algos[hash_algo];\n@@ -543,7 +543,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,\n \t\t\t     const struct string_list *server_options,\n \t\t\t     int stateless_rpc)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct strvec *ref_prefixes = transport_options ?\n \t\t&transport_options->ref_prefixes : NULL;\n \tconst char **unborn_head_target = transport_options ?\ndiff --git a/convert.c b/convert.c\nindex a54d1690c08..8820b1301e0 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -313,17 +313,15 @@ static void trace_encoding(const char *context, const char *path,\n {\n \tstatic struct trace_key coe = TRACE_KEY_INIT(WORKING_TREE_ENCODING);\n \tstruct strbuf trace = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tstrbuf_addf(&trace, \"%s (%s, considered %s):\\n\", context, path, encoding);\n \tfor (i = 0; i < len && buf; ++i) {\n-\t\tstrbuf_addf(\n-\t\t\t&trace, \"| \\033[2m%2i:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n-\t\t\ti,\n-\t\t\t(unsigned char) buf[i],\n-\t\t\t(buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n-\t\t\t((i+1) % 8 && (i+1) < len ? ' ' : '\\n')\n-\t\t);\n+\t\tstrbuf_addf(&trace,\n+\t\t\t    \"| \\033[2m%2u:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n+\t\t\t    (unsigned int)i, (unsigned char)buf[i],\n+\t\t\t    (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n+\t\t\t    ((i + 1) % 8 && (i + 1) < len ? ' ' : '\\n'));\n \t}\n \tstrbuf_addchars(&trace, '\\n', 1);\n \n@@ -1815,7 +1813,7 @@ struct ident_filter {\n \n static int is_foreign_ident(const char *str)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(str, \"$Id: \", &str))\n \t\treturn 0;\ndiff --git a/credential.c b/credential.c\nindex f32011343f9..e25ebbc52e9 100644\n--- a/credential.c\n+++ b/credential.c\n@@ -344,7 +344,7 @@ static int credential_do(struct credential *c, const char *helper,\n \n void credential_fill(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->username && c->password)\n \t\treturn;\n@@ -373,7 +373,7 @@ void credential_fill(struct credential *c)\n \n void credential_approve(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->approved)\n \t\treturn;\n@@ -389,7 +389,7 @@ void credential_approve(struct credential *c)\n \n void credential_reject(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tcredential_apply_config(c);\n \ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..aa5ee229bd1 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1122,7 +1123,8 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s\n \tif (!listen_addr->nr)\n \t\tsetup_named_sock(NULL, listen_port, socklist);\n \telse {\n-\t\tint i, socknum;\n+\t\tsize_t i;\n+\t\tint socknum;\n \t\tfor (i = 0; i < listen_addr->nr; i++) {\n \t\t\tsocknum = setup_named_sock(listen_addr->items[i].string,\n \t\t\t\t\t\t   listen_port, socklist);\n@@ -1149,7 +1151,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/date.c b/date.c\nindex 6f45eeb3568..fd4b686b7e0 100644\n--- a/date.c\n+++ b/date.c\n@@ -421,12 +421,12 @@ static const struct {\n \n static int match_string(const char *date, const char *str)\n {\n-\tint i = 0;\n+\tint i;\n \n \tfor (i = 0; *date; date++, str++, i++) {\n \t\tif (*date == *str)\n \t\t\tcontinue;\n-\t\tif (toupper(*date) == toupper(*str))\n+\t\tif (tolower(*date) == tolower(*str))\n \t\t\tcontinue;\n \t\tif (!isalnum(*date))\n \t\t\tbreak;\ndiff --git a/decorate.c b/decorate.c\nindex 2036d159671..5654dd435d2 100644\n--- a/decorate.c\n+++ b/decorate.c\n@@ -34,8 +34,8 @@ static void *insert_decoration(struct decoration *n, const struct object *base,\n \n static void grow_decoration(struct decoration *n)\n {\n-\tint i;\n-\tint old_size = n->size;\n+\tunsigned int i;\n+\tunsigned int old_size = n->size;\n \tstruct decoration_entry *old_entries = n->entries;\n \n \tn->size = (old_size + 1000) * 3 / 2;\n@@ -56,7 +56,7 @@ static void grow_decoration(struct decoration *n)\n void *add_decoration(struct decoration *n, const struct object *obj,\n \t\tvoid *decoration)\n {\n-\tint nr = n->nr + 1;\n+\tunsigned int nr = n->nr + 1;\n \n \tif (nr > n->size * 2 / 3)\n \t\tgrow_decoration(n);\ndiff --git a/delta-islands.c b/delta-islands.c\nindex afdec0a878d..d4a7bce70ab 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -243,8 +243,8 @@ void resolve_tree_islands(struct repository *r,\n {\n \tstruct progress *progress_state = NULL;\n \tstruct tree_islands_todo *todo;\n-\tint nr = 0;\n-\tint i;\n+\tuint32_t nr = 0;\n+\tuint32_t i;\n \n \tif (!island_marks)\n \t\treturn;\n@@ -320,7 +320,8 @@ static const char *core_island_name;\n \n static void free_config_regexes(struct island_load_data *ild)\n {\n-\tfor (size_t i = 0; i < ild->nr; i++)\n+\tsize_t i;\n+\tfor (i = 0; i < ild->nr; i++)\n \t\tregfree(&ild->rx[i]);\n \tfree(ild->rx);\n }\n@@ -400,7 +401,8 @@ static int find_island_for_ref(const char *refname, const struct object_id *oid,\n \t * than we support.\n \t */\n \tregmatch_t matches[16];\n-\tint i, m;\n+\tint i;\n+\tsize_t m;\n \tstruct strbuf island_name = STRBUF_INIT;\n \n \t/* walk backwards to get last-one-wins ordering */\ndiff --git a/diagnose.c b/diagnose.c\nindex 8f265698966..9206c271663 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -25,7 +25,7 @@ static struct diagnose_option diagnose_options[] = {\n \n int option_parse_diagnose(const struct option *opt, const char *arg, int unset)\n {\n-\tint i;\n+\tsize_t i;\n \tenum diagnose_mode *diagnose = opt->value;\n \n \tif (!arg) {\ndiff --git a/diff-lib.c b/diff-lib.c\nindex dec040c366c..03088f668b1 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -90,7 +90,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \n int run_diff_files(struct rev_info *revs, unsigned int option)\n {\n-\tint entries, i;\n+\tunsigned int entries, i;\n \tint diff_unmerged_stage = revs->max_count;\n \tunsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)\n \t\t\t      ? CE_MATCH_RACY_IS_DIRTY : 0);\n@@ -556,7 +556,7 @@ static int diff_cache(struct rev_info *revs,\n \n void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *mb_child[2] = {0};\n \tstruct commit_list *merge_bases;\n \ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 05fafd0019b..2019db4a350 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -242,7 +242,8 @@ int diff_no_index(struct rev_info *revs,\n \t\t  int implicit_no_index,\n \t\t  int argc, const char **argv)\n {\n-\tint i, no_index;\n+\tunsigned int i;\n+\tint no_index;\n \tint ret = 1;\n \tconst char *paths[2];\n \tchar *to_free[ARRAY_SIZE(paths)] = { 0 };\ndiff --git a/diff.c b/diff.c\nindex 469e18aed20..62422361bb5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,7 +124,7 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tchar *params_copy = xstrdup(params_string);\n \tstruct string_list params = STRING_LIST_INIT_NODUP;\n \tint ret = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (*params_copy)\n \t\tstring_list_split_in_place(&params, params_copy, ',', -1);\n@@ -1678,7 +1678,7 @@ static void emit_hunk_header(struct emit_callback *ecbdata,\n \n static struct diff_tempfile *claim_diff_tempfile(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++)\n \t\tif (!diff_temp[i].name)\n \t\t\treturn diff_temp + i;\n@@ -1687,7 +1687,7 @@ static struct diff_tempfile *claim_diff_tempfile(void)\n \n static void remove_tempfile(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++) {\n \t\tif (is_tempfile_active(diff_temp[i].tempfile))\n \t\t\tdelete_tempfile(&diff_temp[i].tempfile);\n@@ -2006,7 +2006,7 @@ static void fn_out_diff_words_aux(void *priv,\n \n /* This function starts looking at *begin, and returns 0 iff a word was found. */\n static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n-\t\tint *begin, int *end)\n+\t\t\t\tlong *begin, long *end)\n {\n \twhile (word_regex && *begin < buffer->size) {\n \t\tregmatch_t match[1];\n@@ -2047,7 +2047,7 @@ static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n static void diff_words_fill(struct diff_words_buffer *buffer, mmfile_t *out,\n \t\tregex_t *word_regex)\n {\n-\tint i, j;\n+\tlong i, j;\n \tlong alloc = 0;\n \n \tout->size = 0;\n@@ -2188,7 +2188,7 @@ static void init_diff_words_data(struct emit_callback *ecbdata,\n \t\t\t\t struct diff_filespec *one,\n \t\t\t\t struct diff_filespec *two)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct diff_options *o = xmalloc(sizeof(struct diff_options));\n \tmemcpy(o, orig_opts, sizeof(struct diff_options));\n \n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\n@@ -3415,7 +3415,7 @@ static void add_formatted_headers(struct strbuf *msg,\n \t\t\t\t  const char *meta,\n \t\t\t\t  const char *reset)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < more_headers->nr; i++)\n \t\tadd_formatted_header(msg, more_headers->items[i].string,\n@@ -4702,7 +4702,7 @@ static unsigned int filter_bit['Z' + 1];\n \n static void prepare_filter_bits(void)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tif (!filter_bit[DIFF_STATUS_ADDED]) {\n \t\tfor (i = 0; diff_status_letters[i]; i++)\n@@ -4933,7 +4933,8 @@ static int diff_opt_diff_filter(const struct option *option,\n \t\t\t\tconst char *optarg, int unset)\n {\n \tstruct diff_options *opt = option->value;\n-\tint i, optch;\n+\tsize_t i;\n+\tint optch;\n \n \tBUG_ON_OPT_NEG(unset);\n \tprepare_filter_bits();\n@@ -5287,7 +5288,7 @@ static int diff_opt_patience(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n \tstruct diff_options *options = opt->value;\n-\tint i;\n+\tsize_t i;\n \n \tBUG_ON_OPT_NEG(unset);\n \tBUG_ON_OPT_ARG(arg);\n@@ -6213,12 +6214,12 @@ static void diff_summary(struct diff_options *opt, struct diff_filepair *p)\n \n struct patch_id_t {\n \tgit_hash_ctx *ctx;\n-\tint patchlen;\n+\tsize_t patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, unsigned long len)\n {\n-\tint i;\n+\tunsigned long i;\n \tchar *dst = line;\n \tunsigned char c;\n \n@@ -6248,7 +6249,7 @@ void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)\n static int patch_id_consume(void *priv, char *line, unsigned long len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \tif (len > 12 && starts_with(line, \"\\\\ \"))\n \t\treturn 0;\n@@ -6290,7 +6291,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid\n \t\txdemitconf_t xecfg;\n \t\tmmfile_t mf1, mf2;\n \t\tstruct diff_filepair *p = q->queue[i];\n-\t\tint len1, len2;\n+\t\tsize_t len1, len2;\n \n \t\tmemset(&xpp, 0, sizeof(xpp));\n \t\tmemset(&xecfg, 0, sizeof(xecfg));\ndiff --git a/dir.c b/dir.c\nindex 4e99f0c868f..e9fd064a433 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -2988,7 +2988,8 @@ static void emit_traversal_statistics(struct dir_struct *dir,\n }\n \n int read_directory(struct dir_struct *dir, struct index_state *istate,\n-\t\t   const char *path, int len, const struct pathspec *pathspec)\n+\t\t   const char *path, unsigned int len,\n+\t\t   const struct pathspec *pathspec)\n {\n \tstruct untracked_cache_dir *untracked;\n \ndiff --git a/dir.h b/dir.h\nindex 8acfc044181..73cdff47c9e 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -374,7 +374,7 @@ int fill_directory(struct dir_struct *dir,\n \t\t   struct index_state *istate,\n \t\t   const struct pathspec *pathspec);\n int read_directory(struct dir_struct *, struct index_state *istate,\n-\t\t   const char *path, int len,\n+\t\t   const char *path, unsigned int len,\n \t\t   const struct pathspec *pathspec);\n \n enum pattern_match_result {\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 04016d1e325..83a92df7055 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -1324,7 +1324,7 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n \tif (advertise_sid && server_supports_v2(\"session-id\"))\n \t\tpacket_buf_write(req_buf, \"session-id=%s\", trace2_session_id());\n \tif (server_options && server_options->nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tensure_server_supports_v2(\"server-option\");\n \t\tfor (i = 0; i < server_options->nr; i++)\n \t\t\tpacket_buf_write(req_buf, \"server-option=%s\",\n@@ -1332,7 +1332,7 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n \t}\n \n \tif (server_feature_v2(\"object-format\", &hash_name)) {\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo_by_ptr(the_hash_algo) != hash_algo)\n \t\t\tdie(_(\"mismatched algorithms: client %s; server %s\"),\n \t\t\t    the_hash_algo->name, hash_name);\ndiff --git a/fsck.c b/fsck.c\nindex 2b18717ee80..ce0efac3b27 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -36,7 +36,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -44,7 +44,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/git.c b/git.c\nindex 6171fd6769d..f227d083c66 100644\n--- a/git.c\n+++ b/git.c\n@@ -42,7 +42,7 @@ static void list_builtins(struct string_list *list, unsigned int exclude_option)\n \n static void exclude_helpers_from_list(struct string_list *list)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \n \twhile (i < list->nr) {\n \t\tif (strstr(list->items[i].string, \"--\"))\ndiff --git a/hash.h b/hash.h\nindex 36b64165fc9..8e72b5a5930 100644\n--- a/hash.h\n+++ b/hash.h\n@@ -186,13 +186,13 @@ extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];\n  * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if\n  * the name doesn't match a known algorithm.\n  */\n-int hash_algo_by_name(const char *name);\n+unsigned hash_algo_by_name(const char *name);\n /* Identical, except based on the format ID. */\n-int hash_algo_by_id(uint32_t format_id);\n+unsigned hash_algo_by_id(uint32_t format_id);\n /* Identical, except based on the length. */\n-int hash_algo_by_length(int len);\n+unsigned hash_algo_by_length(size_t len);\n /* Identical, except for a pointer to struct git_hash_algo. */\n-static inline int hash_algo_by_ptr(const struct git_hash_algo *p)\n+static inline unsigned hash_algo_by_ptr(const struct git_hash_algo *p)\n {\n \treturn p - hash_algos;\n }\ndiff --git a/help.c b/help.c\nindex 812af4cdea6..90e2d41d514 100644\n--- a/help.c\n+++ b/help.c\n@@ -92,7 +92,7 @@ static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask)\n static void print_command_list(const struct cmdname_help *cmds,\n \t\t\t       uint32_t mask, int longest)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; cmds[i].name; i++) {\n \t\tif (cmds[i].category & mask) {\n@@ -380,7 +380,7 @@ void list_all_other_cmds(struct string_list *list)\n void list_cmds_by_category(struct string_list *list,\n \t\t\t   const char *cat)\n {\n-\tint i, n = ARRAY_SIZE(command_list);\n+\tsize_t i, n = ARRAY_SIZE(command_list);\n \tuint32_t cat_id = 0;\n \n \tfor (i = 0; category_names[i]; i++) {\n@@ -470,7 +470,7 @@ static int get_alias(const char *var, const char *value, void *data)\n static void list_all_cmds_help_external_commands(void)\n {\n \tstruct string_list others = STRING_LIST_INIT_DUP;\n-\tint i;\n+\tsize_t i;\n \n \tlist_all_other_cmds(&others);\n \tif (others.nr)\n@@ -484,7 +484,7 @@ static void list_all_cmds_help_aliases(int longest)\n {\n \tstruct string_list alias_list = STRING_LIST_INIT_DUP;\n \tstruct cmdname_help *aliases;\n-\tint i;\n+\tsize_t i;\n \n \tgit_config(get_alias, &alias_list);\n \tstring_list_sort(&alias_list);\n@@ -810,7 +810,7 @@ static struct string_list guess_refs(const char *ref)\n NORETURN void help_unknown_ref(const char *ref, const char *cmd,\n \t\t\t       const char *error)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct string_list suggested_refs = guess_refs(ref);\n \n \tfprintf_ln(stderr, _(\"%s: %s - %s\"), cmd, ref, error);\ndiff --git a/help.h b/help.h\nindex af073a7a026..3a7940b32a0 100644\n--- a/help.h\n+++ b/help.h\n@@ -58,7 +58,7 @@ static inline void list_config_item(struct string_list *list,\n #define define_list_config_array(array)\t\t\t\t\t\\\n void list_config_##array(struct string_list *list, const char *prefix)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\tint i;\t\t\t\t\t\t\t\t\\\n+\tsize_t i;\t\t\t\t\t\t\t\t\\\n \tfor (i = 0; i < ARRAY_SIZE(array); i++)\t\t\t\t\\\n \t\tif (array[i])\t\t\t\t\t\t\\\n \t\t\tlist_config_item(list, prefix, array[i]);\t\\\n@@ -68,7 +68,7 @@ struct string_list\n #define define_list_config_array_extra(array, values)\t\t\t\\\n void list_config_##array(struct string_list *list, const char *prefix)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\tint i;\t\t\t\t\t\t\t\t\\\n+\tsize_t i;\t\t\t\t\t\t\t\t\\\n \tstatic const char *extra[] = values;\t\t\t\t\\\n \tfor (i = 0; i < ARRAY_SIZE(extra); i++)\t\t\t\t\\\n \t\tlist_config_item(list, prefix, extra[i]);\t\t\\\ndiff --git a/hex.c b/hex.c\nindex 4f64d346963..9337f4572e4 100644\n--- a/hex.c\n+++ b/hex.c\n@@ -50,7 +50,7 @@ int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)\n static int get_hash_hex_algop(const char *hex, unsigned char *hash,\n \t\t\t      const struct git_hash_algo *algop)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < algop->rawsz; i++) {\n \t\tint val = hex2chr(hex);\n \t\tif (val < 0)\n@@ -122,7 +122,7 @@ char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash,\n {\n \tstatic const char hex[] = \"0123456789abcdef\";\n \tchar *buf = buffer;\n-\tint i;\n+\tsize_t i;\n \n \t/*\n \t * Our struct object_id has been memset to 0, so default to printing\ndiff --git a/http-backend.c b/http-backend.c\nindex 8ab58e55f85..1a4e9eb632d 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -255,7 +255,7 @@ static struct rpc_service *select_service(struct strbuf *hdr, const char *name)\n {\n \tconst char *svc_name;\n \tstruct rpc_service *svc = NULL;\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(name, \"git-\", &svc_name))\n \t\tforbidden(hdr, \"Unsupported service: '%s'\", name);\n@@ -743,7 +743,7 @@ int cmd_main(int argc, const char **argv)\n \tchar *dir;\n \tstruct service_cmd *cmd = NULL;\n \tchar *cmd_arg = NULL;\n-\tint i;\n+\tsize_t i;\n \tstruct strbuf hdr = STRBUF_INIT;\n \n \tset_die_routine(die_webcgi);\ndiff --git a/http-push.c b/http-push.c\nindex 7f71316456c..a5d460bdf18 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1325,7 +1325,7 @@ static struct object_list **process_tree(struct tree *tree,\n \n static int get_delta(struct rev_info *revs, struct remote_lock *lock)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *commit;\n \tstruct object_list **p = &objects;\n \tint count = 0;\n@@ -1580,8 +1580,8 @@ static int delete_remote_branch(const char *pattern, int force)\n \tstruct object_id head_oid;\n \tchar *symref = NULL;\n \tint match;\n-\tint patlen = strlen(pattern);\n-\tint i;\n+\tsize_t patlen = strlen(pattern);\n+\tsize_t i;\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n \tchar *url;\n@@ -1589,7 +1589,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t/* Find the remote branch(es) matching the specified branch name */\n \tfor (match = 0; refs; refs = refs->next) {\n \t\tchar *name = refs->name;\n-\t\tint namelen = strlen(name);\n+\t\tsize_t namelen = strlen(name);\n \t\tif (namelen < patlen ||\n \t\t    memcmp(name + namelen - patlen, pattern, patlen))\n \t\t\tcontinue;\ndiff --git a/http-walker.c b/http-walker.c\nindex b8f0f98ae14..e42fe8d6be0 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -170,7 +170,7 @@ static int is_alternate_allowed(const char *url)\n \tconst char *protocols[] = {\n \t\t\"http\", \"https\", \"ftp\", \"ftps\"\n \t};\n-\tint i;\n+\tsize_t i;\n \n \tif (http_follow_config != HTTP_FOLLOW_ALWAYS) {\n \t\twarning(\"alternate disabled by http.followRedirects: %s\", url);\n@@ -207,7 +207,7 @@ static void process_alternates_response(void *callback_data)\n \tconst char *base = alt_req->base;\n \tconst char null_byte = '\\0';\n \tchar *data;\n-\tint i = 0;\n+\tsize_t i = 0;\n \n \tnormalize_curl_result(&slot->curl_result, slot->http_code,\n \t\t\t      curl_errorstr, sizeof(curl_errorstr));\n@@ -247,12 +247,12 @@ static void process_alternates_response(void *callback_data)\n \tdata = alt_req->buffer->buf;\n \n \twhile (i < alt_req->buffer->len) {\n-\t\tint posn = i;\n+\t\tsize_t posn = i;\n \t\twhile (posn < alt_req->buffer->len && data[posn] != '\\n')\n \t\t\tposn++;\n \t\tif (data[posn] == '\\n') {\n \t\t\tint okay = 0;\n-\t\t\tint serverlen = 0;\n+\t\t\tsize_t serverlen = 0;\n \t\t\tstruct alt_base *newalt;\n \t\t\tif (data[i] == '/') {\n \t\t\t\t/*\ndiff --git a/http.c b/http.c\nindex c4b6ddef287..671af68fff4 100644\n--- a/http.c\n+++ b/http.c\n@@ -481,7 +481,7 @@ static void init_curl_proxy_auth(CURL *result)\n \tvar_override(&http_proxy_authmethod, getenv(\"GIT_HTTP_PROXY_AUTHMETHOD\"));\n \n \tif (http_proxy_authmethod) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) {\n \t\t\tif (!strcmp(http_proxy_authmethod, proxy_authmethods[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYAUTH,\n@@ -800,7 +800,7 @@ static long get_curl_allowed_protocols(int from_user, struct strbuf *list)\n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n {\n-\tint i;\n+\tsize_t i;\n \tstatic struct {\n \t\tconst char *name;\n \t\tlong opt_token;\n@@ -854,7 +854,7 @@ static CURL *get_curl_handle(void)\n \n #ifdef CURLGSSAPI_DELEGATION_FLAG\n \tif (curl_deleg) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {\n \t\t\tif (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,\n@@ -883,7 +883,7 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_SSL_VERSION\"))\n \t\tssl_version = getenv(\"GIT_SSL_VERSION\");\n \tif (ssl_version && *ssl_version) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(sslversions); i++) {\n \t\t\tif (!strcmp(ssl_version, sslversions[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_SSLVERSION,\n@@ -1089,7 +1089,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)\n \tif (http_ssl_backend) {\n \t\tconst curl_ssl_backend **backends;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tswitch (curl_global_sslset(-1, http_ssl_backend, &backends)) {\n \t\tcase CURLSSLSET_UNKNOWN_BACKEND:\n@@ -1754,9 +1754,9 @@ static void write_accept_language(struct strbuf *buf)\n \tconst int MAX_LANGUAGE_TAGS = 1000;\n \tconst int MAX_ACCEPT_LANGUAGE_HEADER_SIZE = 4000;\n \tchar **language_tags = NULL;\n-\tint num_langs = 0;\n+\tunsigned int num_langs = 0;\n \tconst char *s = get_preferred_languages();\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf tag = STRBUF_INIT;\n \n \t/* Don't add Accept-Language header if no language is preferred. */\n@@ -1802,7 +1802,7 @@ static void write_accept_language(struct strbuf *buf)\n \t\t     decimal_places++, max_q *= 10)\n \t\t\t;\n \n-\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%dd\", decimal_places);\n+\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%ud\", decimal_places);\n \n \t\tstrbuf_addstr(buf, \"Accept-Language: \");\n \ndiff --git a/line-log.c b/line-log.c\nindex a7f3e7f6ce4..7a87eb27ef7 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -473,8 +473,8 @@ static void range_set_map_across_diff(struct range_set *out,\n static struct commit *check_single_commit(struct rev_info *revs)\n {\n \tstruct object *commit = NULL;\n-\tint found = -1;\n-\tint i;\n+\tunsigned found = 0;\n+\tunsigned i;\n \n \tfor (i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object *obj = revs->pending.objects[i].item;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/list-objects.c b/list-objects.c\nindex 7528fe1db2c..23f1b0963ea 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -267,7 +267,7 @@ void mark_edges_uninteresting(struct rev_info *revs,\n \t\t\t      int sparse)\n {\n \tstruct commit_list *list;\n-\tint i;\n+\tunsigned int i;\n \n \tif (sparse) {\n \t\tstruct oidset set;\n@@ -326,7 +326,7 @@ static void add_pending_tree(struct rev_info *revs, struct tree *tree)\n static void traverse_non_commits(struct traversal_context *ctx,\n \t\t\t\t struct strbuf *base)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tassert(base->len == 0);\n \ndiff --git a/ll-merge.c b/ll-merge.c\nindex 130d26501c6..4643c8c2f65 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -194,7 +194,8 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,\n \tstruct strbuf_expand_dict_entry dict[6];\n \tstruct strbuf path_sq = STRBUF_INIT;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint status, fd, i;\n+\tint status, fd;\n+\tunsigned int i;\n \tstruct stat st;\n \tenum ll_merge_result ret;\n \tassert(opts);\n@@ -329,7 +330,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr\n {\n \tstruct ll_merge_driver *fn;\n \tconst char *name;\n-\tint i;\n+\tsize_t i;\n \n \tinitialize_ll_merge();\n \ndiff --git a/lockfile.c b/lockfile.c\nindex cc9a4b84283..5468a642654 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -14,7 +14,7 @@\n  */\n static void trim_last_path_component(struct strbuf *path)\n {\n-\tint i = path->len;\n+\tsize_t i = path->len;\n \n \t/* back up past trailing slashes, if any */\n \twhile (i && path->buf[i - 1] == '/')\ndiff --git a/log-tree.c b/log-tree.c\nindex 1dd5fcbf7be..5db3fcede2c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -138,7 +138,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\t\t      int flags UNUSED,\n \t\t\t      void *cb_data)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct object *obj;\n \tenum object_type objtype;\n \tenum decoration_type deco_type = DECORATION_NONE;\ndiff --git a/ls-refs.c b/ls-refs.c\nindex 697d4beb8de..b40f902648f 100644\n--- a/ls-refs.c\n+++ b/ls-refs.c\n@@ -54,7 +54,7 @@ static void ensure_config_read(void)\n  */\n static int ref_match(const struct strvec *prefixes, const char *refname)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (!prefixes->nr)\n \t\treturn 1; /* no restriction */\ndiff --git a/mailinfo.c b/mailinfo.c\nindex 833d28612f7..963ad2e7794 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -617,7 +617,7 @@ check_header_out:\n static int is_inbody_header(const struct mailinfo *mi,\n \t\t\t    const struct strbuf *line)\n {\n-\tint i;\n+\tsize_t i;\n \tconst char *val;\n \tfor (i = 0; header[i]; i++)\n \t\tif (!mi->s_hdr_data[i] && skip_header(line, header[i], &val))\n@@ -765,7 +765,7 @@ static int check_inbody_header(struct mailinfo *mi, const struct strbuf *line)\n \tif (starts_with(line->buf, \">From\") && isspace(line->buf[5]))\n \t\treturn is_format_patch_separator(line->buf + 1, line->len - 1);\n \tif (starts_with(line->buf, \"[PATCH]\") && isspace(line->buf[7])) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; header[i]; i++)\n \t\t\tif (!strcmp(\"Subject\", header[i])) {\n \t\t\t\thandle_header(&mi->s_hdr_data[i], line);\n@@ -809,7 +809,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)\n \t\treturn 0; /* mi->input_error already set */\n \n \tif (mi->use_scissors && is_scissors_line(line->buf)) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tstrbuf_setlen(&mi->log_message, 0);\n \t\tmi->header_stage = 1;\n@@ -1147,7 +1147,7 @@ static void output_header_lines(FILE *fout, const char *hdr, const struct strbuf\n static void handle_info(struct mailinfo *mi)\n {\n \tstruct strbuf *hdr;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; header[i]; i++) {\n \t\t/* only print inbody headers if we output a patch file */\ndiff --git a/merge-ort.c b/merge-ort.c\nindex d1611ca400a..a57dacaa080 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -681,9 +681,9 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,\n \t\t/* Release and free each strbuf found in output */\n \t\tstrmap_for_each_entry(&opti->conflicts, &iter, e) {\n \t\t\tstruct string_list *list = e->value;\n-\t\t\tfor (int i = 0; i < list->nr; i++) {\n+\t\t\tfor (size_t j = 0; j < list->nr; j++) {\n \t\t\t\tstruct logical_conflict_info *info =\n-\t\t\t\t\tlist->items[i].util;\n+\t\t\t\t\tlist->items[j].util;\n \t\t\t\tstrvec_clear(&info->paths);\n \t\t\t}\n \t\t\t/*\n@@ -793,7 +793,7 @@ static void path_msg(struct merge_options *opt,\n \tif (other_path_2)\n \t\tstrvec_push(&info->paths, other_path_2);\n \tif (other_paths)\n-\t\tfor (int i = 0; i < other_paths->nr; i++)\n+\t\tfor (size_t i = 0; i < other_paths->nr; i++)\n \t\tstrvec_push(&info->paths, other_paths->items[i].string);\n \n \t/* Handle message and its format, in normal case */\n@@ -810,7 +810,7 @@ static void path_msg(struct merge_options *opt,\n \n \t/* Handle specialized formatting of message under --remerge-diff */\n \tif (opt->record_conflict_msgs_as_headers) {\n-\t\tint i_sb = 0, i_tmp = 0;\n+\t\tsize_t i_sb = 0, i_tmp = 0;\n \n \t\t/* Start with the specified prefix */\n \t\tif (opt->msg_header_prefix)\n@@ -1011,7 +1011,7 @@ static void setup_path_info(struct merge_options *opt,\n \t\toidcpy(&mi->result.oid, &merged_version->oid);\n \t\tmi->is_null = !!is_null;\n \t} else {\n-\t\tint i;\n+\t\tunsigned i;\n \t\tstruct conflict_info *ci;\n \n \t\tASSIGN_AND_VERIFY_CI(ci, mi);\n@@ -1380,7 +1380,8 @@ static int collect_merge_info_callback(int n,\n \t\tstruct tree_desc t[3];\n \t\tvoid *buf[3] = {NULL, NULL, NULL};\n \t\tconst char *original_dir_name;\n-\t\tint i, ret, side;\n+\t\tunsigned int i, side;\n+\t\tint ret;\n \n \t\t/*\n \t\t * Check for whether we can avoid recursing due to one side\n@@ -1553,12 +1554,12 @@ static int handle_deferred_entries(struct merge_options *opt,\n \t\t\t\t\t    0);\n \t\tstrintmap_for_each_entry(&copy, &iter, entry) {\n \t\t\tconst char *path = entry->key;\n-\t\t\tunsigned dir_rename_mask = (intptr_t)entry->value;\n+\t\t\tunsigned dir_rename_mask = (uintptr_t)entry->value;\n \t\t\tstruct conflict_info *ci;\n \t\t\tunsigned dirmask;\n \t\t\tstruct tree_desc t[3];\n \t\t\tvoid *buf[3] = {NULL,};\n-\t\t\tint i;\n+\t\t\tunsigned i;\n \n \t\t\tci = strmap_get(&opt->priv->paths, path);\n \t\t\tVERIFY_CI(ci);\n@@ -1683,13 +1684,13 @@ static int collect_merge_info(struct merge_options *opt,\n \n /*** Function Grouping: functions related to threeway content merges ***/\n \n-static int find_first_merges(struct repository *repo,\n+static unsigned find_first_merges(struct repository *repo,\n \t\t\t     const char *path,\n \t\t\t     struct commit *a,\n \t\t\t     struct commit *b,\n \t\t\t     struct object_array *result)\n {\n-\tint i, j;\n+\tunsigned i, j;\n \tstruct object_array merges = OBJECT_ARRAY_INIT;\n \tstruct commit *commit;\n \tint contains_another;\n@@ -1757,10 +1758,10 @@ static int merge_submodule(struct merge_options *opt,\n \tstruct strbuf sb = STRBUF_INIT;\n \tint ret = 0;\n \tstruct commit *commit_o, *commit_a, *commit_b;\n-\tint parent_count;\n+\tunsigned parent_count;\n \tstruct object_array merges;\n \n-\tint i;\n+\tunsigned i;\n \tint search = !opt->priv->call_depth;\n \tint sub_not_initialized = 1;\n \tint sub_flag = CONFLICT_SUBMODULE_FAILED_TO_MERGE;\n@@ -2357,7 +2358,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt)\n \tstruct rename_info *renames = &opt->priv->renames;\n \tstruct strmap *side1_dir_renames = &renames->dir_renames[MERGE_SIDE1];\n \tstruct strmap *side2_dir_renames = &renames->dir_renames[MERGE_SIDE2];\n-\tint i;\n+\tsize_t i;\n \n \tstrmap_for_each_entry(side1_dir_renames, &iter, entry) {\n \t\tif (strmap_contains(side2_dir_renames, entry->key))\n@@ -3339,8 +3340,9 @@ static int detect_and_process_renames(struct merge_options *opt,\n \tstruct diff_queue_struct combined = { 0 };\n \tstruct rename_info *renames = &opt->priv->renames;\n \tstruct strmap collisions[3];\n-\tint need_dir_renames, s, i, clean = 1;\n-\tunsigned detection_run = 0;\n+\tint need_dir_renames, s, clean = 1;\n+\tunsigned i;\n+\tint detection_run = 0;\n \n \tif (!possible_renames(renames))\n \t\tgoto cleanup;\n@@ -3353,13 +3355,13 @@ static int detect_and_process_renames(struct merge_options *opt,\n \t\trenames->redo_after_renames = 0;\n \t}\n \tif (renames->redo_after_renames && detection_run) {\n-\t\tint i, side;\n+\t\tint side;\n \t\tstruct diff_filepair *p;\n \n \t\t/* Cache the renames, we found */\n \t\tfor (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) "},{"id":"473524","messageId":"pull.1399.v17.git.git.1678886803276.gitgitgadget@gmail.com","threadId":"58962","inReplyTo":"pull.1399.v16.git.git.1678886439331.gitgitgadget@gmail.com","subject":"[PATCH v17] git: change variable types to match what is assigned to them","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-03-15T13:26:42Z","receivedAt":"2023-03-15T13:27:01Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThere are many places where \"int len = strlen(foo);\" is written,\njust for len to be passed as a parameter of size_t.\n\nThis causes truncation and then expansion\nback from int to size_t. This is poor logic.\n\nAs of right now, the current set of changes\nis too large to keep going, so future changes\nshould be in future patches. However, the codebase\nworks perfectly even if only these changes\nwere ever to be accepted. I just do not want\nto change too much at a time.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: change variable types to match what is assigned to them\n    \n    There are many places where \"int len = strlen(foo);\" is written, just\n    for len to be passed as a parameter of size_t. This causes truncation\n    and then expansion back from int to size_t. Not to mention this is poor\n    logic and needless truncations can add extra unneeded instructions.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1399%2FAtariDreams%2Ffix-type-v17\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1399/AtariDreams/fix-type-v17\nPull-Request: https://github.com/git/git/pull/1399\n\nRange-diff vs v16:\n\n 1:  8b4008fd55d ! 1:  e85f9787279 git: change variable types to match what is assigned to them\n     @@ cache.h: int path_inside_repo(const char *prefix, const char *path);\n       \n       int init_db(const char *git_dir, const char *real_git_dir,\n      -\t    const char *template_dir, int hash_algo,\n     -+\t    const char *template_dir, unsigned int hash_algo,\n     ++\t    const char *template_dir, int hash,\n       \t    const char *initial_branch, unsigned int flags);\n      -void initialize_repository_version(int hash_algo, int reinit);\n     -+void initialize_repository_version(unsigned int hash_algo, int reinit);\n     ++void initialize_repository_version(unsigned int hash, int reinit);\n       \n       void sanitize_stdfds(void);\n       int daemonize(void);\n\n\n add-interactive.c             | 29 ++++++-----\n add-patch.c                   |  3 +-\n advice.c                      |  4 +-\n apply.c                       | 64 +++++++++++-------------\n apply.h                       |  8 +--\n archive-tar.c                 |  8 +--\n archive.c                     |  2 +-\n attr.c                        | 10 ++--\n base85.c                      | 11 +++--\n bisect.c                      |  8 +--\n blame.c                       | 20 ++++----\n block-sha1/sha1.c             |  2 +-\n bloom.c                       | 10 ++--\n branch.c                      |  4 +-\n builtin/add.c                 |  3 +-\n builtin/clone.c               |  2 +-\n builtin/commit.c              |  2 +-\n builtin/fast-export.c         |  4 +-\n builtin/fast-import.c         |  2 +-\n builtin/fetch-pack.c          |  2 +-\n builtin/fetch.c               |  7 +--\n builtin/for-each-repo.c       |  3 +-\n builtin/fsck.c                |  2 +-\n builtin/gc.c                  | 43 +++++++++-------\n builtin/grep.c                |  5 +-\n builtin/help.c                |  2 +-\n builtin/index-pack.c          |  2 +-\n builtin/init-db.c             | 10 ++--\n builtin/log.c                 |  4 +-\n builtin/ls-files.c            | 24 ++++-----\n builtin/ls-remote.c           |  1 -\n builtin/mailsplit.c           |  2 +-\n builtin/merge-file.c          |  3 +-\n builtin/merge.c               |  3 +-\n builtin/name-rev.c            |  4 +-\n builtin/pack-objects.c        |  4 +-\n builtin/pack-redundant.c      |  6 +--\n builtin/patch-id.c            | 14 +++---\n builtin/pull.c                |  2 +-\n builtin/read-tree.c           |  6 +--\n builtin/rebase.c              |  6 +--\n builtin/receive-pack.c        | 12 +++--\n builtin/remote.c              | 12 +++--\n builtin/repack.c              |  7 +--\n builtin/rerere.c              |  3 +-\n builtin/reset.c               |  2 +-\n builtin/rev-parse.c           |  2 +-\n builtin/rm.c                  | 10 ++--\n builtin/show-branch.c         | 34 ++++++-------\n builtin/show-index.c          |  4 +-\n builtin/sparse-checkout.c     |  7 +--\n builtin/stash.c               |  4 +-\n builtin/submodule--helper.c   |  7 +--\n builtin/unpack-objects.c      |  2 +-\n builtin/update-ref.c          |  4 +-\n builtin/worktree.c            |  7 +--\n bulk-checkin.c                |  4 +-\n bundle.c                      | 15 +++---\n cache-tree.c                  | 10 ++--\n cache.h                       | 16 +++---\n chunk-format.c                |  7 +--\n color.c                       | 34 +++++++------\n color.h                       |  2 +-\n column.c                      |  9 ++--\n combine-diff.c                | 19 ++++---\n commit-graph.c                | 19 +++----\n commit-reach.c                | 11 +++--\n commit.c                      | 10 ++--\n compat/compiler.h             |  9 ++--\n compat/strcasestr.c           | 10 ++--\n compat/unsetenv.c             |  2 +-\n compat/winansi.c              |  7 +--\n config.c                      | 31 +++++++-----\n config.h                      |  2 +-\n connect.c                     | 22 ++++-----\n convert.c                     | 16 +++---\n credential.c                  |  6 +--\n daemon.c                      | 14 +++---\n date.c                        |  4 +-\n decorate.c                    |  6 +--\n delta-islands.c               | 10 ++--\n diagnose.c                    |  2 +-\n diff-lib.c                    |  4 +-\n diff-no-index.c               |  3 +-\n diff.c                        | 35 ++++++-------\n dir.c                         |  3 +-\n dir.h                         |  2 +-\n fetch-pack.c                  |  4 +-\n fsck.c                        |  4 +-\n git.c                         |  2 +-\n hash.h                        |  8 +--\n help.c                        | 10 ++--\n help.h                        |  4 +-\n hex.c                         |  4 +-\n http-backend.c                |  4 +-\n http-push.c                   |  8 +--\n http-walker.c                 |  8 +--\n http.c                        | 16 +++---\n line-log.c                    |  4 +-\n list-objects-filter-options.c |  2 +-\n list-objects.c                |  4 +-\n ll-merge.c                    |  5 +-\n lockfile.c                    |  2 +-\n log-tree.c                    |  2 +-\n ls-refs.c                     |  2 +-\n mailinfo.c                    |  8 +--\n merge-ort.c                   | 93 ++++++++++++++++++-----------------\n merge-recursive.c             | 27 +++++-----\n merge-recursive.h             |  2 +-\n merge.c                       |  5 +-\n mergesort.h                   |  2 +-\n name-hash.c                   |  6 +--\n notes-utils.c                 |  4 +-\n notes.c                       |  4 +-\n object-file.c                 | 12 ++---\n object-name.c                 |  6 +--\n path.c                        |  4 +-\n pathspec.c                    | 22 +++++----\n pathspec.h                    |  4 +-\n pkt-line.c                    |  2 +-\n pretty.c                      | 28 +++++------\n range-diff.c                  | 15 +++---\n read-cache.c                  | 45 +++++++++--------\n remote-curl.c                 |  2 +-\n repository.c                  |  2 +-\n repository.h                  |  2 +-\n run-command.c                 |  5 +-\n shallow.c                     |  2 +-\n shallow.h                     |  2 +-\n strbuf.c                      |  4 +-\n string-list.c                 |  3 +-\n string-list.h                 |  3 +-\n sub-process.c                 |  4 +-\n submodule.c                   | 16 +++---\n submodule.h                   |  2 +-\n trailer.c                     |  2 +-\n transport-helper.c            | 10 ++--\n transport.c                   |  8 +--\n unpack-trees.c                | 16 +++---\n unpack-trees.h                |  2 +-\n wt-status.c                   | 29 +++++------\n xdiff-interface.c             |  6 +--\n 142 files changed, 687 insertions(+), 627 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 00a0f6f96f3..5ece4dab996 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -218,7 +218,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n struct list_options {\n \tint columns;\n \tconst char *header;\n-\tvoid (*print_item)(int i, int selected, struct string_list_item *item,\n+\tvoid (*print_item)(size_t i, int selected,\n+\t\t\t   struct string_list_item *item,\n \t\t\t   void *print_item_data);\n \tvoid *print_item_data;\n };\n@@ -226,7 +227,8 @@ struct list_options {\n static void list(struct add_i_state *s, struct string_list *list, int *selected,\n \t\t struct list_options *opts)\n {\n-\tint i, last_lf = 0;\n+\tsize_t i;\n+\tint last_lf = 0;\n \n \tif (!list->nr)\n \t\treturn;\n@@ -469,7 +471,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n \n \tfor (i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n-\t\tint hash = strhash(name);\n+\t\tunsigned int hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n \t\tstruct file_item *file_item;\n \t\tstruct adddel *adddel, *other_adddel;\n@@ -528,7 +530,7 @@ static int get_modified_files(struct repository *r,\n \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t     &head_oid, NULL);\n \tstruct collection_status s = { 0 };\n-\tint i;\n+\tunsigned int i;\n \n \tdiscard_index(r->index);\n \tif (repo_read_index_preload(r, ps, 0) < 0)\n@@ -617,12 +619,14 @@ struct print_file_item_data {\n \tunsigned only_names:1;\n };\n \n-static void print_file_item(int i, int selected, struct string_list_item *item,\n+static void print_file_item(size_t i, int selected,\n+\t\t\t    struct string_list_item *item,\n \t\t\t    void *print_file_item_data)\n {\n \tstruct file_item *c = item->util;\n \tstruct print_file_item_data *d = print_file_item_data;\n \tconst char *highlighted = NULL;\n+\tunsigned int e = (unsigned int)i + 1;\n \n \tstrbuf_reset(&d->index);\n \tstrbuf_reset(&d->worktree);\n@@ -639,7 +643,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \t}\n \n \tif (d->only_names) {\n-\t\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1,\n+\t\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e,\n \t\t       highlighted ? highlighted : item->string);\n \t\treturn;\n \t}\n@@ -650,7 +654,7 @@ static void print_file_item(int i, int selected, struct string_list_item *item,\n \tstrbuf_addf(&d->buf, d->modified_fmt, d->index.buf, d->worktree.buf,\n \t\t    highlighted ? highlighted : item->string);\n \n-\tprintf(\"%c%2d: %s\", selected ? '*' : ' ', i + 1, d->buf.buf);\n+\tprintf(\"%c%2u: %s\", selected ? '*' : ' ', e, d->buf.buf);\n }\n \n static int run_status(struct add_i_state *s, const struct pathspec *ps,\n@@ -1067,20 +1071,21 @@ struct print_command_item_data {\n \tconst char *color, *reset;\n };\n \n-static void print_command_item(int i, int selected,\n+static void print_command_item(size_t i, int selected,\n \t\t\t       struct string_list_item *item,\n \t\t\t       void *print_command_item_data)\n {\n+\tunsigned int e = (unsigned int)(i + 1);\n \tstruct print_command_item_data *d = print_command_item_data;\n \tstruct command_item *util = item->util;\n \n \tif (!util->prefix_length ||\n \t    !is_valid_prefix(item->string, util->prefix_length))\n-\t\tprintf(\" %2d: %s\", i + 1, item->string);\n+\t\tprintf(\" %2u: %s\", e, item->string);\n \telse\n-\t\tprintf(\" %2d: %s%.*s%s%s\", i + 1,\n-\t\t       d->color, (int)util->prefix_length, item->string,\n-\t\t       d->reset, item->string + util->prefix_length);\n+\t\tprintf(\" %2u: %s%.*s%s%s\", e, d->color,\n+\t\t       (int)util->prefix_length, item->string, d->reset,\n+\t\t       item->string + util->prefix_length);\n }\n \n static void command_prompt_help(struct add_i_state *s)\ndiff --git a/add-patch.c b/add-patch.c\nindex a86a92e1646..be049301bb1 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -377,9 +377,10 @@ static int is_octal(const char *p, size_t len)\n \tif (!len)\n \t\treturn 0;\n \n-\twhile (len--)\n+\tdo {\n \t\tif (*p < '0' || *(p++) > '7')\n \t\t\treturn 0;\n+\t} while (--len);\n \treturn 1;\n }\n \ndiff --git a/advice.c b/advice.c\nindex fd189689437..74ae3020dab 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -138,7 +138,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)\n int git_default_advice_config(const char *var, const char *value)\n {\n \tconst char *k, *slot_name;\n-\tint i;\n+\tsize_t i;\n \n \tif (!strcmp(var, \"color.advice\")) {\n \t\tadvice_use_color = git_config_colorbool(var, value);\n@@ -169,7 +169,7 @@ int git_default_advice_config(const char *var, const char *value)\n \n void list_config_advices(struct string_list *list, const char *prefix)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++)\n \t\tlist_config_item(list, prefix, advice_setting[i].key);\ndiff --git a/apply.c b/apply.c\nindex 5cc5479c9c3..0881bda6f50 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -443,7 +443,7 @@ static int name_terminate(int c, int terminate)\n /* remove double slashes to make --index work with such filenames */\n static char *squash_slash(char *name)\n {\n-\tint i = 0, j = 0;\n+\tsize_t i = 0, j = 0;\n \n \tif (!name)\n \t\treturn NULL;\n@@ -654,7 +654,7 @@ static char *find_name_common(struct strbuf *root,\n \t\t\t      const char *end,\n \t\t\t      int terminate)\n {\n-\tint len;\n+\tsize_t len;\n \tconst char *start = NULL;\n \n \tif (p_value == 0)\n@@ -685,13 +685,13 @@ static char *find_name_common(struct strbuf *root,\n \t * or \"file~\").\n \t */\n \tif (def) {\n-\t\tint deflen = strlen(def);\n+\t\tsize_t deflen = strlen(def);\n \t\tif (deflen < len && !strncmp(start, def, deflen))\n \t\t\treturn squash_slash(xstrdup(def));\n \t}\n \n \tif (root->len) {\n-\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, len, start);\n+\t\tchar *ret = xstrfmt(\"%s%.*s\", root->buf, (int)len, start);\n \t\treturn squash_slash(ret);\n \t}\n \n@@ -790,7 +790,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tconst char *timestamp = NULL, *cp, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n-\tint zoneoffset, epoch_hour, hour, minute;\n+\tlong zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n \tfor (cp = nameline; *cp != '\\n'; cp++) {\n@@ -1068,7 +1068,7 @@ static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,\n \t\t\t\t const char *line,\n \t\t\t\t struct patch *patch)\n {\n-\tunsigned long val = strtoul(line, NULL, 10);\n+\tint val = atoi(line);\n \tif (val <= 100)\n \t\tpatch->score = val;\n \treturn 0;\n@@ -1083,7 +1083,7 @@ static int gitdiff_index(struct gitdiff_data *state,\n \t * and optional space with octal mode.\n \t */\n \tconst char *ptr, *eol;\n-\tint len;\n+\tsize_t len;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tptr = strchr(line, '.');\n@@ -1125,12 +1125,10 @@ static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,\n  * Skip p_value leading components from \"line\"; as we do not accept\n  * absolute paths, return NULL in that case.\n  */\n-static const char *skip_tree_prefix(int p_value,\n-\t\t\t\t    const char *line,\n-\t\t\t\t    int llen)\n+static const char *skip_tree_prefix(int p_value, const char *line, size_t llen)\n {\n \tint nslash;\n-\tint i;\n+\tsize_t i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n@@ -1152,9 +1150,7 @@ static const char *skip_tree_prefix(int p_value,\n  * creation or deletion of an empty file.  In any of these cases,\n  * both sides are the same name under a/ and b/ respectively.\n  */\n-static char *git_header_name(int p_value,\n-\t\t\t     const char *line,\n-\t\t\t     int llen)\n+static char *git_header_name(int p_value, const char *line, size_t llen)\n {\n \tconst char *name;\n \tconst char *second = NULL;\n@@ -1302,12 +1298,8 @@ static int check_header_line(int linenr, struct patch *patch)\n \treturn 0;\n }\n \n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch)\n {\n \tunsigned long offset;\n@@ -1360,14 +1352,14 @@ int parse_git_diff_header(struct strbuf *root,\n \t\t\t{ \"index \", gitdiff_index },\n \t\t\t{ \"\", gitdiff_unrecognized },\n \t\t};\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tlen = linelen(line, size);\n \t\tif (!len || line[len-1] != '\\n')\n \t\t\tbreak;\n \t\tfor (i = 0; i < ARRAY_SIZE(optable); i++) {\n \t\t\tconst struct opentry *p = optable + i;\n-\t\t\tint oplen = strlen(p->str);\n+\t\t\tsize_t oplen = strlen(p->str);\n \t\t\tint res;\n \t\t\tif (len < oplen || memcmp(p->str, line, oplen))\n \t\t\t\tcontinue;\n@@ -1391,7 +1383,7 @@ done:\n \t\t\t\t \"%d leading pathname components (line %d)\",\n \t\t\t\t parse_hdr_state.p_value),\n \t\t\t      parse_hdr_state.p_value, *linenr);\n-\t\t\treturn -128;\n+\t\t\treturn -1;\n \t\t}\n \t\tpatch->old_name = xstrdup(patch->def_name);\n \t\tpatch->new_name = xstrdup(patch->def_name);\n@@ -1400,7 +1392,7 @@ done:\n \t    (!patch->old_name && !patch->is_new)) {\n \t\terror(_(\"git diff header lacks filename information \"\n \t\t\t\"(line %d)\"), *linenr);\n-\t\treturn -128;\n+\t\treturn -1;\n \t}\n \tpatch->is_toplevel_relative = 1;\n \treturn offset;\n@@ -1454,22 +1446,23 @@ static int parse_range(const char *line, int len, int offset, const char *expect\n \treturn offset + ex;\n }\n \n-static void recount_diff(const char *line, int size, struct fragment *fragment)\n+static void recount_diff(const char *line, size_t size,\n+\t\t\t struct fragment *fragment)\n {\n \tint oldlines = 0, newlines = 0, ret = 0;\n \n-\tif (size < 1) {\n+\tif (size == 0) {\n \t\twarning(\"recount: ignore empty hunk\");\n \t\treturn;\n \t}\n \n \tfor (;;) {\n-\t\tint len = linelen(line, size);\n-\t\tsize -= len;\n-\t\tline += len;\n+\t\tsize_t len = linelen(line, size);\n \n-\t\tif (size < 1)\n+\t\tif (size <= len)\n \t\t\tbreak;\n+\t\tsize -= len;\n+\t\tline += len;\n \n \t\tswitch (*line) {\n \t\tcase ' ': case '\\n':\n@@ -2086,7 +2079,7 @@ static void add_name_limit(struct apply_state *state,\n static int use_patch(struct apply_state *state, struct patch *p)\n {\n \tconst char *pathname = p->new_name ? p->new_name : p->old_name;\n-\tint i;\n+\tsize_t i;\n \n \t/* Paths outside are not touched regardless of \"--include\" */\n \tif (state->prefix && *state->prefix) {\n@@ -2172,9 +2165,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n+\t\t\tsize_t i;\n \t\t\tfor (i = 0; binhdr[i]; i++) {\n-\t\t\t\tint len = strlen(binhdr[i]);\n+\t\t\t\tsize_t len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n \t\t\t\t\tstate->linenr++;\n@@ -2384,8 +2377,9 @@ static void update_pre_post_images(struct image *preimage,\n \tif (postlen\n \t    ? postlen < new_buf - postimage->buf\n \t    : postimage->len < new_buf - postimage->buf)\n-\t\tBUG(\"caller miscounted postlen: asked %d, orig = %d, used = %d\",\n-\t\t    (int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));\n+\t\tBUG(\"caller miscounted postlen: asked %u, orig = %u, used = %u\",\n+\t\t    (unsigned int)postlen, (unsigned int)postimage->len,\n+\t\t    (unsigned int)(new_buf - postimage->buf));\n \n \t/* Fix the length of the whole thing */\n \tpostimage->len = new_buf - postimage->buf;\ndiff --git a/apply.h b/apply.h\nindex b9f18ce87d1..7e6b6eb5d2d 100644\n--- a/apply.h\n+++ b/apply.h\n@@ -165,12 +165,8 @@ int check_apply_state(struct apply_state *state, int force_apply);\n  *\n  * Returns -1 on failure, the length of the parsed header otherwise.\n  */\n-int parse_git_diff_header(struct strbuf *root,\n-\t\t\t  int *linenr,\n-\t\t\t  int p_value,\n-\t\t\t  const char *line,\n-\t\t\t  int len,\n-\t\t\t  unsigned int size,\n+int parse_git_diff_header(struct strbuf *root, int *linenr, int p_value,\n+\t\t\t  const char *line, size_t len, unsigned int size,\n \t\t\t  struct patch *patch);\n \n void release_patch(struct patch *patch);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex f8fad2946ef..6d91eb01157 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -352,12 +352,12 @@ static void write_global_extended_header(struct archiver_args *args)\n }\n \n static struct archiver **tar_filters;\n-static int nr_tar_filters;\n-static int alloc_tar_filters;\n+static size_t nr_tar_filters;\n+static size_t alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!strncmp(ar->name, name, len) && !ar->name[len])\n@@ -525,7 +525,7 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n+\tsize_t i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\ndiff --git a/archive.c b/archive.c\nindex 9aeaf2bd87d..2db9b0b56eb 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -275,7 +275,7 @@ int write_archive_entries(struct archiver_args *args,\n \tstruct strbuf path_in_archive = STRBUF_INIT;\n \tstruct strbuf content = STRBUF_INIT;\n \tstruct object_id fake_oid;\n-\tint i;\n+\tsize_t i;\n \n \toidcpy(&fake_oid, null_oid());\n \ndiff --git a/attr.c b/attr.c\nindex 1053dfcd4b6..acdd74775f6 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -180,16 +180,16 @@ static int attr_name_valid(const char *name, size_t namelen)\n \t * Attribute name cannot begin with '-' and must consist of\n \t * characters from [-A-Za-z0-9_.].\n \t */\n-\tif (namelen <= 0 || *name == '-')\n+\tif (namelen == 0 || *name == '-')\n \t\treturn 0;\n-\twhile (namelen--) {\n+\tdo {\n \t\tchar ch = *name++;\n \t\tif (! (ch == '-' || ch == '.' || ch == '_' ||\n \t\t       ('0' <= ch && ch <= '9') ||\n \t\t       ('a' <= ch && ch <= 'z') ||\n \t\t       ('A' <= ch && ch <= 'Z')) )\n \t\t\treturn 0;\n-\t}\n+\t} while (--namelen);\n \treturn 1;\n }\n \n@@ -515,7 +515,7 @@ static void check_vector_add(struct attr_check *c)\n \n static void check_vector_remove(struct attr_check *check)\n {\n-\tint i;\n+\tsize_t i;\n \n \tvector_lock();\n \n@@ -539,7 +539,7 @@ static void check_vector_remove(struct attr_check *check)\n /* Iterate through all attr_check instances and drop their stacks */\n static void drop_all_attr_stacks(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tvector_lock();\n \ndiff --git a/base85.c b/base85.c\nindex 5ca601ee14f..ad32ba1411a 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -37,14 +37,15 @@ static void prep_base85(void)\n \t}\n }\n \n-int decode_85(char *dst, const char *buffer, int len)\n+int decode_85(char *dst, const char *buffer, size_t len)\n {\n \tprep_base85();\n \n-\tsay2(\"decode 85 <%.*s>\", len / 4 * 5, buffer);\n+\tsay2(\"decode 85 <%.*s>\", (int)(len / 4 * 5), buffer);\n \twhile (len) {\n \t\tunsigned acc = 0;\n-\t\tint de, cnt = 4;\n+\t\tint de;\n+\t\tsize_t cnt = 4;\n \t\tunsigned char ch;\n \t\tdo {\n \t\t\tch = *buffer++;\n@@ -76,7 +77,7 @@ int decode_85(char *dst, const char *buffer, int len)\n \treturn 0;\n }\n \n-void encode_85(char *buf, const unsigned char *data, int bytes)\n+void encode_85(char *buf, const unsigned char *data, size_t bytes)\n {\n \tsay(\"encode 85\");\n \twhile (bytes) {\n@@ -90,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\t}\n \t\tsay1(\" %08x\", acc);\n \t\tfor (cnt = 4; cnt >= 0; cnt--) {\n-\t\t\tint val = acc % 85;\n+\t\t\tunsigned val = acc % 85;\n \t\t\tacc /= 85;\n \t\t\tbuf[cnt] = en85[val];\n \t\t}\ndiff --git a/bisect.c b/bisect.c\nindex ef5ee5a6436..618739689fc 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -218,7 +218,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n\n \tstruct commit_list *p;\n \tstruct commit_dist *array = xcalloc(nr, sizeof(*array));\n \tstruct strbuf buf = STRBUF_INIT;\n-\tint cnt, i;\n+\tsize_t cnt, i;\n \n \tfor (p = list, cnt = 0; p; p = p->next) {\n \t\tint distance;\n@@ -493,7 +493,7 @@ static void read_bisect_paths(struct strvec *array)\n static char *join_oid_array_hex(struct oid_array *array, char delim)\n {\n \tstruct strbuf joined_hexs = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < array->nr; i++) {\n \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\n@@ -653,7 +653,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,\n \tstruct setup_revision_opt opt = {\n \t\t.free_removed_argv_elements = 1,\n \t};\n-\tint i;\n+\tsize_t i;\n \n \trepo_init_revisions(r, revs, prefix);\n \trevs->abbrev = 0;\n@@ -771,7 +771,7 @@ static struct commit **get_bad_and_good_commits(struct repository *r,\n \t\t\t\t\t\tint *rev_nr)\n {\n \tstruct commit **rev;\n-\tint i, n = 0;\n+\tsize_t i, n = 0;\n \n \tALLOC_ARRAY(rev, 1 + good_revs.nr);\n \trev[n++] = get_commit_reference(r, current_bad_oid);\ndiff --git a/blame.c b/blame.c\nindex 8bfeaa1c63a..b050ba7f893 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -493,7 +493,7 @@ static void get_line_fingerprints(struct fingerprint *fingerprints,\n \t\t\t\t  const char *content, const int *line_starts,\n \t\t\t\t  long first_line, long line_count)\n {\n-\tint i;\n+\tlong i;\n \tconst char *linestart, *lineend;\n \n \tline_starts += first_line;\n@@ -1496,7 +1496,7 @@ static void split_overlap(struct blame_entry *split,\n \t\t\t  struct blame_origin *parent)\n {\n \tint chunk_end_lno;\n-\tint i;\n+\tunsigned int i;\n \tmemset(split, 0, sizeof(struct blame_entry [3]));\n \n \tfor (i = 0; i < 3; i++) {\n@@ -1583,7 +1583,7 @@ static void split_blame(struct blame_entry ***blamed,\n  */\n static void decref_split(struct blame_entry *split)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < 3; i++)\n \t\tblame_origin_decref(split[i].suspect);\n@@ -2001,7 +2001,7 @@ static void copy_split_if_better(struct blame_scoreboard *sb,\n \t\t\t\t struct blame_entry *best_so_far,\n \t\t\t\t struct blame_entry *potential)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tif (!potential[1].suspect)\n \t\treturn;\n@@ -2193,10 +2193,10 @@ struct blame_list {\n  * and prepare a list of entry and the best split.\n  */\n static struct blame_list *setup_blame_list(struct blame_entry *unblamed,\n-\t\t\t\t\t   int *num_ents_p)\n+\t\t\t\t\t   size_t *num_ents_p)\n {\n \tstruct blame_entry *e;\n-\tint num_ents, i;\n+\tsize_t num_ents, i;\n \tstruct blame_list *blame_list = NULL;\n \n \tfor (e = unblamed, num_ents = 0; e; e = e->next)\n@@ -2224,9 +2224,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t\tint opt)\n {\n \tstruct diff_options diff_opts;\n-\tint i, j;\n+\tsize_t i, j;\n \tstruct blame_list *blame_list;\n-\tint num_ents;\n+\tsize_t num_ents;\n \tstruct blame_entry *unblamed = target->suspects;\n \tstruct blame_entry *leftover = NULL;\n \n@@ -2645,7 +2645,7 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2708,7 +2708,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 80cebd27564..a08be63bc63 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -214,7 +214,7 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx)\n {\n \tstatic const unsigned char pad[64] = { 0x80 };\n \tunsigned int padlen[2];\n-\tint i;\n+\tsize_t i;\n \n \t/* Pad with a binary 1 (ie 0x80), then zeroes, then length */\n \tpadlen[0] = htonl((uint32_t)(ctx->size >> 29));\ndiff --git a/bloom.c b/bloom.c\nindex d0730525da5..d38064e257f 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -73,11 +73,11 @@ uint32_t murmur3_seeded(uint32_t seed, const char *data, size_t len)\n \tconst uint32_t r2 = 13;\n \tconst uint32_t m = 5;\n \tconst uint32_t n = 0xe6546b64;\n-\tint i;\n+\tsize_t i;\n \tuint32_t k1 = 0;\n \tconst char *tail;\n \n-\tint len4 = len / sizeof(uint32_t);\n+\tsize_t len4 = len / sizeof(uint32_t);\n \n \tuint32_t k;\n \tfor (i = 0; i < len4; i++) {\n@@ -127,7 +127,7 @@ void fill_bloom_key(const char *data,\n \t\t    struct bloom_key *key,\n \t\t    const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tconst uint32_t seed0 = 0x293ae76f;\n \tconst uint32_t seed1 = 0x7e646e2c;\n \tconst uint32_t hash0 = murmur3_seeded(seed0, data, len);\n@@ -147,7 +147,7 @@ void add_key_to_filter(const struct bloom_key *key,\n \t\t       struct bloom_filter *filter,\n \t\t       const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tfor (i = 0; i < settings->num_hashes; i++) {\n@@ -310,7 +310,7 @@ int bloom_filter_contains(const struct bloom_filter *filter,\n \t\t\t  const struct bloom_key *key,\n \t\t\t  const struct bloom_filter_settings *settings)\n {\n-\tint i;\n+\tuint32_t i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tif (!mod)\ndiff --git a/branch.c b/branch.c\nindex e5614b53b36..f8193de41be 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -375,7 +375,7 @@ static struct strmap current_checked_out_branches = STRMAP_INIT;\n \n static void prepare_checked_out_branches(void)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \tstruct worktree **worktrees;\n \n \tif (initialized_checked_out_branches)\n@@ -836,7 +836,7 @@ int replace_each_worktree_head_symref(const char *oldref, const char *newref,\n {\n \tint ret = 0;\n \tstruct worktree **worktrees = get_worktrees();\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; worktrees[i]; i++) {\n \t\tstruct ref_store *refs;\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 61dd386d109..124ecf1001c 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -40,7 +40,8 @@ struct update_callback_data {\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tunsigned int i;\n+\tint ret = 0;\n \n \tfor (i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 65b5b7db6de..b55962692a5 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1298,7 +1298,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (mapped_refs) {\n-\t\tint hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n+\t\tunsigned hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));\n \n \t\t/*\n \t\t * Now that we know what algorithm the remote side is using,\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 985a0445b78..bcf55081d1e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -292,7 +292,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \n static void add_remove_files(struct string_list *list)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < list->nr; i++) {\n \t\tstruct stat st;\n \t\tstruct string_list_item *p = &(list->items[i]);\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 39a890fc005..43da493eb4b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -906,7 +906,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < info->nr; i++) {\n \t\tstruct rev_cmdline_entry *e = info->rev + i;\n@@ -1230,7 +1230,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"the option '%s' requires '%s'\"), \"--anonymize-map\", \"--anonymize\");\n \n \tif (refspecs_list.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tfor (i = 0; i < refspecs_list.nr; i++)\n \t\t\trefspec_append(&refspecs, refspecs_list.items[i].string);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 7134683ab93..068c218ca61 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -860,7 +860,7 @@ static void end_packfile(void)\n \t\tstruct packed_git *new_p;\n \t\tstruct object_id cur_pack_oid;\n \t\tchar *idx_name;\n-\t\tint i;\n+\t\tunsigned long i;\n \t\tstruct branch *b;\n \t\tstruct tag *t;\n \ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex afe679368de..9758d067b73 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -239,7 +239,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \tref = fetch_pack(&args, fd, ref, sought, nr_sought,\n \t\t\t &shallow, pack_lockfiles_ptr, version);\n \tif (pack_lockfiles.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tprintf(\"lock %s\\n\", pack_lockfiles.items[0].string);\n \t\tfflush(stdout);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex a09606b4726..12d7a067d36 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1480,11 +1480,11 @@ static int add_oid(const char *refname UNUSED,\n static void add_negotiation_tips(struct git_transport_options *smart_options)\n {\n \tstruct oid_array *oids = xcalloc(1, sizeof(*oids));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < negotiation_tip.nr; i++) {\n \t\tconst char *s = negotiation_tip.items[i].string;\n-\t\tint old_nr;\n+\t\tsize_t old_nr;\n \t\tif (!has_glob_specials(s)) {\n \t\t\tstruct object_id oid;\n \t\t\tif (get_oid(s, &oid))\n@@ -1939,7 +1939,8 @@ static int fetch_finished(int result, struct strbuf *out,\n \n static int fetch_multiple(struct string_list *list, int max_children)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tstruct strvec argv = STRVEC_INIT;\n \n \tif (!append && write_fetch_head) {\ndiff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c\nindex 6aeac371488..ababcbef101 100644\n--- a/builtin/for-each-repo.c\n+++ b/builtin/for-each-repo.c\n@@ -30,7 +30,8 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)\n int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n {\n \tstatic const char *config_key = NULL;\n-\tint i, result = 0;\n+\tint result = 0;\n+\tsize_t i;\n \tconst struct string_list *values;\n \n \tconst struct option options[] = {\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex d207bd909b4..3b411735a58 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_object(struct object *obj)\n \n static void check_connectivity(void)\n {\n-\tint i, max;\n+\tunsigned int i, max;\n \n \t/* Traverse the pending reachable objects */\n \ttraverse_reachable();\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 02455fdcd73..511419ba417 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -68,7 +68,7 @@ static struct string_list pack_garbage = STRING_LIST_INIT_DUP;\n \n static void clean_pack_garbage(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < pack_garbage.nr; i++)\n \t\tunlink_or_warn(pack_garbage.items[i].string);\n \tstring_list_clear(&pack_garbage, 0);\n@@ -1288,7 +1288,8 @@ static int compare_tasks_by_selection(const void *a_, const void *b_)\n \n static int maintenance_run_tasks(struct maintenance_run_opts *opts)\n {\n-\tint i, found_selected = 0;\n+\tunsigned int i;\n+\tint found_selected = 0;\n \tint result = 0;\n \tstruct lock_file lk;\n \tstruct repository *r = the_repository;\n@@ -1367,7 +1368,7 @@ static void initialize_maintenance_strategy(void)\n \n static void initialize_task_config(int schedule)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf config_name = STRBUF_INIT;\n \tgc_config();\n \n@@ -1401,7 +1402,8 @@ static void initialize_task_config(int schedule)\n static int task_option_parse(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n-\tint i, num_selected = 0;\n+\tunsigned int i;\n+\tint num_selected = 0;\n \tstruct maintenance_task *task = NULL;\n \n \tBUG_ON_OPT_NEG(unset);\n@@ -1431,7 +1433,7 @@ static int task_option_parse(const struct option *opt,\n \n static int maintenance_run(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct maintenance_run_opts opts;\n \tstruct option builtin_maintenance_run_options[] = {\n \t\tOPT_BOOL(0, \"auto\", &opts.auto_flag,\n@@ -1810,8 +1812,9 @@ static int launchctl_list_contains_plist(const char *name, const char *cmd)\n \n static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule)\n {\n-\tint i, fd;\n-\tconst char *preamble, *repeat;\n+\tunsigned int i;\n+\tint fd;\n+\tconst char *preamble;\n \tconst char *frequency = get_frequency(schedule);\n \tchar *name = launchctl_service_name(frequency);\n \tchar *filename = launchctl_service_filename(name);\n@@ -1843,22 +1846,24 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit\n \n \tswitch (schedule) {\n \tcase SCHEDULE_HOURLY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Hour</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 23; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_DAILY:\n-\t\trepeat = \"<dict>\\n\"\n-\t\t\t \"<key>Day</key><integer>%d</integer>\\n\"\n-\t\t\t \"<key>Hour</key><integer>0</integer>\\n\"\n-\t\t\t \"<key>Minute</key><integer>0</integer>\\n\"\n-\t\t\t \"</dict>\\n\";\n \t\tfor (i = 1; i <= 6; i++)\n-\t\t\tstrbuf_addf(&plist, repeat, i);\n+\t\t\tstrbuf_addf(&plist,\n+\t\t\t\t    \"<dict>\\n\"\n+\t\t\t\t    \"<key>Day</key><integer>%u</integer>\\n\"\n+\t\t\t\t    \"<key>Hour</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"<key>Minute</key><integer>0</integer>\\n\"\n+\t\t\t\t    \"</dict>\\n\",\n+\t\t\t\t    i);\n \t\tbreak;\n \n \tcase SCHEDULE_WEEKLY:\n@@ -2553,7 +2558,7 @@ static void validate_scheduler(enum scheduler scheduler)\n static int update_background_schedule(const struct maintenance_start_opts *opts,\n \t\t\t\t      int enable)\n {\n-\tunsigned int i;\n+\tsize_t i;\n \tint result = 0;\n \tstruct lock_file lk;\n \tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex f7821c5fbba..75cc21f632e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -174,7 +174,7 @@ static void work_done(struct work_item *w)\n \n static void free_repos(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < repos_to_free_nr; i++) {\n \t\trepo_clear(repos_to_free[i]);\n@@ -409,7 +409,8 @@ static void run_pager(struct grep_opt *opt, const char *prefix)\n {\n \tstruct string_list *path_list = opt->output_priv;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint i, status;\n+\tsize_t i;\n+\tint status;\n \n \tfor (i = 0; i < path_list->nr; i++)\n \t\tstrvec_push(&child.args, path_list->items[i].string);\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 53f2812dfb1..fd227be20f1 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -124,7 +124,7 @@ static void list_config_help(enum show_config_type type)\n \tstruct string_list keys = STRING_LIST_INIT_DUP;\n \tstruct string_list keys_uniq = STRING_LIST_INIT_DUP;\n \tstruct string_list_item *item;\n-\tint i;\n+\tsize_t i;\n \n \tfor (p = config_name_list; *p; p++) {\n \t\tconst char *var = *p;\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 6648f2daef5..eb383e2fe75 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1726,7 +1726,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tunsigned char pack_hash[GIT_MAX_RAWSZ];\n \tunsigned foreign_nr = 1;\t/* zero is a \"good\" value, assume bad */\n \tint report_end_of_input = 0;\n-\tint hash_algo = 0;\n+\tunsigned hash_algo = 0;\n \n \t/*\n \t * index-pack never needs to fetch missing objects except when\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex dcaaf102eaf..6431c8855f4 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -167,17 +167,17 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)\n \treturn 1;\n }\n \n-void initialize_repository_version(int hash_algo, int reinit)\n+void initialize_repository_version(unsigned hash_algo, int reinit)\n {\n \tchar repo_version_string[10];\n-\tint repo_version = GIT_REPO_VERSION;\n+\tunsigned repo_version = GIT_REPO_VERSION;\n \n \tif (hash_algo != GIT_HASH_SHA1)\n \t\trepo_version = GIT_REPO_VERSION_READ;\n \n \t/* This forces creation of new config file */\n \txsnprintf(repo_version_string, sizeof(repo_version_string),\n-\t\t  \"%d\", repo_version);\n+\t\t  \"%u\", repo_version);\n \tgit_config_set(\"core.repositoryformatversion\", repo_version_string);\n \n \tif (hash_algo != GIT_HASH_SHA1)\n@@ -374,7 +374,7 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash\n \telse if (hash != GIT_HASH_UNKNOWN)\n \t\trepo_fmt->hash_algo = hash;\n \telse if (env) {\n-\t\tint env_algo = hash_algo_by_name(env);\n+\t\tunsigned env_algo = hash_algo_by_name(env);\n \t\tif (env_algo == GIT_HASH_UNKNOWN)\n \t\t\tdie(_(\"unknown hash algorithm '%s'\"), env);\n \t\trepo_fmt->hash_algo = env_algo;\n@@ -537,7 +537,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tunsigned int flags = 0;\n \tconst char *object_format = NULL;\n \tconst char *initial_branch = NULL;\n-\tint hash_algo = GIT_HASH_UNKNOWN;\n+\tunsigned hash_algo = GIT_HASH_UNKNOWN;\n \tconst struct option init_db_options[] = {\n \t\tOPT_STRING(0, \"template\", &template_dir, N_(\"template-directory\"),\n \t\t\t\tN_(\"directory from which templates will be used\")),\ndiff --git a/builtin/log.c b/builtin/log.c\nindex a70fba198f9..db640058328 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -179,7 +179,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n static void set_default_decoration_filter(struct decoration_filter *decoration_filter)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *value = NULL;\n \tstruct string_list *include = decoration_filter->include_ref_pattern;\n \tconst struct string_list *config_exclude =\n@@ -386,7 +386,7 @@ static struct itimerval early_output_timer;\n \n static void log_show_early(struct rev_info *revs, struct commit_list *list)\n {\n-\tint i = revs->early_output;\n+\tunsigned int i = revs->early_output;\n \tint show_header = 1;\n \tint no_free = revs->diffopt.no_free;\n \ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex a03b559ecaa..c369e95c30e 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -348,7 +348,8 @@ static void show_ru_info(struct index_state *istate)\n \tfor_each_string_list_item(item, istate->resolve_undo) {\n \t\tconst char *path = item->string;\n \t\tstruct resolve_undo_info *ui = item->util;\n-\t\tint i, len;\n+\t\tunsigned int i;\n+\t\tint len;\n \n \t\tlen = strlen(path);\n \t\tif (len < max_prefix_len)\n@@ -359,9 +360,8 @@ static void show_ru_info(struct index_state *istate)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n-\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev),\n-\t\t\t       i + 1);\n+\t\t\tprintf(\"%s%06o %s %u\\t\", tag_resolve_undo, ui->mode[i],\n+\t\t\t       find_unique_abbrev(&ui->oid[i], abbrev), i + 1);\n \t\t\twrite_name(path);\n \t\t}\n \t}\n@@ -385,7 +385,7 @@ static void construct_fullname(struct strbuf *out, const struct repository *repo\n \n static void show_files(struct repository *repo, struct dir_struct *dir)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf fullname = STRBUF_INIT;\n \n \t/* For cached/deleted files we don't need to even do the readdir */\n@@ -449,12 +449,12 @@ static void show_files(struct repository *repo, struct dir_struct *dir)\n \n skip_to_next_name:\n \t\t{\n-\t\t\tint j;\n-\t\t\tstruct cache_entry **cache = repo->index->cache;\n-\t\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n-\t\t\t\tif (strcmp(ce->name, cache[j]->name))\n-\t\t\t\t\tbreak;\n-\t\t\ti = j - 1; /* compensate for the for loop */\n+\t\tunsigned int j;\n+\t\tstruct cache_entry **cache = repo->index->cache;\n+\t\tfor (j = i + 1; j < repo->index->cache_nr; j++)\n+\t\t\tif (strcmp(ce->name, cache[j]->name))\n+\t\t\t\tbreak;\n+\t\ti = j - 1; /* compensate for the for loop */\n \t\t}\n \t}\n \n@@ -571,7 +571,7 @@ void overlay_tree_on_index(struct index_state *istate,\n \tstruct object_id oid;\n \tstruct pathspec pathspec;\n \tstruct cache_entry *last_stage0 = NULL;\n-\tint i;\n+\tunsigned int i;\n \tread_tree_fn_t fn = NULL;\n \tint err;\n \ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 65161773489..0e72f28b53a 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -87,7 +87,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tpacket_trace_identity(\"ls-remote\");\n \n \tif (argc > 1) {\n-\t\tint i;\n \t\tCALLOC_ARRAY(pattern, argc);\n \t\tfor (i = 1; i < argc; i++) {\n \t\t\tpattern[i - 1] = xstrfmt(\"*/%s\", argv[i]);\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 73509f651bd..053c9eecb30 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -172,7 +172,7 @@ static int split_maildir(const char *maildir, const char *dir,\n \tchar *file = NULL;\n \tFILE *f = NULL;\n \tint ret = -1;\n-\tint i;\n+\tsize_t i;\n \tstruct string_list list = STRING_LIST_INIT_DUP;\n \n \tlist.cmp = maildir_filename_cmp;\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex c923bbf2abb..e4655e8541c 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -29,7 +29,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tmmfile_t mmfs[3] = { 0 };\n \tmmbuffer_t result = { 0 };\n \txmparam_t xmp = { 0 };\n-\tint ret = 0, i = 0, to_stdout = 0;\n+\tint ret = 0, to_stdout = 0;\n+\tsize_t i = 0;\n \tint quiet = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"stdout\", &to_stdout, N_(\"send results to standard output\")),\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 0a3c10a0966..7b42e7440f8 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -186,7 +186,8 @@ static struct strategy *get_strategy(const char *name)\n \t\tmemset(&not_strategies, 0, sizeof(struct cmdnames));\n \t\tload_command_list(\"git-merge-\", &main_cmds, &other_cmds);\n \t\tfor (i = 0; i < main_cmds.cnt; i++) {\n-\t\t\tint j, found = 0;\n+\t\t\tsize_t j;\n+\t\t\tint found = 0;\n \t\t\tstruct cmdname *ent = main_cmds.names[i];\n \t\t\tfor (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)\n \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 97959bfaf9e..c5a9fe74448 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -653,7 +653,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tstrbuf_release(&sb);\n \t} else if (all) {\n-\t\tint i, max;\n+\t\tunsigned int i, max;\n \n \t\tmax = get_max_object_index();\n \t\tfor (i = 0; i < max; i++) {\n@@ -664,7 +664,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t  always, allow_undefined, data.name_only);\n \t\t}\n \t} else {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < revs.nr; i++)\n \t\t\tshow_name(revs.objects[i].item, revs.objects[i].name,\n \t\t\t\t  always, allow_undefined, data.name_only);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 74a167a180c..a939b89cd30 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1511,7 +1511,7 @@ static int want_object_in_pack(const struct object_id *oid,\n \tif (uri_protocols.nr) {\n \t\tstruct configured_exclusion *ex =\n \t\t\toidmap_get(&configured_exclusions, oid);\n-\t\tint i;\n+\t\tsize_t i;\n \t\tconst char *p;\n \n \t\tif (ex) {\n@@ -4084,7 +4084,7 @@ static void add_extra_kept_packs(const struct string_list *names)\n \n \tfor (p = get_all_packs(the_repository); p; p = p->next) {\n \t\tconst char *name = basename(p->pack_name);\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!p->pack_local)\n \t\t\tcontinue;\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex ecd49ca268f..0f6c827faca 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -51,9 +51,9 @@ static inline struct llist_item *llist_item_get(void)\n \t\tnew_item = free_nodes;\n \t\tfree_nodes = free_nodes->next;\n \t} else {\n-\t\tint i = 1;\n+\t\tsize_t i;\n \t\tALLOC_ARRAY(new_item, BLKSIZE);\n-\t\tfor (; i < BLKSIZE; i++)\n+\t\tfor (i = 1; i < BLKSIZE; i++)\n \t\t\tllist_item_put(&new_item[i]);\n \t}\n \treturn new_item;\n@@ -366,7 +366,7 @@ static int cmp_remaining_objects(const void *a, const void *b)\n static void sort_pack_list(struct pack_list **pl)\n {\n \tstruct pack_list **ary, *p;\n-\tint i;\n+\tsize_t i;\n \tsize_t n = pack_list_size(*pl);\n \n \tif (n < 2)\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex f840fbf1c7e..8fed7935e9a 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -10,7 +10,7 @@ static void flush_current_id(int patchlen, struct object_id *id, struct object_i\n \t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n }\n \n-static int remove_space(char *line)\n+static size_t remove_space(char *line)\n {\n \tchar *src = line;\n \tchar *dst = line;\n@@ -57,10 +57,12 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n-\t\t\t   struct strbuf *line_buf, int stable, int verbatim)\n+static size_t get_one_patchid(struct object_id *next_oid,\n+\t\t\t      struct object_id *result, struct strbuf *line_buf,\n+\t\t\t      int stable, int verbatim)\n {\n-\tint patchlen = 0, found_next = 0;\n+\tsize_t patchlen = 0;\n+\tint found_next = 0;\n \tint before = -1, after = -1;\n \tint diff_is_binary = 0;\n \tchar pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];\n@@ -72,7 +74,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n \twhile (strbuf_getwholeline(line_buf, stdin, '\\n') != EOF) {\n \t\tchar *line = line_buf->buf;\n \t\tconst char *p = line;\n-\t\tint len;\n+\t\tsize_t len;\n \n \t\t/* Possibly skip over the prefix added by \"log\" or \"format-patch\" */\n \t\tif (!skip_prefix(line, \"commit \", &p) &&\n@@ -173,7 +175,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,\n static void generate_id_list(int stable, int verbatim)\n {\n \tstruct object_id oid, n, result;\n-\tint patchlen;\n+\tsize_t patchlen;\n \tstruct strbuf line_buf = STRBUF_INIT;\n \n \toidclr(&oid);\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 1ab4de0005d..115b4bd8819 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -941,7 +941,7 @@ static int get_can_ff(struct object_id *orig_head,\n static int already_up_to_date(struct object_id *orig_head,\n \t\t\t      struct oid_array *merge_heads)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *ours;\n \n \tours = lookup_commit_reference(the_repository, orig_head);\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 3ce75417833..444939c70dc 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -85,13 +85,13 @@ static void debug_stage(const char *label, const struct cache_entry *ce,\n static int debug_merge(const struct cache_entry * const *stages,\n \t\t       struct unpack_trees_options *o)\n {\n-\tint i;\n+\tunsigned int i;\n \n-\tprintf(\"* %d-way merge\\n\", o->merge_size);\n+\tprintf(\"* %u-way merge\\n\", o->merge_size);\n \tdebug_stage(\"index\", stages[0], o);\n \tfor (i = 1; i <= o->merge_size; i++) {\n \t\tchar buf[24];\n-\t\txsnprintf(buf, sizeof(buf), \"ent#%d\", i);\n+\t\txsnprintf(buf, sizeof(buf), \"ent#%u\", i);\n \t\tdebug_stage(buf, stages[i], o);\n \t}\n \treturn 0;\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 6635f10d529..e12edfa84af 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1465,15 +1465,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (strategy_options.nr) {\n-\t\tint i;\n+\t\tsize_t j;\n \n \t\tif (!options.strategy)\n \t\t\toptions.strategy = \"ort\";\n \n \t\tstrbuf_reset(&buf);\n-\t\tfor (i = 0; i < strategy_options.nr; i++)\n+\t\tfor (j = 0; j < strategy_options.nr; j++)\n \t\t\tstrbuf_addf(&buf, \" --%s\",\n-\t\t\t\t    strategy_options.items[i].string);\n+\t\t\t\t    strategy_options.items[j].string);\n \t\toptions.strategy_opts = xstrdup(buf.buf);\n \t}\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex cd5c7a28eff..5ff421061c7 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -536,7 +536,7 @@ static void hmac_hash(unsigned char *out,\n \tunsigned char key[GIT_MAX_BLKSZ];\n \tunsigned char k_ipad[GIT_MAX_BLKSZ];\n \tunsigned char k_opad[GIT_MAX_BLKSZ];\n-\tint i;\n+\tsize_t i;\n \tgit_hash_ctx ctx;\n \n \t/* RFC 2104 2. (1) */\n@@ -1302,7 +1302,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)\n \tstruct oid_array extra = OID_ARRAY_INIT;\n \tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n \tuint32_t mask = 1 << (cmd->index % 32);\n-\tint i;\n+\tsize_t i;\n \n \ttrace_printf_key(&trace_shallow,\n \t\t\t \"shallow: update_shallow_ref %s\\n\", cmd->ref_name);\n@@ -2313,7 +2313,9 @@ static const char *unpack_with_sideband(struct shallow_info *si)\n \n static void prepare_shallow_update(struct shallow_info *si)\n {\n-\tint i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tsize_t i, j, k;\n+\tsize_t bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);\n+\tint l;\n \n \tALLOC_ARRAY(si->used_shallow, si->shallow->nr);\n \tassign_shallow_commits_to_refs(si, si->used_shallow, NULL);\n@@ -2322,8 +2324,8 @@ static void prepare_shallow_update(struct shallow_info *si)\n \tCALLOC_ARRAY(si->reachable, si->shallow->nr);\n \tCALLOC_ARRAY(si->shallow_ref, si->ref->nr);\n \n-\tfor (i = 0; i < si->nr_ours; i++)\n-\t\tsi->need_reachability_test[si->ours[i]] = 1;\n+\tfor (l = 0; l < si->nr_ours; l++)\n+\t\tsi->need_reachability_test[si->ours[l]] = 1;\n \n \tfor (i = 0; i < si->shallow->nr; i++) {\n \t\tif (!si->used_shallow[i])\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 729f6f3643a..93f8c9a2fad 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -161,7 +161,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tstruct remote *remote;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tconst char *name, *url;\n-\tint i;\n+\tsize_t i;\n \n \tstruct option options[] = {\n \t\tOPT_BOOL('f', \"fetch\", &fetch, N_(\"fetch the remote branches\")),\n@@ -862,7 +862,8 @@ static int rm(int argc, const char **argv, const char *prefix)\n \tstruct string_list branches = STRING_LIST_INIT_DUP;\n \tstruct string_list skipped = STRING_LIST_INIT_DUP;\n \tstruct branches_for_remote cb_data;\n-\tint i, result;\n+\tsize_t i;\n+\tint result;\n \n \tmemset(&cb_data, 0, sizeof(cb_data));\n \tcb_data.branches = &branches;\n@@ -1093,7 +1094,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \tstruct branch_info *branch_info = item->util;\n \tstruct string_list *merge = &branch_info->merge;\n \tint width = show_info->width + 4;\n-\tint i;\n+\tsize_t i;\n \n \tif (branch_info->rebase >= REBASE_TRUE && branch_info->merge.nr > 1) {\n \t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n@@ -1245,7 +1246,7 @@ static int show_all(void)\n \tresult = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tstring_list_sort(&list);\n \t\tfor (i = 0; i < list.nr; i++) {\n@@ -1370,7 +1371,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \n static int set_head(int argc, const char **argv, const char *prefix)\n {\n-\tint i, opt_a = 0, opt_d = 0, result = 0;\n+\tint opt_a = 0, opt_d = 0, result = 0;\n \tstruct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;\n \tchar *head_name = NULL;\n \n@@ -1394,6 +1395,7 @@ static int set_head(int argc, const char **argv, const char *prefix)\n \t\tif (!states.heads.nr)\n \t\t\tresult |= error(_(\"Cannot determine remote HEAD\"));\n \t\telse if (states.heads.nr > 1) {\n+\t\t\tsize_t i;\n \t\t\tresult |= error(_(\"Multiple remote HEAD branches. \"\n \t\t\t\t\t  \"Please choose one explicitly with:\"));\n \t\t\tfor (i = 0; i < states.heads.nr; i++)\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex f6493795318..7d2031506de 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -109,7 +109,7 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,\n \n \twhile ((e = readdir(dir)) != NULL) {\n \t\tsize_t len;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (!strip_suffix(e->d_name, \".pack\", &len))\n \t\t\tcontinue;\n@@ -218,7 +218,7 @@ static struct generated_pack_data *populate_pack_exts(const char *name)\n \tstruct stat statbuf;\n \tstruct strbuf path = STRBUF_INIT;\n \tstruct generated_pack_data *data = xcalloc(1, sizeof(*data));\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n \t\tstrbuf_reset(&path);\n@@ -744,7 +744,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)\n \tstruct pack_geometry *geometry = NULL;\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct tempfile *refs_snapshot = NULL;\n-\tint i, ext, ret;\n+\tsize_t i;\n+\tint ext, ret;\n \tFILE *out;\n \tint show_progress;\n \ndiff --git a/builtin/rerere.c b/builtin/rerere.c\nindex 94ffb8c21ab..7a0aeed3323 100644\n--- a/builtin/rerere.c\n+++ b/builtin/rerere.c\n@@ -51,7 +51,8 @@ static int diff_two(const char *file1, const char *label1,\n int cmd_rerere(int argc, const char **argv, const char *prefix)\n {\n \tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n-\tint i, autoupdate = -1, flags = 0;\n+\tsize_t i;\n+\tint autoupdate = -1, flags = 0;\n \n \tstruct option options[] = {\n \t\tOPT_SET_INT(0, \"rerere-autoupdate\", &autoupdate,\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 0697fa89de2..580fbfea217 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -50,7 +50,7 @@ static inline int is_merge(void)\n \n static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)\n {\n-\tint i, nr = 0;\n+\tunsigned int i, nr = 0;\n \tstruct tree_desc desc[2];\n \tstruct tree *tree;\n \tstruct unpack_trees_options opts;\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex e67999e5ebc..c235e67a099 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -707,7 +707,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \n \t\tif (!seen_end_of_options) {\n \t\t\tif (!strcmp(arg, \"--local-env-vars\")) {\n-\t\t\t\tint i;\n+\t\t\t\tsize_t i;\n \t\t\t\tfor (i = 0; local_repo_env[i]; i++)\n \t\t\t\t\tprintf(\"%s\\n\", local_repo_env[i]);\n \t\t\t\tcontinue;\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 8844f906557..d70610a3faf 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -49,7 +49,7 @@ static void print_error_files(struct string_list *files_list,\n \t\t\t      int *errs)\n {\n \tif (files_list->nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct strbuf err_msg = STRBUF_INIT;\n \n \t\tstrbuf_addstr(&err_msg, main_msg);\n@@ -258,7 +258,9 @@ static struct option builtin_rm_options[] = {\n int cmd_rm(int argc, const char **argv, const char *prefix)\n {\n \tstruct lock_file lock_file = LOCK_INIT;\n-\tint i, ret = 0;\n+\tint i;\n+\tunsigned int j;\n+\tint ret = 0;\n \tstruct pathspec pathspec;\n \tchar *seen;\n \n@@ -302,8 +304,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \tif (pathspec_needs_expanded_index(&the_index, &pathspec))\n \t\tensure_full_index(&the_index);\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n-\t\tconst struct cache_entry *ce = the_index.cache[i];\n+\tfor (j = 0; j < the_index.cache_nr; j++) {\n+\t\tconst struct cache_entry *ce = the_index.cache[j];\n \n \t\tif (!include_sparse &&\n \t\t    (ce_skip_worktree(ce) ||\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 358ac3e519a..470927ed4d3 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -109,9 +109,9 @@ static void name_parent(struct commit *commit, struct commit *parent)\n \t\t\t    commit_name->generation + 1);\n }\n \n-static int name_first_parent_chain(struct commit *c)\n+static size_t name_first_parent_chain(struct commit *c)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \twhile (c) {\n \t\tstruct commit *p;\n \t\tif (!commit_to_name(c))\n@@ -130,14 +130,12 @@ static int name_first_parent_chain(struct commit *c)\n \treturn i;\n }\n \n-static void name_commits(struct commit_list *list,\n-\t\t\t struct commit **rev,\n-\t\t\t char **ref_name,\n-\t\t\t int num_rev)\n+static void name_commits(struct commit_list *list, struct commit **rev,\n+\t\t\t char **ref_name, size_t num_rev)\n {\n \tstruct commit_list *cl;\n \tstruct commit *c;\n-\tint i;\n+\tsize_t i;\n \n \t/* First give names to the given heads */\n \tfor (cl = list; cl; cl = cl->next) {\n@@ -213,18 +211,17 @@ static int mark_seen(struct commit *commit, struct commit_list **seen_p)\n \treturn 0;\n }\n \n-static void join_revs(struct commit_list **list_p,\n-\t\t      struct commit_list **seen_p,\n-\t\t      int num_rev, int extra)\n+static void join_revs(struct commit_list **list_p, struct commit_list **seen_p,\n+\t\t      size_t num_rev, int extra)\n {\n-\tint all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n-\tint all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n+\tsize_t all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);\n+\tsize_t all_revs = all_mask & ~((1u << REV_SHIFT) - 1);\n \n \twhile (*list_p) {\n \t\tstruct commit_list *parents;\n \t\tint still_interesting = !!interesting(*list_p);\n \t\tstruct commit *commit = pop_commit(list_p);\n-\t\tint flags = commit->object.flags & all_mask;\n+\t\tunsigned int flags = commit->object.flags & all_mask;\n \n \t\tif (!still_interesting && extra <= 0)\n \t\t\tbreak;\n@@ -513,11 +510,10 @@ static int show_merge_base(struct commit_list *seen, int num_rev)\n \treturn exit_status;\n }\n \n-static int show_independent(struct commit **rev,\n-\t\t\t    int num_rev,\n+static int show_independent(struct commit **rev, size_t num_rev,\n \t\t\t    unsigned int *rev_mask)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < num_rev; i++) {\n \t\tstruct commit *commit = rev[i];\n@@ -625,7 +621,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \tchar *reflog_msg[MAX_REVS];\n \tstruct commit_list *list = NULL, *seen = NULL;\n \tunsigned int rev_mask[MAX_REVS];\n-\tint num_rev, i, extra = 0;\n+\tsize_t num_rev, i;\n+\tint extra = 0;\n \tint all_heads = 0, all_remotes = 0;\n \tint all_mask, all_revs;\n \tenum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -789,7 +786,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\t\t\tmsg);\n \t\t\tfree(logmsg);\n \n-\t\t\tnth_desc = xstrfmt(\"%s@{%d}\", *av, base+i);\n+\t\t\tnth_desc = xstrfmt(\"%s@{%lu}\", *av,\n+\t\t\t\t\t   (unsigned long)(base + i));\n \t\t\tappend_ref(nth_desc, &oid, 1);\n \t\t\tfree(nth_desc);\n \t\t}\ndiff --git a/builtin/show-index.c b/builtin/show-index.c\nindex 0e0b9fb95bc..608d0908c98 100644\n--- a/builtin/show-index.c\n+++ b/builtin/show-index.c\n@@ -10,13 +10,13 @@ static const char *const show_index_usage[] = {\n \n int cmd_show_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n+\tunsigned int i;\n \tunsigned nr;\n \tunsigned int version;\n \tstatic unsigned int top_index[256];\n \tunsigned hashsz;\n \tconst char *hash_name = NULL;\n-\tint hash_algo;\n+\tunsigned hash_algo;\n \tconst struct option show_index_options[] = {\n \t\tOPT_STRING(0, \"object-format\", &hash_name, N_(\"hash-algorithm\"),\n \t\t\t   N_(\"specify the hash algorithm to use\")),\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex c3738154918..89b86d933af 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -78,7 +78,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (pl.use_cone_patterns) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tstruct pattern_entry *pe;\n \t\tstruct hashmap_iter iter;\n \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n@@ -106,7 +106,8 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \n static void clean_tracked_sparse_directories(struct repository *r)\n {\n-\tint i, was_full = 0;\n+\tunsigned int i;\n+\tint was_full = 0;\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t pathlen;\n \tstruct string_list_item *item;\n@@ -264,7 +265,7 @@ static char *escaped_pattern(char *pattern)\n \n static void write_cone_to_file(FILE *fp, struct pattern_list *pl)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct pattern_entry *pe;\n \tstruct hashmap_iter iter;\n \tstruct string_list sl = STRING_LIST_INIT_DUP;\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 3a4f9fd566d..855076a287e 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -853,7 +853,7 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op\n \tstruct tree *tree[ARRAY_SIZE(oid)];\n \tstruct tree_desc tree_desc[ARRAY_SIZE(oid)];\n \tstruct unpack_trees_options unpack_tree_opt = { 0 };\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(oid); i++) {\n \t\ttree[i] = parse_tree_indirect(oid[i]);\n@@ -1521,7 +1521,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \n \trepo_read_index_preload(the_repository, NULL, 0);\n \tif (!include_untracked && ps->nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 4c173d8b37a..664edde6517 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -185,7 +185,8 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tunsigned int i;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\n@@ -251,7 +252,7 @@ static char *get_up_path(const char *path)\n \tint i;\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tfor (i = count_slashes(path); i; i--)\n+\tfor (i = count_slashes(path); i > 0; i--)\n \t\tstrbuf_addstr(&sb, \"../\");\n \n \t/*\n@@ -3212,7 +3213,7 @@ static void die_on_index_match(const char *path, int force)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (ps.nr) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tchar *ps_matched = xcalloc(ps.nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 43789b8ef29..e337ca4129e 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -571,7 +571,7 @@ static void unpack_one(unsigned nr)\n \n static void unpack_all(void)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n \n \tnr_objects = ntohl(hdr->hdr_entries);\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex a84e7b47a20..ded6a67a07f 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -393,7 +393,7 @@ static void update_refs_stdin(void)\n \tstruct strbuf input = STRBUF_INIT, err = STRBUF_INIT;\n \tenum update_refs_state state = UPDATE_REFS_OPEN;\n \tstruct ref_transaction *transaction;\n-\tint i, j;\n+\tsize_t i;\n \n \ttransaction = ref_transaction_begin(&err);\n \tif (!transaction)\n@@ -435,7 +435,7 @@ static void update_refs_stdin(void)\n \t\t * error in case there is an early EOF to let the command\n \t\t * handle missing arguments with a proper error message.\n \t\t */\n-\t\tfor (j = 1; line_termination == '\\0' && j < cmd->args; j++)\n+\t\tfor (i = 1; line_termination == '\\0' && i < cmd->args; i++)\n \t\t\tif (strbuf_appendwholeline(&input, stdin, line_termination))\n \t\t\t\tbreak;\n \ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 254283aa6f5..0f05fa7df20 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -160,7 +160,7 @@ static int prune_cmp(const void *a, const void *b)\n \n static void prune_dups(struct string_list *l)\n {\n-\tint i;\n+\tsize_t i;\n \n \tQSORT(l->items, l->nr, prune_cmp);\n \tfor (i = 1; i < l->nr; i++) {\n@@ -785,7 +785,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \n static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; wt[i]; i++) {\n \t\tint sha1_len;\n@@ -925,7 +925,8 @@ static void validate_no_submodules(const struct worktree *wt)\n {\n \tstruct index_state istate = INDEX_STATE_INIT(the_repository);\n \tstruct strbuf path = STRBUF_INIT;\n-\tint i, found_submodules = 0;\n+\tunsigned int i;\n+\tint found_submodules = 0;\n \n \tif (is_directory(worktree_git_path(wt, \"modules\"))) {\n \t\t/*\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 855b68ec23b..6bd0a15b671 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -48,7 +48,7 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n {\n \tunsigned char hash[GIT_MAX_RAWSZ];\n \tstruct strbuf packname = STRBUF_INIT;\n-\tint i;\n+\tuint32_t i;\n \n \tif (!state->f)\n \t\treturn;\n@@ -121,7 +121,7 @@ static void flush_batch_fsync(void)\n \n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n-\tint i;\n+\tuint32_t i;\n \n \t/* The object may already exist in the repository */\n \tif (has_object_file(oid))\ndiff --git a/bundle.c b/bundle.c\nindex 6ab6cd7378d..cc3c820de67 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -41,7 +41,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n {\n \tconst char *arg;\n \tif (skip_prefix(capability, \"object-format=\", &arg)) {\n-\t\tint algo = hash_algo_by_name(arg);\n+\t\tunsigned algo = hash_algo_by_name(arg);\n \t\tif (algo == GIT_HASH_UNKNOWN)\n \t\t\treturn error(_(\"unrecognized bundle hash algorithm: %s\"), arg);\n \t\theader->hash_algo = &hash_algos[algo];\n@@ -56,7 +56,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n \n static int parse_bundle_signature(struct bundle_header *header, const char *line)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n \t\tif (!strcmp(line, bundle_sigs[i].signature)) {\n@@ -163,7 +163,7 @@ int is_bundle(const char *path, int quiet)\n \n static int list_refs(struct string_list *r, int argc, const char **argv)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < r->nr; i++) {\n \t\tstruct object_id *oid;\n@@ -212,7 +212,8 @@ int verify_bundle(struct repository *r,\n \t * to be verbose about the errors\n \t */\n \tstruct string_list *p = &header->prerequisites;\n-\tint i, ret = 0;\n+\tsize_t i;\n+\tint ret = 0;\n \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n \tstruct string_list_iterator iter = {\n \t\t.list = p,\n@@ -316,7 +317,7 @@ out:\n static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n {\n \tstruct child_process pack_objects = CHILD_PROCESS_INIT;\n-\tint i;\n+\tunsigned int i;\n \n \tstrvec_pushl(&pack_objects.args,\n \t\t     \"pack-objects\",\n@@ -370,7 +371,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n  */\n static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n {\n-\tint i;\n+\tunsigned int i;\n \tint ref_count = 0;\n \n \tfor (i = 0; i < revs->pending.nr; i++) {\n@@ -495,7 +496,7 @@ int create_bundle(struct repository *r, const char *path,\n \tstruct rev_info revs, revs_copy;\n \tint min_version = 2;\n \tstruct bundle_prerequisites_info bpi;\n-\tint i;\n+\tunsigned int i;\n \n \t/* init revs to list objects for pack-objects later */\n \tsave_commit_buffer = 0;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 88c2c04f87f..5b03a036fbb 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -694,7 +694,7 @@ struct tree* write_in_core_index_as_tree(struct repository *repo) {\n \n \tret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);\n \tif (ret == WRITE_TREE_UNMERGED_INDEX) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tbug(\"there are unmerged index entries:\");\n \t\tfor (i = 0; i < index_state->cache_nr; i++) {\n \t\t\tconst struct cache_entry *ce = index_state->cache[i];\n@@ -879,7 +879,8 @@ static int verify_one(struct repository *r,\n \t\t      struct cache_tree *it,\n \t\t      struct strbuf *path)\n {\n-\tint i, pos, len = path->len;\n+\tint i, pos;\n+\tsize_t len = path->len;\n \tstruct strbuf tree_buf = STRBUF_INIT;\n \tstruct object_id new_oid;\n \n@@ -952,8 +953,9 @@ static int verify_one(struct repository *r,\n \t\t\t &new_oid);\n \tif (!oideq(&new_oid, &it->oid))\n \t\tBUG(\"cache-tree for path %.*s does not match. \"\n-\t\t    \"Expected %s got %s\", len, path->buf,\n-\t\t    oid_to_hex(&new_oid), oid_to_hex(&it->oid));\n+\t\t    \"Expected %s got %s\",\n+\t\t    (int)len, path->buf, oid_to_hex(&new_oid),\n+\t\t    oid_to_hex(&it->oid));\n \tstrbuf_setlen(path, len);\n \tstrbuf_release(&tree_buf);\n \treturn 0;\ndiff --git a/cache.h b/cache.h\nindex 12789903e88..bbfd0ac8255 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -649,9 +649,9 @@ int path_inside_repo(const char *prefix, const char *path);\n #define INIT_DB_EXIST_OK 0x0002\n \n int init_db(const char *git_dir, const char *real_git_dir,\n-\t    const char *template_dir, int hash_algo,\n+\t    const char *template_dir, int hash,\n \t    const char *initial_branch, unsigned int flags);\n-void initialize_repository_version(int hash_algo, int reinit);\n+void initialize_repository_version(unsigned int hash, int reinit);\n \n void sanitize_stdfds(void);\n int daemonize(void);\n@@ -1132,7 +1132,7 @@ struct repository_format {\n \tchar *partial_clone; /* value of extensions.partialclone */\n \tint worktree_config;\n \tint is_bare;\n-\tint hash_algo;\n+\tunsigned hash_algo;\n \tint sparse_index;\n \tchar *work_tree;\n \tstruct string_list unknown_extensions;\n@@ -1212,7 +1212,8 @@ void check_repository_format(struct repository_format *fmt);\n  */\n const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);\n #define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)\n-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);\n+unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n+\t\t\t\t       const struct object_id *oid, int len);\n #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)\n \n /* set default permissions by passing mode arguments to open(2) */\n@@ -1618,7 +1619,8 @@ int base_name_compare(const char *name1, size_t len1, int mode1,\n int df_name_compare(const char *name1, size_t len1, int mode1,\n \t\t    const char *name2, size_t len2, int mode2);\n int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);\n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2);\n \n void *read_object_with_reference(struct repository *r,\n \t\t\t\t const struct object_id *oid,\n@@ -1828,8 +1830,8 @@ extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\n-int decode_85(char *dst, const char *line, int linelen);\n-void encode_85(char *buf, const unsigned char *data, int bytes);\n+int decode_85(char *dst, const char *line, size_t linelen);\n+void encode_85(char *buf, const unsigned char *data, size_t bytes);\n \n /* pkt-line.c */\n void packet_trace_identity(const char *prog);\ndiff --git a/chunk-format.c b/chunk-format.c\nindex 0275b74a895..6981c2afd57 100644\n--- a/chunk-format.c\n+++ b/chunk-format.c\n@@ -58,7 +58,8 @@ void add_chunk(struct chunkfile *cf,\n \n int write_chunkfile(struct chunkfile *cf, void *data)\n {\n-\tint i, result = 0;\n+\tsize_t i;\n+\tint result = 0;\n \tuint64_t cur_offset = hashfile_total(cf->f);\n \n \ttrace2_region_enter(\"chunkfile\", \"write\", the_repository);\n@@ -101,7 +102,7 @@ int read_table_of_contents(struct chunkfile *cf,\n \t\t\t   uint64_t toc_offset,\n \t\t\t   int toc_length)\n {\n-\tint i;\n+\tsize_t i;\n \tuint32_t chunk_id;\n \tconst unsigned char *table_of_contents = mfile + toc_offset;\n \n@@ -172,7 +173,7 @@ int read_chunk(struct chunkfile *cf,\n \t       chunk_read_fn fn,\n \t       void *data)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < cf->chunks_nr; i++) {\n \t\tif (cf->chunks[i].id == chunk_id)\ndiff --git a/color.c b/color.c\nindex f05d8a81d72..e3e1d3a04a6 100644\n--- a/color.c\n+++ b/color.c\n@@ -54,7 +54,7 @@ struct color {\n  * \"word\" is a buffer of length \"len\"; does it match the NUL-terminated\n  * \"match\" exactly?\n  */\n-static int match_word(const char *word, int len, const char *match)\n+static int match_word(const char *word, size_t len, const char *match)\n {\n \treturn !strncasecmp(word, match, len) && !match[len];\n }\n@@ -73,15 +73,15 @@ static int get_hex_color(const char *in, unsigned char *out)\n  * If an ANSI color is recognized in \"name\", fill \"out\" and return 0.\n  * Otherwise, leave out unchanged and return -1.\n  */\n-static int parse_ansi_color(struct color *out, const char *name, int len)\n+static int parse_ansi_color(struct color *out, const char *name, size_t len)\n {\n \t/* Positions in array must match ANSI color codes */\n \tstatic const char * const color_names[] = {\n \t\t\"black\", \"red\", \"green\", \"yellow\",\n \t\t\"blue\", \"magenta\", \"cyan\", \"white\"\n \t};\n-\tint i;\n-\tint color_offset = COLOR_FOREGROUND_ANSI;\n+\tunsigned int i;\n+\tunsigned int color_offset = COLOR_FOREGROUND_ANSI;\n \n \tif (match_word(name, len, \"default\")) {\n \t\t/*\n@@ -119,7 +119,7 @@ static int parse_ansi_color(struct color *out, const char *name, int len)\n \treturn -1;\n }\n \n-static int parse_color(struct color *out, const char *name, int len)\n+static int parse_color(struct color *out, const char *name, size_t len)\n {\n \tchar *end;\n \tlong val;\n@@ -195,7 +195,7 @@ static int parse_attr(const char *name, size_t len)\n #undef ATTR\n \t};\n \tint negate = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (skip_prefix_mem(name, len, \"no\", &name, &len)) {\n \t\tskip_prefix_mem(name, len, \"-\", &name, &len);\n@@ -219,7 +219,8 @@ int color_parse(const char *value, char *dst)\n  * already have the ANSI escape code in it. \"out\" should have enough\n  * space in it to fit any color.\n  */\n-static char *color_output(char *out, int len, const struct color *c, int background)\n+static char *color_output(char *out, size_t len, const struct color *c,\n+\t\t\t  int background)\n {\n \tint offset = 0;\n \n@@ -250,17 +251,17 @@ static int color_empty(const struct color *c)\n \treturn c->type <= COLOR_NORMAL;\n }\n \n-int color_parse_mem(const char *value, int value_len, char *dst)\n+int color_parse_mem(const char *value, size_t value_len, char *dst)\n {\n \tconst char *ptr = value;\n-\tint len = value_len;\n+\tsize_t len = value_len;\n \tchar *end = dst + COLOR_MAXLEN;\n-\tunsigned int has_reset = 0;\n+\tint has_reset = 0;\n \tunsigned int attr = 0;\n \tstruct color fg = { COLOR_UNSPECIFIED };\n \tstruct color bg = { COLOR_UNSPECIFIED };\n \n-\twhile (len > 0 && isspace(*ptr)) {\n+\twhile (len && isspace(*ptr)) {\n \t\tptr++;\n \t\tlen--;\n \t}\n@@ -271,10 +272,11 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t}\n \n \t/* [reset] [fg [bg]] [attr]... */\n-\twhile (len > 0) {\n+\twhile (len) {\n \t\tconst char *word = ptr;\n \t\tstruct color c = { COLOR_UNSPECIFIED };\n-\t\tint val, wordlen = 0;\n+\t\tint val;\n+\t\tsize_t wordlen = 0;\n \n \t\twhile (len > 0 && !isspace(word[wordlen])) {\n \t\t\twordlen++;\n@@ -319,7 +321,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \n \tif (has_reset || attr || !color_empty(&fg) || !color_empty(&bg)) {\n \t\tint sep = 0;\n-\t\tint i;\n+\t\tunsigned int i;\n \n \t\tOUT('\\033');\n \t\tOUT('[');\n@@ -334,7 +336,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \t\t\tattr &= ~bit;\n \t\t\tif (sep++)\n \t\t\t\tOUT(';');\n-\t\t\tdst += xsnprintf(dst, end - dst, \"%d\", i);\n+\t\t\tdst += xsnprintf(dst, end - dst, \"%u\", i);\n \t\t}\n \t\tif (!color_empty(&fg)) {\n \t\t\tif (sep++)\n@@ -351,7 +353,7 @@ int color_parse_mem(const char *value, int value_len, char *dst)\n \tOUT(0);\n \treturn 0;\n bad:\n-\treturn error(_(\"invalid color value: %.*s\"), value_len, value);\n+\treturn error(_(\"invalid color value: %.*s\"), (int)value_len, value);\n #undef OUT\n }\n \ndiff --git a/color.h b/color.h\nindex cfc8f841b23..35c0cf09d08 100644\n--- a/color.h\n+++ b/color.h\n@@ -119,7 +119,7 @@ int want_color_fd(int fd, int var);\n  * name (\"red\"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.\n  */\n int color_parse(const char *value, char *dst);\n-int color_parse_mem(const char *value, int len, char *dst);\n+int color_parse_mem(const char *value, size_t len, char *dst);\n \n /*\n  * Output the formatted string in the specified color (and then reset to normal\ndiff --git a/column.c b/column.c\nindex fbf88639aae..01db21d535c 100644\n--- a/column.c\n+++ b/column.c\n@@ -32,7 +32,7 @@ static int item_length(const char *s)\n  */\n static void layout(struct column_data *data, int *width)\n {\n-\tint i;\n+\tsize_t i;\n \n \t*width = 0;\n \tfor (i = 0; i < data->list->nr; i++)\n@@ -101,7 +101,7 @@ static void shrink_columns(struct column_data *data)\n static void display_plain(const struct string_list *list,\n \t\t\t  const char *indent, const char *nl)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++)\n \t\tprintf(\"%s%s%s\", indent, list->items[i].string, nl);\n@@ -146,7 +146,8 @@ static void display_table(const struct string_list *list,\n \t\t\t  const struct column_options *opts)\n {\n \tstruct column_data data;\n-\tint x, y, i, initial_width;\n+\tint x, y, initial_width;\n+\tsize_t i;\n \tchar *empty_cell;\n \n \tmemset(&data, 0, sizeof(data));\n@@ -240,7 +241,7 @@ static int parse_option(const char *arg, int len, unsigned int *colopts,\n \t\t{ \"row\",    COL_ROW,      COL_LAYOUT_MASK },\n \t\t{ \"dense\",  COL_DENSE,    0 },\n \t};\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < ARRAY_SIZE(opts); i++) {\n \t\tint set = 1, arg_len = len, name_len;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 1a39b5dde09..ae0073472bb 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -30,8 +30,8 @@ static int filename_changed(char status)\n \n static struct combine_diff_path *intersect_paths(\n \tstruct combine_diff_path *curr,\n-\tint n,\n-\tint num_parent,\n+\tsize_t n,\n+\tsize_t num_parent,\n \tint combined_all_paths)\n {\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n@@ -40,7 +40,7 @@ static struct combine_diff_path *intersect_paths(\n \n \tif (!n) {\n \t\tfor (i = 0; i < q->nr; i++) {\n-\t\t\tint len;\n+\t\t\tsize_t len;\n \t\t\tconst char *path;\n \t\t\tif (diff_unmodified_pair(q->queue[i]))\n \t\t\t\tcontinue;\n@@ -251,7 +251,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \t/* At this point, baseend and newend point to the end of each lists */\n \ti--;\n \tj--;\n-\twhile (i != 0 || j != 0) {\n+\twhile (i > 0 || j > 0) {\n \t\tif (directions[i][j] == MATCH) {\n \t\t\tbaseend->parent_map |= 1<<parent;\n \t\t\tbaseend = baseend->prev;\n@@ -836,14 +836,13 @@ static void dump_sline(struct sline *sline, const char *line_prefix,\n \t\tprintf(\"%s\\n\", c_reset);\n \t\twhile (lno < hunk_end) {\n \t\t\tstruct lline *ll;\n-\t\t\tint j;\n \t\t\tunsigned long p_mask;\n \t\t\tstruct sline *sl = &sline[lno++];\n \t\t\tll = (sl->flag & no_pre_delete) ? NULL : sl->lost;\n \t\t\twhile (ll) {\n \t\t\t\tprintf(\"%s%s\", line_prefix, c_old);\n-\t\t\t\tfor (j = 0; j < num_parent; j++) {\n-\t\t\t\t\tif (ll->parent_map & (1UL<<j))\n+\t\t\t\tfor (i = 0; i < num_parent; i++) {\n+\t\t\t\t\tif (ll->parent_map & (1UL<<i))\n \t\t\t\t\t\tputchar('-');\n \t\t\t\t\telse\n \t\t\t\t\t\tputchar(' ');\n@@ -866,7 +865,7 @@ static void dump_sline(struct sline *sline, const char *line_prefix,\n \t\t\t}\n \t\t\telse\n \t\t\t\tfputs(c_new, stdout);\n-\t\t\tfor (j = 0; j < num_parent; j++) {\n+\t\t\tfor (i = 0; i < num_parent; i++) {\n \t\t\t\tif (p_mask & sl->flag)\n \t\t\t\t\tputchar('+');\n \t\t\t\telse\n@@ -1383,7 +1382,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,\n \tint combined_all_paths)\n {\n \tstruct combine_diff_path *paths = NULL;\n-\tint i, num_parent = parents->nr;\n+\tsize_t i, num_parent = parents->nr;\n \n \tint output_format = opt->output_format;\n \tconst char *orderfile = opt->orderfile;\n@@ -1431,7 +1430,7 @@ static struct combine_diff_path *find_paths_multitree(\n \tconst struct object_id *oid, const struct oid_array *parents,\n \tstruct diff_options *opt)\n {\n-\tint i, nparent = parents->nr;\n+\tsize_t i, nparent = parents->nr;\n \tconst struct object_id **parents_oid;\n \tstruct combine_diff_path paths_head;\n \tstruct strbuf base;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex c11b59f28b3..9683618d3ef 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -501,7 +501,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct stat st;\n \tstruct object_id *oids;\n-\tint i = 0, valid = 1, count;\n+\tint i, valid = 1, count;\n \tchar *chain_name = get_commit_graph_chain_filename(odb);\n \tFILE *fp;\n \tint stat_res;\n@@ -1045,7 +1045,8 @@ static int write_graph_chunk_fanout(struct hashfile *f,\n \t\t\t\t    void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, count = 0;\n+\tunsigned int i;\n+\tuint32_t count = 0;\n \tstruct commit **list = ctx->commits.list;\n \n \t/*\n@@ -1195,7 +1196,7 @@ static int write_graph_chunk_generation_data(struct hashfile *f,\n \t\t\t\t\t     void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i, num_generation_data_overflows = 0;\n+\tsize_t i, num_generation_data_overflows = 0;\n \n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n@@ -1219,7 +1220,7 @@ static int write_graph_chunk_generation_data_overflow(struct hashfile *f,\n \t\t\t\t\t\t      void *data)\n {\n \tstruct write_commit_graph_context *ctx = data;\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ctx->commits.nr; i++) {\n \t\tstruct commit *c = ctx->commits.list[i];\n \t\ttimestamp_t offset = commit_graph_data_at(c)->generation - c->date;\n@@ -1390,7 +1391,7 @@ static void add_missing_parents(struct write_commit_graph_context *ctx, struct c\n \n static void close_reachable(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit *commit;\n \tenum commit_graph_split_flags flags = ctx->opts ?\n \t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n@@ -1448,7 +1449,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n static void compute_topological_levels(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1501,7 +1502,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n \n static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct commit_list *list = NULL;\n \n \tif (ctx->report_progress)\n@@ -1582,10 +1583,10 @@ static void trace2_bloom_filter_write_statistics(struct write_commit_graph_conte\n \n static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct progress *progress = NULL;\n \tstruct commit **sorted_commits;\n-\tint max_new_filters;\n+\tsize_t max_new_filters;\n \n \tinit_bloom_filters();\n \ndiff --git a/commit-reach.c b/commit-reach.c\nindex 2e33c599a82..9220c5753cf 100644\n--- a/commit-reach.c\n+++ b/commit-reach.c\n@@ -722,7 +722,8 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\t timestamp_t min_generation)\n {\n \tstruct commit **list = NULL;\n-\tint i;\n+\tunsigned int i;\n+\tint j;\n \tint nr_commits;\n \tint result = 1;\n \n@@ -759,12 +760,12 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \n \tQSORT(list, nr_commits, compare_commits_by_gen);\n \n-\tfor (i = 0; i < nr_commits; i++) {\n+\tfor (j = 0; j < nr_commits; j++) {\n \t\t/* DFS from list[i] */\n \t\tstruct commit_list *stack = NULL;\n \n-\t\tlist[i]->object.flags |= assign_flag;\n-\t\tcommit_list_insert(list[i], &stack);\n+\t\tlist[j]->object.flags |= assign_flag;\n+\t\tcommit_list_insert(list[j], &stack);\n \n \t\twhile (stack) {\n \t\t\tstruct commit_list *parent;\n@@ -797,7 +798,7 @@ int can_all_from_reach_with_flag(struct object_array *from,\n \t\t\t\tpop_commit(&stack);\n \t\t}\n \n-\t\tif (!(list[i]->object.flags & (with_flag | RESULT))) {\n+\t\tif (!(list[j]->object.flags & (with_flag | RESULT))) {\n \t\t\tresult = 0;\n \t\t\tgoto cleanup;\n \t\t}\ndiff --git a/commit.c b/commit.c\nindex e433c33bb01..fde358d75ce 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -423,8 +423,8 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b\n \tstruct object_id parent;\n \tstruct commit_list **pptr;\n \tstruct commit_graft *graft;\n-\tconst int tree_entry_len = the_hash_algo->hexsz + 5;\n-\tconst int parent_entry_len = the_hash_algo->hexsz + 7;\n+\tconst size_t tree_entry_len = the_hash_algo->hexsz + 5;\n+\tconst size_t parent_entry_len = the_hash_algo->hexsz + 7;\n \tstruct tree *tree;\n \n \tif (item->object.parsed)\n@@ -1168,10 +1168,10 @@ int remove_signature(struct strbuf *buf)\n \t\tif (in_signature && line[0] == ' ')\n \t\t\tsigp->end = next;\n \t\telse if (starts_with(line, \"gpgsig\")) {\n-\t\t\tint i;\n-\t\t\tfor (i = 1; i < GIT_HASH_NALGOS; i++) {\n+\t\t\tunsigned int j;\n+\t\t\tfor (j = 1; j < GIT_HASH_NALGOS; j++) {\n \t\t\t\tconst char *p;\n-\t\t\t\tif (skip_prefix(line, gpg_sig_headers[i], &p) &&\n+\t\t\t\tif (skip_prefix(line, gpg_sig_headers[j], &p) &&\n \t\t\t\t    *p == ' ') {\n \t\t\t\t\tsigp->start = line;\n \t\t\t\t\tsigp->end = next;\ndiff --git a/compat/compiler.h b/compat/compiler.h\nindex 10dbb65937d..33d51f461c9 100644\n--- a/compat/compiler.h\n+++ b/compat/compiler.h\n@@ -10,7 +10,8 @@\n \n static inline void get_compiler_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n+\n #ifdef __clang__\n \tstrbuf_addf(info, \"clang: %s\\n\", __clang_version__);\n #elif defined(__GNUC__)\n@@ -18,8 +19,8 @@ static inline void get_compiler_info(struct strbuf *info)\n #endif\n \n #ifdef _MSC_VER\n-\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\",\n-\t\t    _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);\n+\tstrbuf_addf(info, \"MSVC version: %02d.%02d.%05d\\n\", _MSC_VER / 100,\n+\t\t    _MSC_VER % 100, _MSC_FULL_VER % 100000);\n #endif\n \n \tif (len == info->len)\n@@ -28,7 +29,7 @@ static inline void get_compiler_info(struct strbuf *info)\n \n static inline void get_libc_info(struct strbuf *info)\n {\n-\tint len = info->len;\n+\tsize_t len = info->len;\n \n #ifdef __GLIBC__\n \tstrbuf_addf(info, \"glibc: %s\\n\", gnu_get_libc_version());\ndiff --git a/compat/strcasestr.c b/compat/strcasestr.c\nindex 26896deca64..a5e69e06ba7 100644\n--- a/compat/strcasestr.c\n+++ b/compat/strcasestr.c\n@@ -2,16 +2,16 @@\n \n char *gitstrcasestr(const char *haystack, const char *needle)\n {\n-\tint nlen = strlen(needle);\n-\tint hlen = strlen(haystack) - nlen + 1;\n-\tint i;\n+\tsize_t nlen = strlen(needle);\n+\tsize_t hlen = strlen(haystack) - nlen + 1;\n+\tsize_t i;\n \n \tfor (i = 0; i < hlen; i++) {\n-\t\tint j;\n+\t\tsize_t j;\n \t\tfor (j = 0; j < nlen; j++) {\n \t\t\tunsigned char c1 = haystack[i+j];\n \t\t\tunsigned char c2 = needle[j];\n-\t\t\tif (toupper(c1) != toupper(c2))\n+\t\t\tif (tolower(c1) != tolower(c2))\n \t\t\t\tgoto next;\n \t\t}\n \t\treturn (char *) haystack + i;\ndiff --git a/compat/unsetenv.c b/compat/unsetenv.c\nindex b9d34af6136..8a7daff2699 100644\n--- a/compat/unsetenv.c\n+++ b/compat/unsetenv.c\n@@ -5,7 +5,7 @@ int gitunsetenv(const char *name)\n #if !defined(__MINGW32__)\n      extern char **environ;\n #endif\n-     int src, dst;\n+     size_t src, dst;\n      size_t nmln;\n \n      nmln = strlen(name);\ndiff --git a/compat/winansi.c b/compat/winansi.c\nindex f83610f684d..5aec44a94e6 100644\n--- a/compat/winansi.c\n+++ b/compat/winansi.c\n@@ -195,9 +195,9 @@ static void erase_in_line(void)\n \t\t&dummy);\n }\n \n-static void set_attr(char func, const int *params, int paramlen)\n+static void set_attr(char func, const int *params, size_t paramlen)\n {\n-\tint i;\n+\tsize_t i;\n \tswitch (func) {\n \tcase 'm':\n \t\tfor (i = 0; i < paramlen; i++) {\n@@ -344,7 +344,8 @@ static DWORD WINAPI console_thread(LPVOID unused)\n {\n \tunsigned char buffer[BUFFER_SIZE];\n \tDWORD bytes;\n-\tint start, end = 0, c, parampos = 0, state = TEXT;\n+\tint start, end = 0, c, state = TEXT;\n+\tsize_t parampos = 0;\n \tint params[MAX_PARAMS];\n \n \twhile (1) {\ndiff --git a/config.c b/config.c\nindex 00090a32fc3..7e7efb5cbbc 100644\n--- a/config.c\n+++ b/config.c\n@@ -721,7 +721,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \tif (env) {\n \t\tunsigned long count;\n \t\tchar *endp;\n-\t\tint i;\n+\t\tunsigned long i;\n \n \t\tcount = strtoul(env, &endp, 10);\n \t\tif (*endp) {\n@@ -736,7 +736,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\tfor (i = 0; i < count; i++) {\n \t\t\tconst char *key, *value;\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_KEY_%lu\", i);\n \t\t\tkey = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!key) {\n \t\t\t\tret = error(_(\"missing config key %s\"), envvar.buf);\n@@ -744,7 +744,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)\n \t\t\t}\n \t\t\tstrbuf_reset(&envvar);\n \n-\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%d\", i);\n+\t\t\tstrbuf_addf(&envvar, \"GIT_CONFIG_VALUE_%lu\", i);\n \t\t\tvalue = getenv_safe(&to_free, envvar.buf);\n \t\t\tif (!value) {\n \t\t\t\tret = error(_(\"missing config value %s\"), envvar.buf);\n@@ -1372,7 +1372,7 @@ static enum fsync_component parse_fsync_components(const char *var, const char *\n \tenum fsync_component positive = 0, negative = 0;\n \n \twhile (string) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tsize_t len;\n \t\tconst char *ep;\n \t\tint negated = 0;\n@@ -2221,7 +2221,8 @@ int config_with_options(config_fn_t fn, void *data,\n \n static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)\n {\n-\tint i, value_index;\n+\tunsigned int i;\n+\tsize_t value_index;\n \tstruct string_list *values;\n \tstruct config_set_element *entry;\n \tstruct configset_list *list = &cs->list;\n@@ -3008,7 +3009,7 @@ static ssize_t write_section(int fd, const char *key,\n static ssize_t write_pair(int fd, const char *key, const char *value,\n \t\t\t  const struct config_store_data *store)\n {\n-\tint i;\n+\tsize_t i;\n \tssize_t ret;\n \tconst char *quote = \"\";\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -3065,17 +3066,19 @@ static ssize_t write_pair(int fd, const char *key, const char *value,\n  */\n static void maybe_remove_section(struct config_store_data *store,\n \t\t\t\t size_t *begin_offset, size_t *end_offset,\n-\t\t\t\t int *seen_ptr)\n+\t\t\t\t unsigned int *seen_ptr)\n {\n \tsize_t begin;\n-\tint i, seen, section_seen = 0;\n+\tunsigned int i;\n+\tunsigned int seen;\n+\tint section_seen = 0;\n \n \t/*\n \t * First, ensure that this is the first key, and that there are no\n \t * comments before the entry nor before the section header.\n \t */\n \tseen = *seen_ptr;\n-\tfor (i = store->seen[seen]; i > 0; i--) {\n+\tfor (i = store->seen[seen]; i; i--) {\n \t\tenum config_event_t type = store->parsed[i - 1].type;\n \n \t\tif (type == CONFIG_EVENT_COMMENT)\n@@ -3257,7 +3260,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t} else {\n \t\tstruct stat st;\n \t\tsize_t copy_begin, copy_end;\n-\t\tint i, new_line = 0;\n+\t\tunsigned int i;\n+\t\tint new_line = 0;\n \t\tstruct config_options opts;\n \n \t\tif (!value_pattern)\n@@ -3352,7 +3356,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \n \t\tfor (i = 0, copy_begin = 0; i < store.seen_nr; i++) {\n \t\t\tsize_t replace_end;\n-\t\t\tint j = store.seen[i];\n+\t\t\tunsigned int j = store.seen[i];\n \n \t\t\tnew_line = 0;\n \t\t\tif (!store.key_seen) {\n@@ -3487,9 +3491,10 @@ void git_config_set_multivar(const char *key, const char *value,\n \t\t\t\t\tflags);\n }\n \n-static int section_name_match (const char *buf, const char *name)\n+static unsigned int section_name_match(const char *buf, const char *name)\n {\n-\tint i = 0, j = 0, dot = 0;\n+\tunsigned int i = 0, j = 0;\n+\tint dot = 0;\n \tif (buf[i] != '[')\n \t\treturn 0;\n \tfor (i = 1; buf[i] && buf[i] != ']'; i++) {\ndiff --git a/config.h b/config.h\nindex 7606246531a..d420035f5cb 100644\n--- a/config.h\n+++ b/config.h\n@@ -413,7 +413,7 @@ struct config_set_element {\n \n struct configset_list_item {\n \tstruct config_set_element *e;\n-\tint value_index;\n+\tsize_t value_index;\n };\n \n /*\ndiff --git a/connect.c b/connect.c\nindex 63e59641c0d..858fa2f891c 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -238,7 +238,7 @@ static void process_capabilities(struct packet_reader *reader, int *linelen)\n \tfeat_val = server_feature_value(\"object-format\", &feat_len);\n \tif (feat_val) {\n \t\tchar *hash_name = xstrndup(feat_val, feat_len);\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo != GIT_HASH_UNKNOWN)\n \t\t\treader->hash_algo = &hash_algos[hash_algo];\n \t\tfree(hash_name);\n@@ -385,7 +385,7 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t\t  const char **unborn_head_target)\n {\n \tint ret = 1;\n-\tint i = 0;\n+\tsize_t i;\n \tstruct object_id old_oid;\n \tstruct ref *ref;\n \tstruct string_list line_sections = STRING_LIST_INIT_DUP;\n@@ -403,15 +403,14 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\tgoto out;\n \t}\n \n-\tif (!strcmp(\"unborn\", line_sections.items[i].string)) {\n-\t\ti++;\n+\tif (!strcmp(\"unborn\", line_sections.items[0].string)) {\n \t\tif (unborn_head_target &&\n-\t\t    !strcmp(\"HEAD\", line_sections.items[i++].string)) {\n+\t\t    !strcmp(\"HEAD\", line_sections.items[1].string)) {\n \t\t\t/*\n \t\t\t * Look for the symref target (if any). If found,\n \t\t\t * return it to the caller.\n \t\t\t */\n-\t\t\tfor (; i < line_sections.nr; i++) {\n+\t\t\tfor (i = 2; i < line_sections.nr; i++) {\n \t\t\t\tconst char *arg = line_sections.items[i].string;\n \n \t\t\t\tif (skip_prefix(arg, \"symref-target:\", &arg)) {\n@@ -422,19 +421,20 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,\n \t\t}\n \t\tgoto out;\n \t}\n-\tif (parse_oid_hex_algop(line_sections.items[i++].string, &old_oid, &end, reader->hash_algo) ||\n+\tif (parse_oid_hex_algop(line_sections.items[0].string, &old_oid, &end,\n+\t\t\t\treader->hash_algo) ||\n \t    *end) {\n \t\tret = 0;\n \t\tgoto out;\n \t}\n \n-\tref = alloc_ref(line_sections.items[i++].string);\n+\tref = alloc_ref(line_sections.items[1].string);\n \n \tmemcpy(ref->old_oid.hash, old_oid.hash, reader->hash_algo->rawsz);\n \t**list = ref;\n \t*list = &ref->next;\n \n-\tfor (; i < line_sections.nr; i++) {\n+\tfor (i = 2; i < line_sections.nr; i++) {\n \t\tconst char *arg = line_sections.items[i].string;\n \t\tif (skip_prefix(arg, \"symref-target:\", &arg))\n \t\t\tref->symref = xstrdup(arg);\n@@ -484,7 +484,7 @@ static void send_capabilities(int fd_out, struct packet_reader *reader)\n \t\tpacket_write_fmt(fd_out, \"agent=%s\", git_user_agent_sanitized());\n \n \tif (server_feature_v2(\"object-format\", &hash_name)) {\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo == GIT_HASH_UNKNOWN)\n \t\t\tdie(_(\"unknown object format '%s' specified by server\"), hash_name);\n \t\treader->hash_algo = &hash_algos[hash_algo];\n@@ -543,7 +543,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,\n \t\t\t     const struct string_list *server_options,\n \t\t\t     int stateless_rpc)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct strvec *ref_prefixes = transport_options ?\n \t\t&transport_options->ref_prefixes : NULL;\n \tconst char **unborn_head_target = transport_options ?\ndiff --git a/convert.c b/convert.c\nindex a54d1690c08..8820b1301e0 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -313,17 +313,15 @@ static void trace_encoding(const char *context, const char *path,\n {\n \tstatic struct trace_key coe = TRACE_KEY_INIT(WORKING_TREE_ENCODING);\n \tstruct strbuf trace = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \n \tstrbuf_addf(&trace, \"%s (%s, considered %s):\\n\", context, path, encoding);\n \tfor (i = 0; i < len && buf; ++i) {\n-\t\tstrbuf_addf(\n-\t\t\t&trace, \"| \\033[2m%2i:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n-\t\t\ti,\n-\t\t\t(unsigned char) buf[i],\n-\t\t\t(buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n-\t\t\t((i+1) % 8 && (i+1) < len ? ' ' : '\\n')\n-\t\t);\n+\t\tstrbuf_addf(&trace,\n+\t\t\t    \"| \\033[2m%2u:\\033[0m %2x \\033[2m%c\\033[0m%c\",\n+\t\t\t    (unsigned int)i, (unsigned char)buf[i],\n+\t\t\t    (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),\n+\t\t\t    ((i + 1) % 8 && (i + 1) < len ? ' ' : '\\n'));\n \t}\n \tstrbuf_addchars(&trace, '\\n', 1);\n \n@@ -1815,7 +1813,7 @@ struct ident_filter {\n \n static int is_foreign_ident(const char *str)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(str, \"$Id: \", &str))\n \t\treturn 0;\ndiff --git a/credential.c b/credential.c\nindex f32011343f9..e25ebbc52e9 100644\n--- a/credential.c\n+++ b/credential.c\n@@ -344,7 +344,7 @@ static int credential_do(struct credential *c, const char *helper,\n \n void credential_fill(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->username && c->password)\n \t\treturn;\n@@ -373,7 +373,7 @@ void credential_fill(struct credential *c)\n \n void credential_approve(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (c->approved)\n \t\treturn;\n@@ -389,7 +389,7 @@ void credential_approve(struct credential *c)\n \n void credential_reject(struct credential *c)\n {\n-\tint i;\n+\tsize_t i;\n \n \tcredential_apply_config(c);\n \ndiff --git a/daemon.c b/daemon.c\nindex 0ae7d12b5c1..aa5ee229bd1 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -517,7 +517,7 @@ static struct daemon_service daemon_service[] = {\n \n static void enable_service(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].enabled = ena;\n@@ -529,7 +529,7 @@ static void enable_service(const char *name, int ena)\n \n static void make_service_overridable(const char *name, int ena)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(daemon_service); i++) {\n \t\tif (!strcmp(daemon_service[i].name, name)) {\n \t\t\tdaemon_service[i].overridable = ena;\n@@ -605,7 +605,7 @@ static void canonicalize_client(struct strbuf *out, const char *in)\n static char *parse_host_arg(struct hostinfo *hi, char *extra_args, int buflen)\n {\n \tchar *val;\n-\tint vallen;\n+\tsize_t vallen;\n \tchar *end = extra_args + buflen;\n \n \tif (extra_args < end && *extra_args) {\n@@ -751,7 +751,8 @@ static void set_keep_alive(int sockfd)\n static int execute(void)\n {\n \tchar *line = packet_buffer;\n-\tint pktlen, len, i;\n+\tint pktlen, len;\n+\tsize_t i;\n \tchar *addr = getenv(\"REMOTE_ADDR\"), *port = getenv(\"REMOTE_PORT\");\n \tstruct hostinfo hi = HOSTINFO_INIT;\n \tstruct strvec env = STRVEC_INIT;\n@@ -1122,7 +1123,8 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s\n \tif (!listen_addr->nr)\n \t\tsetup_named_sock(NULL, listen_port, socklist);\n \telse {\n-\t\tint i, socknum;\n+\t\tsize_t i;\n+\t\tint socknum;\n \t\tfor (i = 0; i < listen_addr->nr; i++) {\n \t\t\tsocknum = setup_named_sock(listen_addr->items[i].string,\n \t\t\t\t\t\t   listen_port, socklist);\n@@ -1149,7 +1151,7 @@ static int service_loop(struct socketlist *socklist)\n \tsignal(SIGCHLD, child_handler);\n \n \tfor (;;) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tcheck_dead_children();\n \ndiff --git a/date.c b/date.c\nindex 6f45eeb3568..fd4b686b7e0 100644\n--- a/date.c\n+++ b/date.c\n@@ -421,12 +421,12 @@ static const struct {\n \n static int match_string(const char *date, const char *str)\n {\n-\tint i = 0;\n+\tint i;\n \n \tfor (i = 0; *date; date++, str++, i++) {\n \t\tif (*date == *str)\n \t\t\tcontinue;\n-\t\tif (toupper(*date) == toupper(*str))\n+\t\tif (tolower(*date) == tolower(*str))\n \t\t\tcontinue;\n \t\tif (!isalnum(*date))\n \t\t\tbreak;\ndiff --git a/decorate.c b/decorate.c\nindex 2036d159671..5654dd435d2 100644\n--- a/decorate.c\n+++ b/decorate.c\n@@ -34,8 +34,8 @@ static void *insert_decoration(struct decoration *n, const struct object *base,\n \n static void grow_decoration(struct decoration *n)\n {\n-\tint i;\n-\tint old_size = n->size;\n+\tunsigned int i;\n+\tunsigned int old_size = n->size;\n \tstruct decoration_entry *old_entries = n->entries;\n \n \tn->size = (old_size + 1000) * 3 / 2;\n@@ -56,7 +56,7 @@ static void grow_decoration(struct decoration *n)\n void *add_decoration(struct decoration *n, const struct object *obj,\n \t\tvoid *decoration)\n {\n-\tint nr = n->nr + 1;\n+\tunsigned int nr = n->nr + 1;\n \n \tif (nr > n->size * 2 / 3)\n \t\tgrow_decoration(n);\ndiff --git a/delta-islands.c b/delta-islands.c\nindex afdec0a878d..d4a7bce70ab 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -243,8 +243,8 @@ void resolve_tree_islands(struct repository *r,\n {\n \tstruct progress *progress_state = NULL;\n \tstruct tree_islands_todo *todo;\n-\tint nr = 0;\n-\tint i;\n+\tuint32_t nr = 0;\n+\tuint32_t i;\n \n \tif (!island_marks)\n \t\treturn;\n@@ -320,7 +320,8 @@ static const char *core_island_name;\n \n static void free_config_regexes(struct island_load_data *ild)\n {\n-\tfor (size_t i = 0; i < ild->nr; i++)\n+\tsize_t i;\n+\tfor (i = 0; i < ild->nr; i++)\n \t\tregfree(&ild->rx[i]);\n \tfree(ild->rx);\n }\n@@ -400,7 +401,8 @@ static int find_island_for_ref(const char *refname, const struct object_id *oid,\n \t * than we support.\n \t */\n \tregmatch_t matches[16];\n-\tint i, m;\n+\tint i;\n+\tsize_t m;\n \tstruct strbuf island_name = STRBUF_INIT;\n \n \t/* walk backwards to get last-one-wins ordering */\ndiff --git a/diagnose.c b/diagnose.c\nindex 8f265698966..9206c271663 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -25,7 +25,7 @@ static struct diagnose_option diagnose_options[] = {\n \n int option_parse_diagnose(const struct option *opt, const char *arg, int unset)\n {\n-\tint i;\n+\tsize_t i;\n \tenum diagnose_mode *diagnose = opt->value;\n \n \tif (!arg) {\ndiff --git a/diff-lib.c b/diff-lib.c\nindex dec040c366c..03088f668b1 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -90,7 +90,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \n int run_diff_files(struct rev_info *revs, unsigned int option)\n {\n-\tint entries, i;\n+\tunsigned int entries, i;\n \tint diff_unmerged_stage = revs->max_count;\n \tunsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)\n \t\t\t      ? CE_MATCH_RACY_IS_DIRTY : 0);\n@@ -556,7 +556,7 @@ static int diff_cache(struct rev_info *revs,\n \n void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *mb_child[2] = {0};\n \tstruct commit_list *merge_bases;\n \ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 05fafd0019b..2019db4a350 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -242,7 +242,8 @@ int diff_no_index(struct rev_info *revs,\n \t\t  int implicit_no_index,\n \t\t  int argc, const char **argv)\n {\n-\tint i, no_index;\n+\tunsigned int i;\n+\tint no_index;\n \tint ret = 1;\n \tconst char *paths[2];\n \tchar *to_free[ARRAY_SIZE(paths)] = { 0 };\ndiff --git a/diff.c b/diff.c\nindex 469e18aed20..62422361bb5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,7 +124,7 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tchar *params_copy = xstrdup(params_string);\n \tstruct string_list params = STRING_LIST_INIT_NODUP;\n \tint ret = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (*params_copy)\n \t\tstring_list_split_in_place(&params, params_copy, ',', -1);\n@@ -1678,7 +1678,7 @@ static void emit_hunk_header(struct emit_callback *ecbdata,\n \n static struct diff_tempfile *claim_diff_tempfile(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++)\n \t\tif (!diff_temp[i].name)\n \t\t\treturn diff_temp + i;\n@@ -1687,7 +1687,7 @@ static struct diff_tempfile *claim_diff_tempfile(void)\n \n static void remove_tempfile(void)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(diff_temp); i++) {\n \t\tif (is_tempfile_active(diff_temp[i].tempfile))\n \t\t\tdelete_tempfile(&diff_temp[i].tempfile);\n@@ -2006,7 +2006,7 @@ static void fn_out_diff_words_aux(void *priv,\n \n /* This function starts looking at *begin, and returns 0 iff a word was found. */\n static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n-\t\tint *begin, int *end)\n+\t\t\t\tlong *begin, long *end)\n {\n \twhile (word_regex && *begin < buffer->size) {\n \t\tregmatch_t match[1];\n@@ -2047,7 +2047,7 @@ static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,\n static void diff_words_fill(struct diff_words_buffer *buffer, mmfile_t *out,\n \t\tregex_t *word_regex)\n {\n-\tint i, j;\n+\tlong i, j;\n \tlong alloc = 0;\n \n \tout->size = 0;\n@@ -2188,7 +2188,7 @@ static void init_diff_words_data(struct emit_callback *ecbdata,\n \t\t\t\t struct diff_filespec *one,\n \t\t\t\t struct diff_filespec *two)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct diff_options *o = xmalloc(sizeof(struct diff_options));\n \tmemcpy(o, orig_opts, sizeof(struct diff_options));\n \n@@ -3305,8 +3305,8 @@ static void emit_binary_diff_body(struct diff_options *o,\n \t/* emit data encoded in base85 */\n \tcp = data;\n \twhile (data_size) {\n-\t\tint len;\n-\t\tint bytes = (52 < data_size) ? 52 : data_size;\n+\t\tsize_t len;\n+\t\tsize_t bytes = (52 < data_size) ? 52 : data_size;\n \t\tchar line[71];\n \t\tdata_size -= bytes;\n \t\tif (bytes <= 26)\n@@ -3415,7 +3415,7 @@ static void add_formatted_headers(struct strbuf *msg,\n \t\t\t\t  const char *meta,\n \t\t\t\t  const char *reset)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < more_headers->nr; i++)\n \t\tadd_formatted_header(msg, more_headers->items[i].string,\n@@ -4702,7 +4702,7 @@ static unsigned int filter_bit['Z' + 1];\n \n static void prepare_filter_bits(void)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tif (!filter_bit[DIFF_STATUS_ADDED]) {\n \t\tfor (i = 0; diff_status_letters[i]; i++)\n@@ -4933,7 +4933,8 @@ static int diff_opt_diff_filter(const struct option *option,\n \t\t\t\tconst char *optarg, int unset)\n {\n \tstruct diff_options *opt = option->value;\n-\tint i, optch;\n+\tsize_t i;\n+\tint optch;\n \n \tBUG_ON_OPT_NEG(unset);\n \tprepare_filter_bits();\n@@ -5287,7 +5288,7 @@ static int diff_opt_patience(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n \tstruct diff_options *options = opt->value;\n-\tint i;\n+\tsize_t i;\n \n \tBUG_ON_OPT_NEG(unset);\n \tBUG_ON_OPT_ARG(arg);\n@@ -6213,12 +6214,12 @@ static void diff_summary(struct diff_options *opt, struct diff_filepair *p)\n \n struct patch_id_t {\n \tgit_hash_ctx *ctx;\n-\tint patchlen;\n+\tsize_t patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, unsigned long len)\n {\n-\tint i;\n+\tunsigned long i;\n \tchar *dst = line;\n \tunsigned char c;\n \n@@ -6248,7 +6249,7 @@ void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)\n static int patch_id_consume(void *priv, char *line, unsigned long len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \tif (len > 12 && starts_with(line, \"\\\\ \"))\n \t\treturn 0;\n@@ -6290,7 +6291,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid\n \t\txdemitconf_t xecfg;\n \t\tmmfile_t mf1, mf2;\n \t\tstruct diff_filepair *p = q->queue[i];\n-\t\tint len1, len2;\n+\t\tsize_t len1, len2;\n \n \t\tmemset(&xpp, 0, sizeof(xpp));\n \t\tmemset(&xecfg, 0, sizeof(xecfg));\ndiff --git a/dir.c b/dir.c\nindex 4e99f0c868f..e9fd064a433 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -2988,7 +2988,8 @@ static void emit_traversal_statistics(struct dir_struct *dir,\n }\n \n int read_directory(struct dir_struct *dir, struct index_state *istate,\n-\t\t   const char *path, int len, const struct pathspec *pathspec)\n+\t\t   const char *path, unsigned int len,\n+\t\t   const struct pathspec *pathspec)\n {\n \tstruct untracked_cache_dir *untracked;\n \ndiff --git a/dir.h b/dir.h\nindex 8acfc044181..73cdff47c9e 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -374,7 +374,7 @@ int fill_directory(struct dir_struct *dir,\n \t\t   struct index_state *istate,\n \t\t   const struct pathspec *pathspec);\n int read_directory(struct dir_struct *, struct index_state *istate,\n-\t\t   const char *path, int len,\n+\t\t   const char *path, unsigned int len,\n \t\t   const struct pathspec *pathspec);\n \n enum pattern_match_result {\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 04016d1e325..83a92df7055 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -1324,7 +1324,7 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n \tif (advertise_sid && server_supports_v2(\"session-id\"))\n \t\tpacket_buf_write(req_buf, \"session-id=%s\", trace2_session_id());\n \tif (server_options && server_options->nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tensure_server_supports_v2(\"server-option\");\n \t\tfor (i = 0; i < server_options->nr; i++)\n \t\t\tpacket_buf_write(req_buf, \"server-option=%s\",\n@@ -1332,7 +1332,7 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,\n \t}\n \n \tif (server_feature_v2(\"object-format\", &hash_name)) {\n-\t\tint hash_algo = hash_algo_by_name(hash_name);\n+\t\tunsigned hash_algo = hash_algo_by_name(hash_name);\n \t\tif (hash_algo_by_ptr(the_hash_algo) != hash_algo)\n \t\t\tdie(_(\"mismatched algorithms: client %s; server %s\"),\n \t\t\t    the_hash_algo->name, hash_name);\ndiff --git a/fsck.c b/fsck.c\nindex 2b18717ee80..ce0efac3b27 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -36,7 +36,7 @@ static struct {\n \n static void prepare_msg_ids(void)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (msg_id_info[0].downcased)\n \t\treturn;\n@@ -44,7 +44,7 @@ static void prepare_msg_ids(void)\n \t/* convert id_string to lower case, without underscores. */\n \tfor (i = 0; i < FSCK_MSG_MAX; i++) {\n \t\tconst char *p = msg_id_info[i].id_string;\n-\t\tint len = strlen(p);\n+\t\tsize_t len = strlen(p);\n \t\tchar *q = xmalloc(len);\n \n \t\tmsg_id_info[i].downcased = q;\ndiff --git a/git.c b/git.c\nindex 6171fd6769d..f227d083c66 100644\n--- a/git.c\n+++ b/git.c\n@@ -42,7 +42,7 @@ static void list_builtins(struct string_list *list, unsigned int exclude_option)\n \n static void exclude_helpers_from_list(struct string_list *list)\n {\n-\tint i = 0;\n+\tsize_t i = 0;\n \n \twhile (i < list->nr) {\n \t\tif (strstr(list->items[i].string, \"--\"))\ndiff --git a/hash.h b/hash.h\nindex 36b64165fc9..8e72b5a5930 100644\n--- a/hash.h\n+++ b/hash.h\n@@ -186,13 +186,13 @@ extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];\n  * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if\n  * the name doesn't match a known algorithm.\n  */\n-int hash_algo_by_name(const char *name);\n+unsigned hash_algo_by_name(const char *name);\n /* Identical, except based on the format ID. */\n-int hash_algo_by_id(uint32_t format_id);\n+unsigned hash_algo_by_id(uint32_t format_id);\n /* Identical, except based on the length. */\n-int hash_algo_by_length(int len);\n+unsigned hash_algo_by_length(size_t len);\n /* Identical, except for a pointer to struct git_hash_algo. */\n-static inline int hash_algo_by_ptr(const struct git_hash_algo *p)\n+static inline unsigned hash_algo_by_ptr(const struct git_hash_algo *p)\n {\n \treturn p - hash_algos;\n }\ndiff --git a/help.c b/help.c\nindex 812af4cdea6..90e2d41d514 100644\n--- a/help.c\n+++ b/help.c\n@@ -92,7 +92,7 @@ static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask)\n static void print_command_list(const struct cmdname_help *cmds,\n \t\t\t       uint32_t mask, int longest)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; cmds[i].name; i++) {\n \t\tif (cmds[i].category & mask) {\n@@ -380,7 +380,7 @@ void list_all_other_cmds(struct string_list *list)\n void list_cmds_by_category(struct string_list *list,\n \t\t\t   const char *cat)\n {\n-\tint i, n = ARRAY_SIZE(command_list);\n+\tsize_t i, n = ARRAY_SIZE(command_list);\n \tuint32_t cat_id = 0;\n \n \tfor (i = 0; category_names[i]; i++) {\n@@ -470,7 +470,7 @@ static int get_alias(const char *var, const char *value, void *data)\n static void list_all_cmds_help_external_commands(void)\n {\n \tstruct string_list others = STRING_LIST_INIT_DUP;\n-\tint i;\n+\tsize_t i;\n \n \tlist_all_other_cmds(&others);\n \tif (others.nr)\n@@ -484,7 +484,7 @@ static void list_all_cmds_help_aliases(int longest)\n {\n \tstruct string_list alias_list = STRING_LIST_INIT_DUP;\n \tstruct cmdname_help *aliases;\n-\tint i;\n+\tsize_t i;\n \n \tgit_config(get_alias, &alias_list);\n \tstring_list_sort(&alias_list);\n@@ -810,7 +810,7 @@ static struct string_list guess_refs(const char *ref)\n NORETURN void help_unknown_ref(const char *ref, const char *cmd,\n \t\t\t       const char *error)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct string_list suggested_refs = guess_refs(ref);\n \n \tfprintf_ln(stderr, _(\"%s: %s - %s\"), cmd, ref, error);\ndiff --git a/help.h b/help.h\nindex af073a7a026..3a7940b32a0 100644\n--- a/help.h\n+++ b/help.h\n@@ -58,7 +58,7 @@ static inline void list_config_item(struct string_list *list,\n #define define_list_config_array(array)\t\t\t\t\t\\\n void list_config_##array(struct string_list *list, const char *prefix)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\tint i;\t\t\t\t\t\t\t\t\\\n+\tsize_t i;\t\t\t\t\t\t\t\t\\\n \tfor (i = 0; i < ARRAY_SIZE(array); i++)\t\t\t\t\\\n \t\tif (array[i])\t\t\t\t\t\t\\\n \t\t\tlist_config_item(list, prefix, array[i]);\t\\\n@@ -68,7 +68,7 @@ struct string_list\n #define define_list_config_array_extra(array, values)\t\t\t\\\n void list_config_##array(struct string_list *list, const char *prefix)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\tint i;\t\t\t\t\t\t\t\t\\\n+\tsize_t i;\t\t\t\t\t\t\t\t\\\n \tstatic const char *extra[] = values;\t\t\t\t\\\n \tfor (i = 0; i < ARRAY_SIZE(extra); i++)\t\t\t\t\\\n \t\tlist_config_item(list, prefix, extra[i]);\t\t\\\ndiff --git a/hex.c b/hex.c\nindex 4f64d346963..9337f4572e4 100644\n--- a/hex.c\n+++ b/hex.c\n@@ -50,7 +50,7 @@ int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)\n static int get_hash_hex_algop(const char *hex, unsigned char *hash,\n \t\t\t      const struct git_hash_algo *algop)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < algop->rawsz; i++) {\n \t\tint val = hex2chr(hex);\n \t\tif (val < 0)\n@@ -122,7 +122,7 @@ char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash,\n {\n \tstatic const char hex[] = \"0123456789abcdef\";\n \tchar *buf = buffer;\n-\tint i;\n+\tsize_t i;\n \n \t/*\n \t * Our struct object_id has been memset to 0, so default to printing\ndiff --git a/http-backend.c b/http-backend.c\nindex 8ab58e55f85..1a4e9eb632d 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -255,7 +255,7 @@ static struct rpc_service *select_service(struct strbuf *hdr, const char *name)\n {\n \tconst char *svc_name;\n \tstruct rpc_service *svc = NULL;\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(name, \"git-\", &svc_name))\n \t\tforbidden(hdr, \"Unsupported service: '%s'\", name);\n@@ -743,7 +743,7 @@ int cmd_main(int argc, const char **argv)\n \tchar *dir;\n \tstruct service_cmd *cmd = NULL;\n \tchar *cmd_arg = NULL;\n-\tint i;\n+\tsize_t i;\n \tstruct strbuf hdr = STRBUF_INIT;\n \n \tset_die_routine(die_webcgi);\ndiff --git a/http-push.c b/http-push.c\nindex 7f71316456c..a5d460bdf18 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1325,7 +1325,7 @@ static struct object_list **process_tree(struct tree *tree,\n \n static int get_delta(struct rev_info *revs, struct remote_lock *lock)\n {\n-\tint i;\n+\tunsigned int i;\n \tstruct commit *commit;\n \tstruct object_list **p = &objects;\n \tint count = 0;\n@@ -1580,8 +1580,8 @@ static int delete_remote_branch(const char *pattern, int force)\n \tstruct object_id head_oid;\n \tchar *symref = NULL;\n \tint match;\n-\tint patlen = strlen(pattern);\n-\tint i;\n+\tsize_t patlen = strlen(pattern);\n+\tsize_t i;\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n \tchar *url;\n@@ -1589,7 +1589,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t/* Find the remote branch(es) matching the specified branch name */\n \tfor (match = 0; refs; refs = refs->next) {\n \t\tchar *name = refs->name;\n-\t\tint namelen = strlen(name);\n+\t\tsize_t namelen = strlen(name);\n \t\tif (namelen < patlen ||\n \t\t    memcmp(name + namelen - patlen, pattern, patlen))\n \t\t\tcontinue;\ndiff --git a/http-walker.c b/http-walker.c\nindex b8f0f98ae14..e42fe8d6be0 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -170,7 +170,7 @@ static int is_alternate_allowed(const char *url)\n \tconst char *protocols[] = {\n \t\t\"http\", \"https\", \"ftp\", \"ftps\"\n \t};\n-\tint i;\n+\tsize_t i;\n \n \tif (http_follow_config != HTTP_FOLLOW_ALWAYS) {\n \t\twarning(\"alternate disabled by http.followRedirects: %s\", url);\n@@ -207,7 +207,7 @@ static void process_alternates_response(void *callback_data)\n \tconst char *base = alt_req->base;\n \tconst char null_byte = '\\0';\n \tchar *data;\n-\tint i = 0;\n+\tsize_t i = 0;\n \n \tnormalize_curl_result(&slot->curl_result, slot->http_code,\n \t\t\t      curl_errorstr, sizeof(curl_errorstr));\n@@ -247,12 +247,12 @@ static void process_alternates_response(void *callback_data)\n \tdata = alt_req->buffer->buf;\n \n \twhile (i < alt_req->buffer->len) {\n-\t\tint posn = i;\n+\t\tsize_t posn = i;\n \t\twhile (posn < alt_req->buffer->len && data[posn] != '\\n')\n \t\t\tposn++;\n \t\tif (data[posn] == '\\n') {\n \t\t\tint okay = 0;\n-\t\t\tint serverlen = 0;\n+\t\t\tsize_t serverlen = 0;\n \t\t\tstruct alt_base *newalt;\n \t\t\tif (data[i] == '/') {\n \t\t\t\t/*\ndiff --git a/http.c b/http.c\nindex c4b6ddef287..671af68fff4 100644\n--- a/http.c\n+++ b/http.c\n@@ -481,7 +481,7 @@ static void init_curl_proxy_auth(CURL *result)\n \tvar_override(&http_proxy_authmethod, getenv(\"GIT_HTTP_PROXY_AUTHMETHOD\"));\n \n \tif (http_proxy_authmethod) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) {\n \t\t\tif (!strcmp(http_proxy_authmethod, proxy_authmethods[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYAUTH,\n@@ -800,7 +800,7 @@ static long get_curl_allowed_protocols(int from_user, struct strbuf *list)\n #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2\n static int get_curl_http_version_opt(const char *version_string, long *opt)\n {\n-\tint i;\n+\tsize_t i;\n \tstatic struct {\n \t\tconst char *name;\n \t\tlong opt_token;\n@@ -854,7 +854,7 @@ static CURL *get_curl_handle(void)\n \n #ifdef CURLGSSAPI_DELEGATION_FLAG\n \tif (curl_deleg) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) {\n \t\t\tif (!strcmp(curl_deleg, curl_deleg_levels[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION,\n@@ -883,7 +883,7 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_SSL_VERSION\"))\n \t\tssl_version = getenv(\"GIT_SSL_VERSION\");\n \tif (ssl_version && *ssl_version) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < ARRAY_SIZE(sslversions); i++) {\n \t\t\tif (!strcmp(ssl_version, sslversions[i].name)) {\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_SSLVERSION,\n@@ -1089,7 +1089,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)\n \tif (http_ssl_backend) {\n \t\tconst curl_ssl_backend **backends;\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tswitch (curl_global_sslset(-1, http_ssl_backend, &backends)) {\n \t\tcase CURLSSLSET_UNKNOWN_BACKEND:\n@@ -1754,9 +1754,9 @@ static void write_accept_language(struct strbuf *buf)\n \tconst int MAX_LANGUAGE_TAGS = 1000;\n \tconst int MAX_ACCEPT_LANGUAGE_HEADER_SIZE = 4000;\n \tchar **language_tags = NULL;\n-\tint num_langs = 0;\n+\tunsigned int num_langs = 0;\n \tconst char *s = get_preferred_languages();\n-\tint i;\n+\tunsigned int i;\n \tstruct strbuf tag = STRBUF_INIT;\n \n \t/* Don't add Accept-Language header if no language is preferred. */\n@@ -1802,7 +1802,7 @@ static void write_accept_language(struct strbuf *buf)\n \t\t     decimal_places++, max_q *= 10)\n \t\t\t;\n \n-\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%dd\", decimal_places);\n+\t\txsnprintf(q_format, sizeof(q_format), \";q=0.%%0%ud\", decimal_places);\n \n \t\tstrbuf_addstr(buf, \"Accept-Language: \");\n \ndiff --git a/line-log.c b/line-log.c\nindex a7f3e7f6ce4..7a87eb27ef7 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -473,8 +473,8 @@ static void range_set_map_across_diff(struct range_set *out,\n static struct commit *check_single_commit(struct rev_info *revs)\n {\n \tstruct object *commit = NULL;\n-\tint found = -1;\n-\tint i;\n+\tunsigned found = 0;\n+\tunsigned i;\n \n \tfor (i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object *obj = revs->pending.objects[i].item;\ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex ee01bcd2cc3..dcb84ee81e9 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -397,7 +397,7 @@ void list_objects_filter_copy(\n \tstruct list_objects_filter_options *dest,\n \tconst struct list_objects_filter_options *src)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* Copy everything. We will overwrite the pointers shortly. */\n \tmemcpy(dest, src, sizeof(struct list_objects_filter_options));\ndiff --git a/list-objects.c b/list-objects.c\nindex 7528fe1db2c..23f1b0963ea 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -267,7 +267,7 @@ void mark_edges_uninteresting(struct rev_info *revs,\n \t\t\t      int sparse)\n {\n \tstruct commit_list *list;\n-\tint i;\n+\tunsigned int i;\n \n \tif (sparse) {\n \t\tstruct oidset set;\n@@ -326,7 +326,7 @@ static void add_pending_tree(struct rev_info *revs, struct tree *tree)\n static void traverse_non_commits(struct traversal_context *ctx,\n \t\t\t\t struct strbuf *base)\n {\n-\tint i;\n+\tunsigned int i;\n \n \tassert(base->len == 0);\n \ndiff --git a/ll-merge.c b/ll-merge.c\nindex 130d26501c6..4643c8c2f65 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -194,7 +194,8 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,\n \tstruct strbuf_expand_dict_entry dict[6];\n \tstruct strbuf path_sq = STRBUF_INIT;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint status, fd, i;\n+\tint status, fd;\n+\tunsigned int i;\n \tstruct stat st;\n \tenum ll_merge_result ret;\n \tassert(opts);\n@@ -329,7 +330,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr\n {\n \tstruct ll_merge_driver *fn;\n \tconst char *name;\n-\tint i;\n+\tsize_t i;\n \n \tinitialize_ll_merge();\n \ndiff --git a/lockfile.c b/lockfile.c\nindex cc9a4b84283..5468a642654 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -14,7 +14,7 @@\n  */\n static void trim_last_path_component(struct strbuf *path)\n {\n-\tint i = path->len;\n+\tsize_t i = path->len;\n \n \t/* back up past trailing slashes, if any */\n \twhile (i && path->buf[i - 1] == '/')\ndiff --git a/log-tree.c b/log-tree.c\nindex 1dd5fcbf7be..5db3fcede2c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -138,7 +138,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,\n \t\t\t      int flags UNUSED,\n \t\t\t      void *cb_data)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct object *obj;\n \tenum object_type objtype;\n \tenum decoration_type deco_type = DECORATION_NONE;\ndiff --git a/ls-refs.c b/ls-refs.c\nindex 697d4beb8de..b40f902648f 100644\n--- a/ls-refs.c\n+++ b/ls-refs.c\n@@ -54,7 +54,7 @@ static void ensure_config_read(void)\n  */\n static int ref_match(const struct strvec *prefixes, const char *refname)\n {\n-\tint i;\n+\tsize_t i;\n \n \tif (!prefixes->nr)\n \t\treturn 1; /* no restriction */\ndiff --git a/mailinfo.c b/mailinfo.c\nindex 833d28612f7..963ad2e7794 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -617,7 +617,7 @@ check_header_out:\n static int is_inbody_header(const struct mailinfo *mi,\n \t\t\t    const struct strbuf *line)\n {\n-\tint i;\n+\tsize_t i;\n \tconst char *val;\n \tfor (i = 0; header[i]; i++)\n \t\tif (!mi->s_hdr_data[i] && skip_header(line, header[i], &val))\n@@ -765,7 +765,7 @@ static int check_inbody_header(struct mailinfo *mi, const struct strbuf *line)\n \tif (starts_with(line->buf, \">From\") && isspace(line->buf[5]))\n \t\treturn is_format_patch_separator(line->buf + 1, line->len - 1);\n \tif (starts_with(line->buf, \"[PATCH]\") && isspace(line->buf[7])) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; header[i]; i++)\n \t\t\tif (!strcmp(\"Subject\", header[i])) {\n \t\t\t\thandle_header(&mi->s_hdr_data[i], line);\n@@ -809,7 +809,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)\n \t\treturn 0; /* mi->input_error already set */\n \n \tif (mi->use_scissors && is_scissors_line(line->buf)) {\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tstrbuf_setlen(&mi->log_message, 0);\n \t\tmi->header_stage = 1;\n@@ -1147,7 +1147,7 @@ static void output_header_lines(FILE *fout, const char *hdr, const struct strbuf\n static void handle_info(struct mailinfo *mi)\n {\n \tstruct strbuf *hdr;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; header[i]; i++) {\n \t\t/* only print inbody headers if we output a patch file */\ndiff --git a/merge-ort.c b/merge-ort.c\nindex d1611ca400a..a57dacaa080 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -681,9 +681,9 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,\n \t\t/* Release and free each strbuf found in output */\n \t\tstrmap_for_each_entry(&opti->conflicts, &iter, e) {\n \t\t\tstruct string_list *list = e->value;\n-\t\t\tfor (int i = 0; i < list->nr; i++) {\n+\t\t\tfor (size_t j = 0; j < list->nr; j++) {\n \t\t\t\tstruct logical_conflict_info *info =\n-\t\t\t\t\tlist->items[i].util;\n+\t\t\t\t\tlist->items[j].util;\n \t\t\t\tstrvec_clear(&info->paths);\n \t\t\t}\n \t\t\t/*\n@@ -793,7 +793,7 @@ static void path_msg(struct merge_options *opt,\n \tif (other_path_2)\n \t\tstrvec_push(&info->paths, other_path_2);\n \tif (other_paths)\n-\t\tfor (int i = 0; i < other_paths->nr; i++)\n+\t\tfor (size_t i = 0; i < other_paths->nr; i++)\n \t\tstrvec_push(&info->paths, other_paths->items[i].string);\n \n \t/* Handle message and its format, in normal case */\n@@ -810,7 +810,7 @@ static void path_msg(struct merge_options *opt,\n \n \t/* Handle specialized formatting of message under --remerge-diff */\n \tif (opt->record_conflict_msgs_as_headers) {\n-\t\tint i_sb = 0, i_tmp = 0;\n+\t\tsize_t i_sb = 0, i_tmp = 0;\n \n \t\t/* Start with the specified prefix */\n \t\tif (opt->msg_header_prefix)\n@@ -1011,7 +1011,7 @@ static void setup_path_info(struct merge_options *opt,\n \t\toidcpy(&mi->result.oid, &merged_version->oid);\n \t\tmi->is_null = !!is_null;\n \t} else {\n-\t\tint i;\n+\t\tunsigned i;\n \t\tstruct conflict_info *ci;\n \n \t\tASSIGN_AND_VERIFY_CI(ci, mi);\n@@ -1380,7 +1380,8 @@ static int collect_merge_info_callback(int n,\n \t\tstruct tree_desc t[3];\n \t\tvoid *buf[3] = {NULL, NULL, NULL};\n \t\tconst char *original_dir_name;\n-\t\tint i, ret, side;\n+\t\tunsigned int i, side;\n+\t\tint ret;\n \n \t\t/*\n \t\t * Check for whether we can avoid recursing due to one side\n@@ -1553,12 +1554,12 @@ static int handle_deferred_entries(struct merge_options *opt,\n \t\t\t\t\t    0);\n \t\tstrintmap_for_each_entry(&copy, &iter, entry) {\n \t\t\tconst char *path = entry->key;\n-\t\t\tunsigned dir_rename_mask = (intptr_t)entry->value;\n+\t\t\tunsigned dir_rename_mask = (uintptr_t)entry->value;\n \t\t\tstruct conflict_info *ci;\n \t\t\tunsigned dirmask;\n \t\t\tstruct tree_desc t[3];\n \t\t\tvoid *buf[3] = {NULL,};\n-\t\t\tint i;\n+\t\t\tunsigned i;\n \n \t\t\tci = strmap_get(&opt->priv->paths, path);\n \t\t\tVERIFY_CI(ci);\n@@ -1683,13 +1684,13 @@ static int collect_merge_info(struct merge_options *opt,\n \n /*** Function Grouping: functions related to threeway content merges ***/\n \n-static int find_first_merges(struct repository *repo,\n+static unsigned find_first_merges(struct repository *repo,\n \t\t\t     const char *path,\n \t\t\t     struct commit *a,\n \t\t\t     struct commit *b,\n \t\t\t     struct object_array *result)\n {\n-\tint i, j;\n+\tunsigned i, j;\n \tstruct object_array merges = OBJECT_ARRAY_INIT;\n \tstruct commit *commit;\n \tint contains_another;\n@@ -1757,10 +1758,10 @@ static int merge_submodule(struct merge_options *opt,\n \tstruct strbuf sb = STRBUF_INIT;\n \tint ret = 0;\n \tstruct commit *commit_o, *commit_a, *commit_b;\n-\tint parent_count;\n+\tunsigned parent_count;\n \tstruct object_array merges;\n \n-\tint i;\n+\tunsigned i;\n \tint search = !opt->priv->call_depth;\n \tint sub_not_initialized = 1;\n \tint sub_flag = CONFLICT_SUBMODULE_FAILED_TO_MERGE;\n@@ -2357,7 +2358,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt)\n \tstruct rename_info *renames = &opt->priv->renames;\n \tstruct strmap *side1_dir_renames = &renames->dir_renames[MERGE_SIDE1];\n \tstruct strmap *side2_dir_renames = &renames->dir_renames[MERGE_SIDE2];\n-\tint i;\n+\tsize_t i;\n \n \tstrmap_for_each_entry(side1_dir_renames, &iter, entry) {\n \t\tif (strmap_contains(side2_dir_renames, entry->key))\n@@ -3339,8 +3340,9 @@ static int detect_and_process_renames(struct merge_options *opt,\n \tstruct diff_queue_struct combined = { 0 };\n \tstruct rename_info *renames = &opt->priv->renames;\n \tstruct strmap collisions[3];\n-\tint need_dir_renames, s, i, clean = 1;\n-\tunsigned detection_run = 0;\n+\tint need_dir_renames, s, clean = 1;\n+\tunsigned i;\n+\tint detection_run = 0;\n \n \tif (!possible_renames(renames))\n \t\tgoto cleanup;\n@@ -3353,13 +3355,13 @@ static int detect_and_process_renames(struct merge_options *opt,\n \t\trenames->redo_after_renames = 0;\n \t}\n \tif (renames->redo_after_renames && detection_run) {\n-\t\tint i, side;\n+\t\tint side;\n \t\tstruct diff_filepair *p;\n \n \t\t/* Cache the renames, we found */\n \t\tfor (side = MERGE_SIDE1; side <= MERGE_SIDE2; side++) {\n-\t\t\tfor (i = 0; i < renames->pairs[side].nr; ++i) {\n-\t\t\t\tp = renames->pairs[side].queue[i];\n+\t\t\tfor (s = 0; s < renames->pairs[side].nr; ++s) {\n+\t\t\t\tp = renames->pairs[side].queue[s];\n \t\t\t\tpossibly_cache_new_pair(renames, p, side, NULL);\n \t\t\t}\n \t\t}\n@@ -3389,7 +3391,7 @@ static int detect_and_process_renames(struct merge_options *opt,\n \t\t   renames->pairs[1].nr + renames->pairs[2].nr,\n \t\t   combined.alloc);\n \tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n-\t\tint other_side = 3 - i;\n+\t\tunsigned other_side = 3 - i;\n \t\tcompute_collisions(&collisions[i],\n \t\t\t\t   &renames->dir_renames[other_side],\n \t\t\t\t   &renames->pairs[i]);\n@@ -3418,25 +3420,24 @@ cleanup:\n \t * Free now unneeded filepairs, which would have been handled\n \t * in collect_renames() normally but we skipped that code.\n \t */\n-\tfor (s = MERGE_SIDE1; s <= MERGE_SIDE2; s++) {\n+\tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n \t\tstruct diff_queue_struct *side_pairs;\n-\t\tint i;\n \n-\t\tside_pairs = &renames->pairs[s];\n-\t\tfor (i = 0; i < side_pairs->nr; ++i) {\n-\t\t\tstruct diff_filepair *p = side_pairs->queue[i];\n+\t\tside_pairs = &renames->pairs[i];\n+\t\tfor (s = 0; s < side_pairs->nr; ++s) {\n+\t\t\tstruct diff_filepair *p = side_pairs->queue[s];\n \t\t\tpool_diff_free_filepair(&opt->priv->pool, p);\n \t\t}\n \t}\n \n simple_cleanup:\n \t/* Free memory for renames->pairs[] and combined */\n-\tfor (s = MERGE_SIDE1; s <= MERGE_SIDE2; s++) {\n-\t\tfree(renames->pairs[s].queue);\n-\t\tDIFF_QUEUE_CLEAR(&renames->pairs[s]);\n+\tfor (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {\n+\t\tfree(renames->pairs[i].queue);\n+\t\tDIFF_QUEUE_CLEAR(&renames->pairs[i]);\n \t}\n-\tfor (i = 0; i < combined.nr; i++)\n-\t\tpool_diff_free_filepair(&opt->priv->pool, combined.queue[i]);\n+\tfor (s = 0; i < combined.nr; s++)\n+\t\tpool_diff_free_filepair(&opt->priv->pool, combined.queue[s]);\n \tfree(combined.queue);\n \n \treturn clean;\n@@ -3609,13 +3610,14 @@ static int tree_entry_order(const void *a_, const void *b_)\n \n static int write_tree(struct object_id *result_oid,\n \t\t      struct string_list *versions,\n-\t\t      unsigned int offset,\n+\t\t      size_t offset,\n \t\t      size_t hash_size)\n {\n \tsize_t maxlen = 0, extra;\n-\tunsigned int nr;\n+\tsize_t nr;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tint i, ret = 0;\n+\tsize_t i;\n+\tint ret = 0;\n \n \tassert(offset <= versions->nr);\n \tnr = versions->nr - offset;\n@@ -3669,7 +3671,8 @@ static int write_completed_directory(struct merge_options *opt,\n {\n \tconst char *prev_dir;\n \tstruct merged_info *dir_info = NULL;\n-\tunsigned int offset, ret = 0;\n+\tsize_t offset;\n+\tint ret = 0;\n \n \t/*\n \t * Some explanation of info->versions and info->offsets...\n@@ -3766,7 +3769,7 @@ static int write_completed_directory(struct merge_options *opt,\n \tif (info->last_directory == NULL ||\n \t    !strncmp(new_directory_name, info->last_directory,\n \t\t     info->last_directory_len)) {\n-\t\tuintptr_t offset = info->versions.nr;\n+\t\toffset = (uintptr_t)info->versions.nr;\n \n \t\tinfo->last_directory = new_directory_name;\n \t\tinfo->last_directory_len = strlen(info->last_directory);\n@@ -3864,7 +3867,7 @@ static int process_entry(struct merge_options *opt,\n \t}\n \n \tif (ci->df_conflict && ci->merged.result.mode == 0) {\n-\t\tint i;\n+\t\tunsigned i;\n \n \t\t/*\n \t\t * directory no longer in the way, but we do have a file we\n@@ -3894,7 +3897,7 @@ static int process_entry(struct merge_options *opt,\n \t\tstruct conflict_info *new_ci;\n \t\tconst char *branch;\n \t\tconst char *old_path = path;\n-\t\tint i;\n+\t\tunsigned i;\n \n \t\tassert(ci->merged.result.mode == S_IFDIR);\n \n@@ -3977,7 +3980,7 @@ static int process_entry(struct merge_options *opt,\n \t\t} else {\n \t\t\t/* determine the mask of the side that didn't match */\n \t\t\tunsigned int othermask = 7 & ~ci->match_mask;\n-\t\t\tint side = (othermask == 4) ? 2 : 1;\n+\t\t\tunsigned int side = (othermask == 4) ? 2 : 1;\n \n \t\t\tci->merged.result.mode = ci->stages[side].mode;\n \t\t\tci->merged.is_null = !ci->merged.result.mode;\n@@ -4137,8 +4140,8 @@ static int process_entry(struct merge_options *opt,\n \t} else if (ci->filemask == 3 || ci->filemask == 5) {\n \t\t/* Modify/delete */\n \t\tconst char *modify_branch, *delete_branch;\n-\t\tint side = (ci->filemask == 5) ? 2 : 1;\n-\t\tint index = opt->priv->call_depth ? 0 : side;\n+\t\tunsigned side = (ci->filemask == 5) ? 2 : 1;\n+\t\tunsigned index = opt->priv->call_depth ? 0 : side;\n \n \t\tci->merged.result.mode = ci->stages[index].mode;\n \t\toidcpy(&ci->merged.result.oid, &ci->stages[index].oid);\n@@ -4184,7 +4187,7 @@ static int process_entry(struct merge_options *opt,\n \t\t}\n \t} else if (ci->filemask == 2 || ci->filemask == 4) {\n \t\t/* Added on one side */\n-\t\tint side = (ci->filemask == 4) ? 2 : 1;\n+\t\tunsigned side = (ci->filemask == 4) ? 2 : 1;\n \t\tci->merged.result.mode = ci->stages[side].mode;\n \t\toidcpy(&ci->merged.result.oid, &ci->stages[side].oid);\n \t\tci->merged.clean = !ci->df_conflict && !ci->path_conflict;\n@@ -4222,7 +4225,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n \t\t/* char *path = e->string; */\n \t\tstruct conflict_info *ci = e->util;\n-\t\tint i;\n+\t\tunsigned i;\n \n \t\t/* Ignore clean entries */\n \t\tif (ci->merged.clean)\n@@ -4600,16 +4603,16 @@ void merge_display_update_messages(struct merge_options *opt,\n \tstring_list_sort(&olist);\n \n \t/* Iterate over the items, printing them */\n-\tfor (int path_nr = 0; path_nr < olist.nr; ++path_nr) {\n+\tfor (size_t path_nr = 0; path_nr < olist.nr; ++path_nr) {\n \t\tstruct string_list *conflicts = olist.items[path_nr].util;\n-\t\tfor (int i = 0; i < conflicts->nr; i++) {\n+\t\tfor (size_t i = 0; i < conflicts->nr; i++) {\n \t\t\tstruct logical_conflict_info *info =\n \t\t\t\tconflicts->items[i].util;\n \n \t\t\tif (detailed) {\n \t\t\t\tprintf(\"%lu\", (unsigned long)info->paths.nr);\n \t\t\t\tputchar('\\0');\n-\t\t\t\tfor (int n = 0; n < info->paths.nr; n++) {\n+\t\t\t\tfor (size_t n = 0; n < info->paths.nr; n++) {\n \t\t\t\t\tfputs(info->paths.v[n], stdout);\n \t\t\t\t\tputchar('\\0');\n \t\t\t\t}\n@@ -4764,7 +4767,7 @@ static struct commit *make_virtual_commit(struct repository *repo,\n static void merge_start(struct merge_options *opt, struct merge_result *result)\n {\n \tstruct rename_info *renames;\n-\tint i;\n+\tunsigned i;\n \tstruct mem_pool *pool = NULL;\n \n \t/* Sanity checks on opt */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex ae469f8cc81..bafa986fc60 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -523,7 +523,7 @@ static struct stage_data *insert_stage_data(struct repository *r,\n static struct string_list *get_unmerged(struct index_state *istate)\n {\n \tstruct string_list *unmerged = xmalloc(sizeof(struct string_list));\n-\tint i;\n+\tunsigned i;\n \n \tstring_list_init_dup(unmerged);\n \n@@ -594,8 +594,8 @@ static void record_df_conflict_files(struct merge_options *opt,\n \t */\n \tstruct string_list df_sorted_entries = STRING_LIST_INIT_NODUP;\n \tconst char *last_file = NULL;\n-\tint last_len = 0;\n-\tint i;\n+\tsize_t last_len = 0;\n+\tsize_t i;\n \n \t/*\n \t * If we're merging merge-bases, we don't want to bother with\n@@ -616,7 +616,7 @@ static void record_df_conflict_files(struct merge_options *opt,\n \tstring_list_clear(&opt->priv->df_conflict_file_set, 1);\n \tfor (i = 0; i < df_sorted_entries.nr; i++) {\n \t\tconst char *path = df_sorted_entries.items[i].string;\n-\t\tint len = strlen(path);\n+\t\tsize_t len = strlen(path);\n \t\tstruct stage_data *e = df_sorted_entries.items[i].util;\n \n \t\t/*\n@@ -877,7 +877,8 @@ static int was_dirty(struct merge_options *opt, const char *path)\n \n static int make_room_for_path(struct merge_options *opt, const char *path)\n {\n-\tint status, i;\n+\tint status;\n+\tsize_t i;\n \tconst char *msg = _(\"failed to create path '%s'%s\");\n \n \t/* Unlink any D/F conflict files that are in the way */\n@@ -1103,11 +1104,11 @@ static int merge_3way(struct merge_options *opt,\n \treturn merge_status;\n }\n \n-static int find_first_merges(struct repository *repo,\n+static unsigned find_first_merges(struct repository *repo,\n \t\t\t     struct object_array *result, const char *path,\n \t\t\t     struct commit *a, struct commit *b)\n {\n-\tint i, j;\n+\tunsigned i, j;\n \tstruct object_array merges = OBJECT_ARRAY_INIT;\n \tstruct commit *commit;\n \tint contains_another;\n@@ -1189,10 +1190,10 @@ static int merge_submodule(struct merge_options *opt,\n \tstruct repository subrepo;\n \tint ret = 0;\n \tstruct commit *commit_base, *commit_a, *commit_b;\n-\tint parent_count;\n+\tunsigned parent_count;\n \tstruct object_array merges;\n \n-\tint i;\n+\tunsigned i;\n \tint search = !opt->priv->call_depth;\n \n \t/* store a in result in case we fail */\n@@ -2065,7 +2066,7 @@ static void get_renamed_dir_portion(const char *old_path, const char *new_path,\n static void remove_hashmap_entries(struct hashmap *dir_renames,\n \t\t\t\t   struct string_list *items_to_remove)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct dir_rename_entry *entry;\n \n \tfor (i = 0; i < items_to_remove->nr; i++) {\n@@ -2995,7 +2996,7 @@ cleanup:\n static void final_cleanup_rename(struct string_list *rename)\n {\n \tconst struct rename *re;\n-\tint i;\n+\tsize_t i;\n \n \tif (!rename)\n \t\treturn;\n@@ -3805,7 +3806,7 @@ static struct commit *get_ref(struct repository *repo,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result)\n {\n@@ -3816,7 +3817,7 @@ int merge_recursive_generic(struct merge_options *opt,\n \tstruct commit_list *ca = NULL;\n \n \tif (merge_bases) {\n-\t\tint i;\n+\t\tunsigned int i;\n \t\tfor (i = 0; i < num_merge_bases; ++i) {\n \t\t\tstruct commit *base;\n \t\t\tif (!(base = get_ref(opt->repo, merge_bases[i],\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex b88000e3c25..f8d7517dc50 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -118,7 +118,7 @@ int merge_recursive(struct merge_options *opt,\n int merge_recursive_generic(struct merge_options *opt,\n \t\t\t    const struct object_id *head,\n \t\t\t    const struct object_id *merge,\n-\t\t\t    int num_merge_bases,\n+\t\t\t    unsigned int num_merge_bases,\n \t\t\t    const struct object_id **merge_bases,\n \t\t\t    struct commit **result);\n \ndiff --git a/merge.c b/merge.c\nindex 445b4f19aa8..7755ed9b4b5 100644\n--- a/merge.c\n+++ b/merge.c\n@@ -20,7 +20,8 @@ int try_merge_command(struct repository *r,\n \t\t      const char *head_arg, struct commit_list *remotes)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n-\tint i, ret;\n+\tsize_t i;\n+\tint ret;\n \tstruct commit_list *j;\n \n \tstrvec_pushf(&cmd.args, \"merge-%s\", strategy);\n@@ -52,7 +53,7 @@ int checkout_fast_forward(struct repository *r,\n \tstruct tree *trees[MAX_UNPACK_TREES];\n \tstruct unpack_trees_options opts;\n \tstruct tree_desc t[MAX_UNPACK_TREES];\n-\tint i, nr_trees = 0;\n+\tunsigned int i, nr_trees = 0;\n \tstruct lock_file lock_file = LOCK_INIT;\n \n \trefresh_index(r->index, REFRESH_QUIET, NULL, NULL, NULL);\ndiff --git a/mergesort.h b/mergesort.h\nindex 7c36f08bd5f..123e4cf3036 100644\n--- a/mergesort.h\n+++ b/mergesort.h\n@@ -54,7 +54,7 @@ scope void name(type **listp,\t\t\t\t\t\t\\\n \t\treturn;\t\t\t\t\t\t\t\\\n \t\t\t\t\t\t\t\t\t\\\n \tfor (;;) {\t\t\t\t\t\t\t\\\n-\t\tint i;\t\t\t\t\t\t\t\\\n+\t\tsize_t i;\t\t\t\t\t\t\t\\\n \t\tsize_t m;\t\t\t\t\t\t\\\n \t\ttype *next = name##__get_next(list);\t\t\t\\\n \t\tif (next)\t\t\t\t\t\t\\\ndiff --git a/name-hash.c b/name-hash.c\nindex cd009c7c8ae..ec5f12f9d4c 100644\n--- a/name-hash.c\n+++ b/name-hash.c\n@@ -13,7 +13,7 @@\n struct dir_entry {\n \tstruct hashmap_entry ent;\n \tstruct dir_entry *parent;\n-\tint nr;\n+\tunsigned int nr;\n \tunsigned int namelen;\n \tchar name[FLEX_ARRAY];\n };\n@@ -477,7 +477,7 @@ struct lazy_name_thread_data {\n static void *lazy_name_thread_proc(void *_data)\n {\n \tstruct lazy_name_thread_data *d = _data;\n-\tint k;\n+\tunsigned int k;\n \n \tfor (k = 0; k < d->istate->cache_nr; k++) {\n \t\tstruct cache_entry *ce_k = d->istate->cache[k];\n@@ -493,7 +493,7 @@ static inline void lazy_update_dir_ref_counts(\n \tstruct index_state *istate,\n \tstruct lazy_entry *lazy_entries)\n {\n-\tint k;\n+\tunsigned int k;\n \n \tfor (k = 0; k < istate->cache_nr; k++) {\n \t\tif (lazy_entries[k].dir)\ndiff --git a/notes-utils.c b/notes-utils.c\nindex d7d18e30f5a..479c180904f 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -166,7 +166,7 @@ int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n \t\t\t  const struct object_id *from_obj, const struct object_id *to_obj)\n {\n \tint ret = 0;\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; c->trees[i]; i++)\n \t\tret = copy_note(c->trees[i], from_obj, to_obj, 1, c->combine) || ret;\n \treturn ret;\n@@ -176,7 +176,7 @@ void finish_copy_notes_for_rewrite(struct repository *r,\n \t\t\t\t   struct notes_rewrite_cfg *c,\n \t\t\t\t   const char *msg)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; c->trees[i]; i++) {\n \t\tcommit_notes(r, c->trees[i], msg);\n \t\tfree_notes(c->trees[i]);\ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..47a6529b9fc 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -956,7 +956,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,\n {\n \tstruct string_list split = STRING_LIST_INIT_NODUP;\n \tchar *globs_copy = xstrdup(globs);\n-\tint i;\n+\tsize_t i;\n \n \tstring_list_split_in_place(&split, globs_copy, ':', -1);\n \tstring_list_remove_empty_items(&split, 0);\n@@ -1309,7 +1309,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n void format_display_notes(const struct object_id *object_oid,\n \t\t\t  struct strbuf *sb, const char *output_encoding, int raw)\n {\n-\tint i;\n+\tsize_t i;\n \tassert(display_notes_trees);\n \tfor (i = 0; display_notes_trees[i]; i++)\n \t\tformat_note(display_notes_trees[i], object_oid, sb,\ndiff --git a/object-file.c b/object-file.c\nindex 939865c1ae0..36ff98b611f 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -236,9 +236,9 @@ const char *empty_blob_oid_hex(void)\n \treturn oid_to_hex_r(buf, the_hash_algo->empty_blob);\n }\n \n-int hash_algo_by_name(const char *name)\n+unsigned hash_algo_by_name(const char *name)\n {\n-\tint i;\n+\tunsigned i;\n \tif (!name)\n \t\treturn GIT_HASH_UNKNOWN;\n \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n@@ -247,18 +247,18 @@ int hash_algo_by_name(const char *name)\n \treturn GIT_HASH_UNKNOWN;\n }\n \n-int hash_algo_by_id(uint32_t format_id)\n+unsigned hash_algo_by_id(uint32_t format_id)\n {\n-\tint i;\n+\tunsigned i;\n \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n \t\tif (format_id == hash_algos[i].format_id)\n \t\t\treturn i;\n \treturn GIT_HASH_UNKNOWN;\n }\n \n-int hash_algo_by_length(int len)\n+unsigned hash_algo_by_length(size_t len)\n {\n-\tint i;\n+\tunsigned i;\n \tfor (i = 1; i < GIT_HASH_NALGOS; i++)\n \t\tif (len == hash_algos[i].rawsz)\n \t\t\treturn i;\ndiff --git a/object-name.c b/object-name.c\nindex 2dd1a0f56e1..7aa105f69b4 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -758,8 +758,8 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)\n \t\tfind_abbrev_len_for_pack(p, mad);\n }\n \n-int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n-\t\t\t      const struct object_id *oid, int len)\n+unsigned int repo_find_unique_abbrev_r(struct repository *r, char *hex,\n+\t\t\t\t       const struct object_id *oid, int len)\n {\n \tstruct disambiguate_state ds;\n \tstruct min_abbrev_data mad;\n@@ -818,7 +818,7 @@ const char *repo_find_unique_abbrev(struct repository *r,\n \t\t\t\t    const struct object_id *oid,\n \t\t\t\t    int len)\n {\n-\tstatic int bufno;\n+\tstatic unsigned int bufno;\n \tstatic char hexbuffer[4][GIT_MAX_HEXSZ + 1];\n \tchar *hex = hexbuffer[bufno];\n \tbufno = (bufno + 1) % ARRAY_SIZE(hexbuffer);\ndiff --git a/path.c b/path.c\nindex 492e17ad121..0868be56610 100644\n--- a/path.c\n+++ b/path.c\n@@ -801,8 +801,8 @@ const char *enter_repo(const char *path, int strict)\n \t\t\t\"/.git\", \"\", \".git/.git\", \".git\", NULL,\n \t\t};\n \t\tconst char *gitfile;\n-\t\tint len = strlen(path);\n-\t\tint i;\n+\t\tsize_t len = strlen(path);\n+\t\tsize_t i;\n \t\twhile ((1 < len) && (path[len-1] == '/'))\n \t\t\tlen--;\n \ndiff --git a/pathspec.c b/pathspec.c\nindex ab70fcbe613..2256b57c655 100644\n--- a/pathspec.c\n+++ b/pathspec.c\n@@ -67,7 +67,7 @@ char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec)\n {\n \tstruct index_state *istate = the_repository->index;\n \tchar *seen = xcalloc(pathspec->nr, 1);\n-\tint i;\n+\tunsigned i;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -103,7 +103,7 @@ static struct pathspec_magic {\n \n static void prefix_magic(struct strbuf *sb, int prefixlen, unsigned magic)\n {\n-\tint i;\n+\tsize_t i;\n \tstrbuf_addstr(sb, \":(\");\n \tfor (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)\n \t\tif (magic & pathspec_magic[i].bit) {\n@@ -309,7 +309,7 @@ static const char *parse_long_magic(unsigned *magic, int *prefix_len,\n \n \tfor (pos = elem + 2; *pos && *pos != ')'; pos = nextat) {\n \t\tsize_t len = strcspn_escaped(pos, \",)\");\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tif (pos[len] == ',')\n \t\t\tnextat = pos + len + 1; /* handle ',' */\n@@ -368,7 +368,7 @@ static const char *parse_short_magic(unsigned *magic, const char *elem)\n \n \tfor (pos = elem + 1; *pos && *pos != ':'; pos++) {\n \t\tchar ch = *pos;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\t/* Special case alias for '!' */\n \t\tif (ch == '^') {\n@@ -529,7 +529,7 @@ static void NORETURN unsupported_magic(const char *pattern,\n \t\t\t\t       unsigned magic)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < ARRAY_SIZE(pathspec_magic); i++) {\n \t\tconst struct pathspec_magic *m = pathspec_magic + i;\n \t\tif (!(magic & m->bit))\n@@ -558,7 +558,8 @@ void parse_pathspec(struct pathspec *pathspec,\n {\n \tstruct pathspec_item *item;\n \tconst char *entry = argv ? *argv : NULL;\n-\tint i, n, prefixlen, nr_exclude = 0;\n+\tsize_t i, n;\n+\tint prefixlen, nr_exclude = 0;\n \n \tmemset(pathspec, 0, sizeof(*pathspec));\n \n@@ -678,7 +679,7 @@ void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask,\n \n void copy_pathspec(struct pathspec *dst, const struct pathspec *src)\n {\n-\tint i, j;\n+\tsize_t i, j;\n \n \t*dst = *src;\n \tDUP_ARRAY(dst->items, src->items, dst->nr);\n@@ -702,7 +703,7 @@ void copy_pathspec(struct pathspec *dst, const struct pathspec *src)\n \n void clear_pathspec(struct pathspec *pathspec)\n {\n-\tint i, j;\n+\tsize_t i, j;\n \n \tfor (i = 0; i < pathspec->nr; i++) {\n \t\tfree(pathspec->items[i].match);\n@@ -724,7 +725,7 @@ int match_pathspec_attrs(struct index_state *istate,\n \t\t\t const char *name, int namelen,\n \t\t\t const struct pathspec_item *item)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *to_free = NULL;\n \n \tif (name[namelen])\n@@ -761,7 +762,8 @@ int match_pathspec_attrs(struct index_state *istate,\n int pathspec_needs_expanded_index(struct index_state *istate,\n \t\t\t\t  const struct pathspec *pathspec)\n {\n-\tunsigned int i, pos;\n+\tsize_t i;\n+\tunsigned int pos;\n \tint res = 0;\n \tchar *skip_worktree_seen = NULL;\n \ndiff --git a/pathspec.h b/pathspec.h\nindex 41f6adfbb42..e466f56981f 100644\n--- a/pathspec.h\n+++ b/pathspec.h\n@@ -28,7 +28,7 @@ struct index_state;\n  * prepared by parse_pathspec().\n  */\n struct pathspec {\n-\tint nr;\n+\tsize_t nr;\n \tunsigned int has_wildcard:1;\n \tunsigned int recursive:1;\n \tunsigned int recurse_submodules:1;\n@@ -41,7 +41,7 @@ struct pathspec {\n \t\tint len, prefix;\n \t\tint nowildcard_len;\n \t\tint flags;\n-\t\tint attr_match_nr;\n+\t\tsize_t attr_match_nr;\n \t\tstruct attr_match {\n \t\t\tchar *value;\n \t\t\tenum attr_match_mode {\ndiff --git a/pkt-line.c b/pkt-line.c\nindex ce4e73b6833..06cb8ff4fc1 100644\n--- a/pkt-line.c\n+++ b/pkt-line.c\n@@ -33,7 +33,7 @@ static int packet_trace_pack(const char *buf, unsigned int len, int sideband)\n \n static void packet_trace(const char *buf, unsigned int len, int write)\n {\n-\tint i;\n+\tunsigned i;\n \tstruct strbuf out;\n \tstatic int in_pack, sideband;\n \ndiff --git a/pretty.c b/pretty.c\nindex 1e1e21878c8..8debf6ef2a6 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -56,7 +56,7 @@ static int git_pretty_formats_config(const char *var, const char *value,\n \tstruct cmt_fmt_map *commit_format = NULL;\n \tconst char *name;\n \tconst char *fmt;\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(var, \"pretty.\", &name))\n \t\treturn 0;\n@@ -130,7 +130,7 @@ static struct cmt_fmt_map *find_commit_format_recursive(const char *sought,\n {\n \tstruct cmt_fmt_map *found = NULL;\n \tsize_t found_match_len = 0;\n-\tint i;\n+\tsize_t i;\n \n \tif (num_redirections >= commit_formats_len)\n \t\tdie(\"invalid --pretty format: \"\n@@ -259,9 +259,9 @@ static int is_rfc822_special(char ch)\n \t}\n }\n \n-static int needs_rfc822_quoting(const char *s, int len)\n+static int needs_rfc822_quoting(const char *s, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tfor (i = 0; i < len; i++)\n \t\tif (is_rfc822_special(s[i]))\n \t\t\treturn 1;\n@@ -279,9 +279,9 @@ static int last_line_length(struct strbuf *sb)\n \treturn sb->len - (i + 1);\n }\n \n-static void add_rfc822_quoted(struct strbuf *out, const char *s, int len)\n+static void add_rfc822_quoted(struct strbuf *out, const char *s, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \n \t/* just a guess, we may have to also backslash-quote */\n \tstrbuf_grow(out, len + 2);\n@@ -357,9 +357,9 @@ static int is_rfc2047_special(char ch, enum rfc2047_type type)\n \treturn !(isalnum(ch) || ch == '!' || ch == '*' || ch == '+' || ch == '-' || ch == '/');\n }\n \n-static int needs_rfc2047_encoding(const char *line, int len)\n+static int needs_rfc2047_encoding(const char *line, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < len; i++) {\n \t\tint ch = line[i];\n@@ -896,11 +896,11 @@ struct format_commit_context {\n static void parse_commit_header(struct format_commit_context *context)\n {\n \tconst char *msg = context->message;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; msg[i]; i++) {\n \t\tconst char *name;\n-\t\tint eol;\n+\t\tsize_t eol;\n \t\tfor (eol = i; msg[eol] && msg[eol] != '\\n'; eol++)\n \t\t\t; /* do nothing */\n \n@@ -930,7 +930,7 @@ void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)\n \tsize_t trimlen;\n \tsize_t start_len = sb->len;\n \tint space = 2;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < len; i++) {\n \t\tif (istitlechar(msg[i])) {\n@@ -1324,7 +1324,7 @@ static size_t parse_describe_args(const char *start, struct strvec *args)\n \t\tconst char *argval;\n \t\tsize_t arglen = 0;\n \t\tint optval = 0;\n-\t\tint i;\n+\t\tsize_t i;\n \n \t\tfor (i = 0; !found && i < ARRAY_SIZE(option); i++) {\n \t\t\tswitch (option[i].type) {\n@@ -2022,7 +2022,7 @@ void pp_title_line(struct pretty_print_context *pp,\n \tstrbuf_addch(sb, '\\n');\n \n \tif (need_8bit_cte == 0) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < pp->in_body_headers.nr; i++) {\n \t\t\tif (has_non_ascii(pp->in_body_headers.items[i].string)) {\n \t\t\t\tneed_8bit_cte = 1;\n@@ -2046,7 +2046,7 @@ void pp_title_line(struct pretty_print_context *pp,\n \t}\n \n \tif (pp->in_body_headers.nr) {\n-\t\tint i;\n+\t\tsize_t i;\n \t\tfor (i = 0; i < pp->in_body_headers.nr; i++) {\n \t\t\tstrbuf_addstr(sb, pp->in_body_headers.items[i].string);\n \t\t\tfree(pp->in_body_headers.items[i].string);\ndiff --git a/range-diff.c b/range-diff.c\nindex 4bd65ab7496..1545d42615b 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -38,7 +38,7 @@ static int read_patches(const char *range, struct string_list *list,\n \tstruct patch_util *util = NULL;\n \tint in_header = 1;\n \tchar *line, *current_filename = NULL;\n-\tssize_t len;\n+\tsize_t len;\n \tsize_t size;\n \tint ret = -1;\n \n@@ -117,7 +117,7 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tstruct patch patch = { 0 };\n \t\t\tstruct strbuf root = STRBUF_INIT;\n \t\t\tint linenr = 0;\n-\t\t\tint orig_len;\n+\t\t\tint orig_len, output;\n \n \t\t\tin_header = 0;\n \t\t\tstrbuf_addch(&buf, '\\n');\n@@ -126,15 +126,16 @@ static int read_patches(const char *range, struct string_list *list,\n \t\t\tif (eol)\n \t\t\t\t*eol = '\\n';\n \t\t\torig_len = len;\n-\t\t\tlen = parse_git_diff_header(&root, &linenr, 0, line,\n-\t\t\t\t\t\t    len, size, &patch);\n-\t\t\tif (len < 0) {\n+\t\t\toutput = parse_git_diff_header(&root, &linenr, 0, line,\n+\t\t\t\t\t\t       len, size, &patch);\n+\t\t\tif (output < 0) {\n \t\t\t\terror(_(\"could not parse git header '%.*s'\"),\n \t\t\t\t      orig_len, line);\n \t\t\t\tFREE_AND_NULL(util);\n \t\t\t\tstring_list_clear(list, 1);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n+\t\t\tlen = output;\n \t\t\tstrbuf_addstr(&buf, \" ## \");\n \t\t\tif (patch.is_new > 0)\n \t\t\t\tstrbuf_addf(&buf, \"%s (new)\", patch.new_name);\n@@ -585,7 +586,7 @@ int is_range_diff_range(const char *arg)\n {\n \tchar *copy = xstrdup(arg); /* setup_revisions() modifies it */\n \tconst char *argv[] = { \"\", copy, \"--\", NULL };\n-\tint i, positive = 0, negative = 0;\n+\tunsigned int i, positive = 0, negative = 0;\n \tstruct rev_info revs;\n \n \tinit_revisions(&revs, NULL);\n@@ -606,5 +607,5 @@ int is_range_diff_range(const char *arg)\n \n \tfree(copy);\n \trelease_revisions(&revs);\n-\treturn negative > 0 && positive > 0;\n+\treturn negative != 0 && positive != 0;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 35e5657877c..1f7ff97ca6a 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -109,7 +109,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \n static const char *alternate_index_output;\n \n-static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void set_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t    struct cache_entry *ce)\n {\n \tif (S_ISSPARSEDIR(ce->ce_mode))\n \t\tistate->sparse_index = INDEX_COLLAPSED;\n@@ -118,7 +119,8 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent\n \tadd_name_hash(istate, ce);\n }\n \n-static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n+static void replace_index_entry(struct index_state *istate, unsigned int nr,\n+\t\t\t\tstruct cache_entry *ce)\n {\n \tstruct cache_entry *old = istate->cache[nr];\n \n@@ -556,7 +558,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)\n \treturn 0;\n }\n \n-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)\n+int cache_name_stage_compare(const char *name1, size_t len1, int stage1,\n+\t\t\t     const char *name2, size_t len2, int stage2)\n {\n \tint cmp;\n \n@@ -704,7 +707,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \t\treturn pos;\n \n \t/* maybe unmerged? */\n-\tpos = -1 - pos;\n+\tpos = -pos - 1;\n \tif (pos >= istate->cache_nr ||\n \t\t\tcompare_name((ce = istate->cache[pos]), path, namelen))\n \t\treturn -1;\n@@ -719,7 +722,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,\n \n static int different_name(struct cache_entry *ce, struct cache_entry *alias)\n {\n-\tint len = ce_namelen(ce);\n+\tunsigned int len = ce_namelen(ce);\n \treturn ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);\n }\n \n@@ -736,7 +739,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,\n \t\t\t\t\t   struct cache_entry *ce,\n \t\t\t\t\t   struct cache_entry *alias)\n {\n-\tint len;\n+\tunsigned int len;\n \tstruct cache_entry *new_entry;\n \n \tif (alias->ce_flags & CE_ADDED)\n@@ -903,7 +906,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,\n \t\t\t\t     unsigned int refresh_options)\n {\n \tstruct cache_entry *ce, *ret;\n-\tint len;\n+\tsize_t len;\n \n \tif (verify_path_internal(path, mode) == PATH_INVALID) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -932,7 +935,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode,\n \t\t\t\t\t       struct mem_pool *ce_mem_pool)\n {\n \tstruct cache_entry *ce;\n-\tint len;\n+\tsize_t len;\n \n \tif (!verify_path(path, mode)) {\n \t\terror(_(\"invalid path '%s'\"), path);\n@@ -983,7 +986,7 @@ int chmod_index_entry(struct index_state *istate, struct cache_entry *ce,\n \n int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)\n {\n-\tint len = ce_namelen(a);\n+\tunsigned int len = ce_namelen(a);\n \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n }\n \n@@ -1110,8 +1113,8 @@ static int has_file_name(struct index_state *istate,\n \t\t\t const struct cache_entry *ce, int pos, int ok_to_replace)\n {\n \tint retval = 0;\n-\tint len = ce_namelen(ce);\n-\tint stage = ce_stage(ce);\n+\tunsigned int len = ce_namelen(ce);\n+\tunsigned int stage = ce_stage(ce);\n \tconst char *name = ce->name;\n \n \twhile (pos < istate->cache_nr) {\n@@ -1152,7 +1155,7 @@ int strcmp_offset(const char *s1, const char *s2, size_t *first_change)\n \t\t\tbreak;\n \n \t*first_change = k;\n-\treturn (unsigned char)s1[k] - (unsigned char)s2[k];\n+\treturn (const unsigned char)s1[k] - (const unsigned char)s2[k];\n }\n \n /*\n@@ -1599,7 +1602,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \t\t  const struct pathspec *pathspec,\n \t\t  char *seen, const char *header_msg)\n {\n-\tint i;\n+\tunsigned int i;\n \tint has_errors = 0;\n \tint really = (flags & REFRESH_REALLY) != 0;\n \tint allow_unmerged = (flags & REFRESH_UNMERGED) != 0;\n@@ -2585,7 +2588,7 @@ void discard_index(struct index_state *istate)\n  */\n void validate_cache_entries(const struct index_state *istate)\n {\n-\tint i;\n+\tunsigned i;\n \n \tif (!should_validate_cache_entries() ||!istate || !istate->initialized)\n \t\treturn;\n@@ -2610,7 +2613,7 @@ void validate_cache_entries(const struct index_state *istate)\n \n int unmerged_index(const struct index_state *istate)\n {\n-\tint i;\n+\tunsigned i;\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tif (ce_stage(istate->cache[i]))\n \t\t\treturn 1;\n@@ -2769,7 +2772,7 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \tsize = offsetof(struct ondisk_cache_entry,data) + ondisk_data_size(ce->ce_flags, 0);\n \n \tif (!previous_name) {\n-\t\tint len = ce_namelen(ce);\n+\t\tunsigned int len = ce_namelen(ce);\n \t\tcopy_cache_entry_to_ondisk(ondisk, ce);\n \t\thashwrite(f, ondisk, size);\n \t\thashwrite(f, ce->name, len);\n@@ -2849,8 +2852,8 @@ static int repo_verify_index(struct repository *repo)\n \n int has_racy_timestamp(struct index_state *istate)\n {\n-\tint entries = istate->cache_nr;\n-\tint i;\n+\tunsigned int entries = istate->cache_nr;\n+\tunsigned int i;\n \n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -3474,7 +3477,7 @@ out:\n int repo_read_index_unmerged(struct repository *repo)\n {\n \tstruct index_state *istate;\n-\tint i;\n+\tunsigned i;\n \tint unmerged = 0;\n \n \trepo_read_index(repo);\n@@ -3482,7 +3485,7 @@ int repo_read_index_unmerged(struct repository *repo)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n \t\tstruct cache_entry *new_ce;\n-\t\tint len;\n+\t\tunsigned int len;\n \n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\n@@ -3817,7 +3820,7 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta\n void prefetch_cache_entries(const struct index_state *istate,\n \t\t\t    must_prefetch_predicate must_prefetch)\n {\n-\tint i;\n+\tunsigned i;\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\ndiff --git a/remote-curl.c b/remote-curl.c\nindex a76b6405eb2..78292f348f4 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -206,7 +206,7 @@ static int set_option(const char *name, const char *value)\n \t\toptions.filter = xstrdup(value);\n \t\treturn 0;\n \t} else if (!strcmp(name, \"object-format\")) {\n-\t\tint algo;\n+\t\tunsigned algo;\n \t\toptions.object_format = 1;\n \t\tif (strcmp(value, \"true\")) {\n \t\t\talgo = hash_algo_by_name(value);\ndiff --git a/repository.c b/repository.c\nindex 937fa974b38..b283b95eb06 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -94,7 +94,7 @@ void repo_set_gitdir(struct repository *repo,\n \t\t\trepo->gitdir, \"index\");\n }\n \n-void repo_set_hash_algo(struct repository *repo, int hash_algo)\n+void repo_set_hash_algo(struct repository *repo, unsigned hash_algo)\n {\n \trepo->hash_algo = &hash_algos[hash_algo];\n }\ndiff --git a/repository.h b/repository.h\nindex e8c67ffe165..dda7cbdc94b 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -187,7 +187,7 @@ struct set_gitdir_args {\n void repo_set_gitdir(struct repository *repo, const char *root,\n \t\t     const struct set_gitdir_args *extra_args);\n void repo_set_worktree(struct repository *repo, const char *path);\n-void repo_set_hash_algo(struct repository *repo, int algo);\n+void repo_set_hash_algo(struct repository *repo, unsigned algo);\n void initialize_the_repository(void);\n RESULT_MUST_BE_USED\n int repo_init(struct repository *r, const char *gitdir, const char *worktree);\ndiff --git a/run-command.c b/run-command.c\nindex 6bd16acb060..706b3d8e0f6 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1650,8 +1650,9 @@ static void pp_buffer_stderr(struct parallel_processes *pp,\n \tfor (size_t i = 0; i < opts->processes; i++) {\n \t\tif (pp->children[i].state == GIT_CP_WORKING &&\n \t\t    pp->pfd[i].revents & (POLLIN | POLLHUP)) {\n-\t\t\tint n = strbuf_read_once(&pp->children[i].err,\n-\t\t\t\t\t\t pp->children[i].process.err, 0);\n+\t\t\tssize_t n = strbuf_read_once(\n+\t\t\t\t&pp->children[i].err,\n+\t\t\t\tpp->children[i].process.err, 0);\n \t\t\tif (n == 0) {\n \t\t\t\tclose(pp->children[i].process.err);\n \t\t\t\tpp->children[i].state = GIT_CP_WAIT_CLEANUP;\ndiff --git a/shallow.c b/shallow.c\nindex 17f9bcdb5f3..e791c8160a8 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -803,7 +803,7 @@ static void post_assign_shallow(struct shallow_info *info,\n }\n \n /* (Delayed) step 7, reachability test at commit level */\n-int delayed_reachability_test(struct shallow_info *si, int c)\n+int delayed_reachability_test(struct shallow_info *si, size_t c)\n {\n \tif (si->need_reachability_test[c]) {\n \t\tstruct commit *commit = lookup_commit(the_repository,\ndiff --git a/shallow.h b/shallow.h\nindex aba6ff58294..be77c0db079 100644\n--- a/shallow.h\n+++ b/shallow.h\n@@ -76,7 +76,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *);\n void assign_shallow_commits_to_refs(struct shallow_info *info,\n \t\t\t\t    uint32_t **used,\n \t\t\t\t    int *ref_status);\n-int delayed_reachability_test(struct shallow_info *si, int c);\n+int delayed_reachability_test(struct shallow_info *si, size_t c);\n \n extern struct trace_key trace_shallow;\n \ndiff --git a/strbuf.c b/strbuf.c\nindex c383f41a3c5..a6eca686b6d 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -172,7 +172,7 @@ struct strbuf **strbuf_split_buf(const char *str, size_t slen,\n \tstruct strbuf *t;\n \n \twhile (slen) {\n-\t\tint len = slen;\n+\t\tsize_t len = slen;\n \t\tif (max <= 0 || nr + 1 < max) {\n \t\t\tconst char *end = memchr(str, terminator, slen);\n \t\t\tif (end)\n@@ -1075,7 +1075,7 @@ void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm,\n void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,\n \t\t\t\t   const struct object_id *oid, int abbrev_len)\n {\n-\tint r;\n+\tunsigned int r;\n \tstrbuf_grow(sb, GIT_MAX_HEXSZ + 1);\n \tr = repo_find_unique_abbrev_r(repo, sb->buf + sb->len, oid, abbrev_len);\n \tstrbuf_setlen(sb, sb->len + r);\ndiff --git a/string-list.c b/string-list.c\nindex 42bacaec55b..29208b2f51b 100644\n--- a/string-list.c\n+++ b/string-list.c\n@@ -263,7 +263,8 @@ int unsorted_string_list_has_string(struct string_list *list,\n \treturn unsorted_string_list_lookup(list, string) != NULL;\n }\n \n-void unsorted_string_list_delete_item(struct string_list *list, int i, int free_util)\n+void unsorted_string_list_delete_item(struct string_list *list, size_t i,\n+\t\t\t\t      int free_util)\n {\n \tif (list->strdup_strings)\n \t\tfree(list->items[i].string);\ndiff --git a/string-list.h b/string-list.h\nindex c7b0d5d0008..401d0bc1052 100644\n--- a/string-list.h\n+++ b/string-list.h\n@@ -241,7 +241,8 @@ struct string_list_item *unsorted_string_list_lookup(struct string_list *list,\n  * string_list is set. The third parameter controls if the `util`\n  * pointer of the items should be freed or not.\n  */\n-void unsorted_string_list_delete_item(struct string_list *list, int i, int free_util);\n+void unsorted_string_list_delete_item(struct string_list *list, size_t i,\n+\t\t\t\t      int free_util);\n \n /**\n  * Split string into substrings on character `delim` and append the\ndiff --git a/sub-process.c b/sub-process.c\nindex 6d4232294db..1d380ef0405 100644\n--- a/sub-process.c\n+++ b/sub-process.c\n@@ -116,7 +116,7 @@ static int handshake_version(struct child_process *process,\n \t\t\t     int *chosen_version)\n {\n \tint version_scratch;\n-\tint i;\n+\tsize_t i;\n \tchar *line;\n \tconst char *p;\n \n@@ -162,7 +162,7 @@ static int handshake_capabilities(struct child_process *process,\n \t\t\t\t  struct subprocess_capability *capabilities,\n \t\t\t\t  unsigned int *supported_capabilities)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *line;\n \n \tfor (i = 0; capabilities[i].name; i++) {\ndiff --git a/submodule.c b/submodule.c\nindex 3a0dfc417c0..65937c1eaf1 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -173,10 +173,10 @@ void add_submodule_odb_by_path(const char *path)\n \tstring_list_insert(&added_submodule_odb_paths, xstrdup(path));\n }\n \n-int register_all_submodule_odb_as_alternates(void)\n+size_t register_all_submodule_odb_as_alternates(void)\n {\n-\tint i;\n-\tint ret = added_submodule_odb_paths.nr;\n+\tsize_t i;\n+\tsize_t ret = added_submodule_odb_paths.nr;\n \n \tfor (i = 0; i < added_submodule_odb_paths.nr; i++)\n \t\tadd_to_alternates_memory(added_submodule_odb_paths.items[i].string);\n@@ -324,7 +324,7 @@ int is_submodule_populated_gently(const char *path, int *return_error_code)\n void die_in_unpopulated_submodule(struct index_state *istate,\n \t\t\t\t  const char *prefix)\n {\n-\tint i, prefixlen;\n+\tsize_t i, prefixlen;\n \n \tif (!prefix)\n \t\treturn;\n@@ -333,7 +333,7 @@ void die_in_unpopulated_submodule(struct index_state *istate,\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n-\t\tint ce_len = ce_namelen(ce);\n+\t\tsize_t ce_len = ce_namelen(ce);\n \n \t\tif (!S_ISGITLINK(ce->ce_mode))\n \t\t\tcontinue;\n@@ -354,7 +354,8 @@ void die_in_unpopulated_submodule(struct index_state *istate,\n void die_path_inside_submodule(struct index_state *istate,\n \t\t\t       const struct pathspec *ps)\n {\n-\tint i, j;\n+\tunsigned int i;\n+\tint j;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct cache_entry *ce = istate->cache[i];\n@@ -1206,7 +1207,8 @@ int push_unpushed_submodules(struct repository *r,\n \t\t\t     const struct string_list *push_options,\n \t\t\t     int dry_run)\n {\n-\tint i, ret = 1;\n+\tsize_t i;\n+\tint ret = 1;\n \tstruct string_list needs_pushing = STRING_LIST_INIT_DUP;\n \n \tif (!find_unpushed_submodules(r, commits,\ndiff --git a/submodule.h b/submodule.h\nindex c55a25ca37d..a62af231e59 100644\n--- a/submodule.h\n+++ b/submodule.h\n@@ -109,7 +109,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags);\n  * added as alternates in the_repository.\n  */\n void add_submodule_odb_by_path(const char *path);\n-int register_all_submodule_odb_as_alternates(void);\n+size_t register_all_submodule_odb_as_alternates(void);\n \n /*\n  * Checks if there are submodule changes in a..b. If a is the null OID,\ndiff --git a/trailer.c b/trailer.c\nindex 0fd5b142a37..be42417fe04 100644\n--- a/trailer.c\n+++ b/trailer.c\n@@ -518,7 +518,7 @@ static int git_trailer_config(const char *conf_key, const char *value,\n \tstruct conf_info *conf;\n \tchar *name = NULL;\n \tenum trailer_info_type type;\n-\tint i;\n+\tsize_t i;\n \n \tif (!skip_prefix(conf_key, \"trailer.\", &trailer_item))\n \t\treturn 0;\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 3ea7c2bb5ad..7afd785ca05 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -295,7 +295,8 @@ static int string_list_set_helper_option(struct helper_data *data,\n \t\t\t\t\t struct string_list *list)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tint i, ret = 0;\n+\tint ret = 0;\n+\tsize_t i;\n \n \tfor (i = 0; i < list->nr; i++) {\n \t\tstrbuf_addf(&buf, \"option %s \", name);\n@@ -315,7 +316,8 @@ static int set_helper_option(struct transport *transport,\n {\n \tstruct helper_data *data = transport->data;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tint i, ret, is_bool = 0;\n+\tsize_t i;\n+\tint ret, is_bool = 0;\n \n \tget_helper(transport);\n \n@@ -459,7 +461,7 @@ static int get_exporter(struct transport *transport,\n {\n \tstruct helper_data *data = transport->data;\n \tstruct child_process *helper = get_helper(transport);\n-\tint i;\n+\tsize_t i;\n \n \tchild_process_init(fastexport);\n \n@@ -1226,7 +1228,7 @@ static struct ref *get_refs_list_using_list(struct transport *transport,\n \t\telse if (buf.buf[0] == ':') {\n \t\t\tconst char *value;\n \t\t\tif (skip_prefix(buf.buf, \":object-format \", &value)) {\n-\t\t\t\tint algo = hash_algo_by_name(value);\n+\t\t\t\tunsigned algo = hash_algo_by_name(value);\n \t\t\t\tif (algo == GIT_HASH_UNKNOWN)\n \t\t\t\t\tdie(_(\"unsupported object format '%s'\"),\n \t\t\t\t\t    value);\ndiff --git a/transport.c b/transport.c\nindex 77a61a9d7bb..8d949a9bdb5 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -42,7 +42,7 @@ static int transport_color_config(void)\n \t\t\"color.transport.rejected\"\n \t}, *key = \"color.transport\";\n \tchar *value;\n-\tint i;\n+\tsize_t i;\n \tstatic int initialized;\n \n \tif (initialized)\n@@ -147,7 +147,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport,\n {\n \tstruct bundle_transport_data *data = transport->data;\n \tstruct ref *result = NULL;\n-\tint i;\n+\tsize_t i;\n \n \tif (for_push)\n \t\treturn NULL;\n@@ -1233,7 +1233,7 @@ void transport_set_verbosity(struct transport *transport, int verbosity,\n \n static void die_with_unpushed_submodules(struct string_list *needs_pushing)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfprintf(stderr, _(\"The following submodule paths contain changes that can\\n\"\n \t\t\t\"not be found on any remote:\\n\"));\n@@ -1552,7 +1552,7 @@ int transport_get_remote_bundle_uri(struct transport *transport)\n void transport_unlock_pack(struct transport *transport, unsigned int flags)\n {\n \tint in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < transport->pack_lockfiles.nr; i++)\n \t\tif (in_signal_handler)\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 3d05e45a279..6290e4535d0 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -2285,8 +2285,8 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t * we are about to extract \"ce->name\"; we would not want to lose\n \t * anything in the existing directory there.\n \t */\n-\tint namelen;\n-\tint i;\n+\tunsigned int namelen;\n+\tunsigned int i;\n \tstruct dir_struct d;\n \tchar *pathbuf;\n \tint cnt = 0;\n@@ -2313,7 +2313,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t     i < o->src_index->cache_nr;\n \t     i++) {\n \t\tstruct cache_entry *ce2 = o->src_index->cache[i];\n-\t\tint len = ce_namelen(ce2);\n+\t\tunsigned int len = ce_namelen(ce2);\n \t\tif (len < namelen ||\n \t\t    strncmp(ce->name, ce2->name, namelen) ||\n \t\t    ce2->name[namelen] != '/')\n@@ -2333,7 +2333,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,\n \t}\n \n \t/* Do not lose a locally present file that is not ignored. */\n-\tpathbuf = xstrfmt(\"%.*s/\", namelen, ce->name);\n+\tpathbuf = xstrfmt(\"%.*s/\", (int)namelen, ce->name);\n \n \tmemset(&d, 0, sizeof(d));\n \tif (o->dir)\n@@ -2876,7 +2876,7 @@ int twoway_merge(const struct cache_entry * const *src,\n \tconst struct cache_entry *newtree = src[2];\n \n \tif (o->merge_size != 2)\n-\t\treturn error(\"Cannot do a twoway merge of %d trees\",\n+\t\treturn error(\"Cannot do a twoway merge of %u trees\",\n \t\t\t     o->merge_size);\n \n \tif (oldtree == o->df_conflict_entry)\n@@ -2958,7 +2958,7 @@ int bind_merge(const struct cache_entry * const *src,\n \tconst struct cache_entry *a = src[1];\n \n \tif (o->merge_size != 1)\n-\t\treturn error(\"Cannot do a bind merge of %d trees\",\n+\t\treturn error(\"Cannot do a bind merge of %u trees\",\n \t\t\t     o->merge_size);\n \tif (a && old)\n \t\treturn o->quiet ? -1 :\n@@ -2984,7 +2984,7 @@ int oneway_merge(const struct cache_entry * const *src,\n \tconst struct cache_entry *a = src[1];\n \n \tif (o->merge_size != 1)\n-\t\treturn error(\"Cannot do a oneway merge of %d trees\",\n+\t\treturn error(\"Cannot do a oneway merge of %u trees\",\n \t\t\t     o->merge_size);\n \n \tif (!a || a == o->df_conflict_entry)\n@@ -3021,7 +3021,7 @@ int stash_worktree_untracked_merge(const struct cache_entry * const *src,\n \tconst struct cache_entry *untracked = src[2];\n \n \tif (o->merge_size != 2)\n-\t\tBUG(\"invalid merge_size: %d\", o->merge_size);\n+\t\tBUG(\"invalid merge_size: %u\", o->merge_size);\n \n \tif (worktree && untracked)\n \t\treturn error(_(\"worktree and untracked commit have duplicate entries: %s\"),\ndiff --git a/unpack-trees.h b/unpack-trees.h\nindex 3a7b3e5f007..f2d87900c9d 100644\n--- a/unpack-trees.h\n+++ b/unpack-trees.h\n@@ -88,7 +88,7 @@ struct unpack_trees_options {\n \tstruct string_list unpack_rejects[NB_UNPACK_TREES_WARNING_TYPES];\n \n \tint head_idx;\n-\tint merge_size;\n+\tunsigned merge_size;\n \n \tstruct cache_entry *df_conflict_entry;\n \tvoid *unpack_data;\ndiff --git a/wt-status.c b/wt-status.c\nindex 3162241a570..d58fd61bf6d 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -151,7 +151,7 @@ void wt_status_prepare(struct repository *r, struct wt_status *s)\n \n static void wt_longstatus_print_unmerged_header(struct wt_status *s)\n {\n-\tint i;\n+\tsize_t i;\n \tint del_mod_conflict = 0;\n \tint both_deleted = 0;\n \tint not_deleted = 0;\n@@ -700,7 +700,7 @@ static int add_file_to_list(const struct object_id *oid,\n static void wt_status_collect_changes_initial(struct wt_status *s)\n {\n \tstruct index_state *istate = s->repo->index;\n-\tint i;\n+\tunsigned int i;\n \n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct string_list_item *it;\n@@ -803,7 +803,7 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \n static int has_unmerged(struct wt_status *s)\n {\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n@@ -854,7 +854,7 @@ void wt_status_state_free_buffers(struct wt_status_state *state)\n static void wt_longstatus_print_unmerged(struct wt_status *s)\n {\n \tint shown_header = 0;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n@@ -877,7 +877,7 @@ static void wt_longstatus_print_unmerged(struct wt_status *s)\n static void wt_longstatus_print_updated(struct wt_status *s)\n {\n \tint shown_header = 0;\n-\tint i;\n+\tsize_t i;\n \n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n@@ -905,7 +905,7 @@ static void wt_longstatus_print_updated(struct wt_status *s)\n static int wt_status_check_worktree_changes(struct wt_status *s,\n \t\t\t\t\t     int *dirty_submodules)\n {\n-\tint i;\n+\tsize_t i;\n \tint changes = 0;\n \n \t*dirty_submodules = 0;\n@@ -928,7 +928,8 @@ static int wt_status_check_worktree_changes(struct wt_status *s,\n \n static void wt_longstatus_print_changed(struct wt_status *s)\n {\n-\tint i, dirty_submodules;\n+\tsize_t i;\n+\tint dirty_submodules;\n \tint worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);\n \n \tif (!worktree_changes)\n@@ -1028,7 +1029,7 @@ static void wt_longstatus_print_other(struct wt_status *s,\n \t\t\t\t      const char *what,\n \t\t\t\t      const char *how)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstatic struct string_list output = STRING_LIST_INIT_DUP;\n \tstruct column_options copts;\n@@ -1164,7 +1165,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)\n \tconst char *cp, *ep, *branch_name;\n \tstruct branch *branch;\n \tchar comment_line_string[3];\n-\tint i;\n+\tunsigned int i;\n \tuint64_t t_begin = 0;\n \n \tassert(s->branch && !s->is_initial);\n@@ -1320,7 +1321,7 @@ static int split_commit_in_progress(struct wt_status *s)\n static void abbrev_oid_in_line(struct strbuf *line)\n {\n \tstruct strbuf **split;\n-\tint i;\n+\tsize_t i;\n \n \tif (starts_with(line->buf, \"exec \") ||\n \t    starts_with(line->buf, \"x \") ||\n@@ -1379,8 +1380,8 @@ static void show_rebase_information(struct wt_status *s,\n \t\t\t\t    const char *color)\n {\n \tif (s->state.rebase_interactive_in_progress) {\n-\t\tint i;\n-\t\tint nr_lines_to_show = 2;\n+\t\tsize_t i;\n+\t\tconst size_t nr_lines_to_show = 2;\n \n \t\tstruct string_list have_done = STRING_LIST_INIT_DUP;\n \t\tstruct string_list yet_to_do = STRING_LIST_INIT_DUP;\n@@ -1729,7 +1730,7 @@ static void wt_status_check_sparse_checkout(struct repository *r,\n \t\t\t\t\t    struct wt_status_state *state)\n {\n \tint skip_worktree = 0;\n-\tint i;\n+\tunsigned int i;\n \n \tif (!core_apply_sparse_checkout || r->index->cache_nr == 0) {\n \t\t/*\n@@ -2487,7 +2488,7 @@ static void wt_porcelain_v2_print(struct wt_status *s)\n {\n \tstruct wt_status_change_data *d;\n \tstruct string_list_item *it;\n-\tint i;\n+\tsize_t i;\n \n \tif (s->show_branch)\n \t\twt_porcelain_v2_print_tracking(s);\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex e87950de32e..d4bec9905ff 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -210,8 +210,8 @@ static long ff_regexp(const char *line, long len,\n {\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint i;\n-\tint result;\n+\tsize_t i;\n+\tlong result;\n \n \t/* Exclude terminating newline (and cr) from matching */\n \tif (len > 0 && line[len-1] == '\\n') {\n@@ -244,7 +244,7 @@ static long ff_regexp(const char *line, long len,\n \n void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n-\tint i;\n+\tsize_t i;\n \tstruct ff_regs *regs;\n \n \txecfg->find_func = ff_regexp;\n\nbase-commit: 73876f4861cd3d187a4682290ab75c9dccadbc56\n-- \ngitgitgadget\n"},{"id":"473562","messageId":"xmqq3565q1a1.fsf@gitster.g","threadId":"58962","inReplyTo":"pull.1399.v16.git.git.1678886439331.gitgitgadget@gmail.com","subject":"Re: [PATCH v16] git: change variable types to match what is assigned to them","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-15T19:09:58Z","receivedAt":"2023-03-15T19:10:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rose via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>       @@ add-interactive.c: static ssize_t find_unique(const char *string, struct prefix_item_list *list)\n>      @@ advice.c: void advise_if_enabled(enum advice_type type, const char *advice, ...)\n>        \n>        \tif (!strcmp(var, \"color.advice\")) {\n>        \t\tadvice_use_color = git_config_colorbool(var, value);\n>      +@@ advice.c: int git_default_advice_config(const char *var, const char *value)\n>      + \n>      + void list_config_advices(struct string_list *list, const char *prefix)\n>      + {\n>      +-\tint i;\n>      ++\tsize_t i;\n>      + \n>      + \tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++)\n>      + \t\tlist_config_item(list, prefix, advice_setting[i].key);\n\nHere, the advice_setting[] is not an attacker controlled array with\nan unbound size.  It is a known static array the program prepares.\nConverting it to use size_t as an index is a totally pointless\nchurn.\n\nSome of the changes in this patch may have merit, but seeing a\nchange like this as the first change in the iteration makes me lose\ninterest in reading this huge message that weighs more than 7000\nlines.  If you are looking for \"for (x = 0;\" where x is declared of\nany type other than size_t and blindly converting them, please stop.\n"}]}