Git fork

global: trivial conversions to fix `-Wsign-compare` warnings

We have a bunch of loops which iterate up to an unsigned boundary using
a signed index, which generates warnigs because we compare a signed and
unsigned value in the loop condition. Address these sites for trivial
cases and enable `-Wsign-compare` warnings for these code units.

This patch only adapts those code units where we can drop the
`DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
80c9e70e 25435e4a

+105 -238
+2 -7
advice.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "advice.h" 5 3 #include "config.h" ··· 162 160 int git_default_advice_config(const char *var, const char *value) 163 161 { 164 162 const char *k, *slot_name; 165 - int i; 166 163 167 164 if (!strcmp(var, "color.advice")) { 168 165 advice_use_color = git_config_colorbool(var, value); ··· 181 178 if (!skip_prefix(var, "advice.", &k)) 182 179 return 0; 183 180 184 - for (i = 0; i < ARRAY_SIZE(advice_setting); i++) { 181 + for (size_t i = 0; i < ARRAY_SIZE(advice_setting); i++) { 185 182 if (strcasecmp(k, advice_setting[i].key)) 186 183 continue; 187 184 advice_setting[i].level = git_config_bool(var, value) ··· 195 192 196 193 void list_config_advices(struct string_list *list, const char *prefix) 197 194 { 198 - int i; 199 - 200 - for (i = 0; i < ARRAY_SIZE(advice_setting); i++) 195 + for (size_t i = 0; i < ARRAY_SIZE(advice_setting); i++) 201 196 list_config_item(list, prefix, advice_setting[i].key); 202 197 } 203 198
+1 -4
base85.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "base85.h" 5 3 ··· 31 29 static char de85[256]; 32 30 static void prep_base85(void) 33 31 { 34 - int i; 35 32 if (de85['Z']) 36 33 return; 37 - for (i = 0; i < ARRAY_SIZE(en85); i++) { 34 + for (size_t i = 0; i < ARRAY_SIZE(en85); i++) { 38 35 int ch = en85[i]; 39 36 de85[ch] = i + 1; 40 37 }
+4 -6
builtin/add.c
··· 4 4 * Copyright (C) 2006 Linus Torvalds 5 5 */ 6 6 7 - #define DISABLE_SIGN_COMPARE_WARNINGS 8 - 9 7 #include "builtin.h" 10 8 #include "advice.h" 11 9 #include "config.h" ··· 42 40 char flip, 43 41 int show_only) 44 42 { 45 - int i, ret = 0; 43 + int ret = 0; 46 44 47 - for (i = 0; i < repo->index->cache_nr; i++) { 45 + for (size_t i = 0; i < repo->index->cache_nr; i++) { 48 46 struct cache_entry *ce = repo->index->cache[i]; 49 47 int err; 50 48 ··· 72 70 const struct pathspec *pathspec, 73 71 int flags) 74 72 { 75 - int i, retval = 0; 73 + int retval = 0; 76 74 77 - for (i = 0; i < repo->index->cache_nr; i++) { 75 + for (size_t i = 0; i < repo->index->cache_nr; i++) { 78 76 struct cache_entry *ce = repo->index->cache[i]; 79 77 80 78 if (!include_sparse &&
-1
builtin/branch.c
··· 6 6 */ 7 7 8 8 #define USE_THE_REPOSITORY_VARIABLE 9 - #define DISABLE_SIGN_COMPARE_WARNINGS 10 9 11 10 #include "builtin.h" 12 11 #include "config.h"
+2 -2
builtin/difftool.c
··· 13 13 */ 14 14 15 15 #define USE_THE_REPOSITORY_VARIABLE 16 - #define DISABLE_SIGN_COMPARE_WARNINGS 17 16 18 17 #include "builtin.h" 19 18 ··· 367 366 char *lbase_dir = NULL, *rbase_dir = NULL; 368 367 size_t ldir_len, rdir_len, wtdir_len; 369 368 const char *workdir, *tmp; 370 - int ret = 0, i; 369 + int ret = 0; 370 + size_t i; 371 371 FILE *fp = NULL; 372 372 struct hashmap working_tree_dups = HASHMAP_INIT(working_tree_entry_cmp, 373 373 NULL);
+2 -3
builtin/for-each-repo.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "config.h" ··· 38 37 { 39 38 static const char *config_key = NULL; 40 39 int keep_going = 0; 41 - int i, result = 0; 40 + int result = 0; 42 41 const struct string_list *values; 43 42 int err; 44 43 ··· 63 62 else if (err) 64 63 return 0; 65 64 66 - for (i = 0; i < values->nr; i++) { 65 + for (size_t i = 0; i < values->nr; i++) { 67 66 int ret = run_command_on_repo(values->items[i].string, argc, argv); 68 67 if (ret) { 69 68 if (!keep_going)
+1 -3
builtin/help.c
··· 3 3 */ 4 4 5 5 #define USE_THE_REPOSITORY_VARIABLE 6 - #define DISABLE_SIGN_COMPARE_WARNINGS 7 6 8 7 #include "builtin.h" 9 8 #include "config.h" ··· 131 130 struct string_list keys = STRING_LIST_INIT_DUP; 132 131 struct string_list keys_uniq = STRING_LIST_INIT_DUP; 133 132 struct string_list_item *item; 134 - int i; 135 133 136 134 for (p = config_name_list; *p; p++) { 137 135 const char *var = *p; ··· 158 156 e->prefix, e->placeholder); 159 157 160 158 string_list_sort(&keys); 161 - for (i = 0; i < keys.nr; i++) { 159 + for (size_t i = 0; i < keys.nr; i++) { 162 160 const char *var = keys.items[i].string; 163 161 const char *wildcard, *tag, *cut; 164 162 const char *dot = NULL;
+1 -2
builtin/mailsplit.c
··· 175 175 char *file = NULL; 176 176 FILE *f = NULL; 177 177 int ret = -1; 178 - int i; 179 178 struct string_list list = STRING_LIST_INIT_DUP; 180 179 181 180 list.cmp = maildir_filename_cmp; ··· 183 182 if (populate_maildir_list(&list, maildir) < 0) 184 183 goto out; 185 184 186 - for (i = 0; i < list.nr; i++) { 185 + for (size_t i = 0; i < list.nr; i++) { 187 186 char *name; 188 187 189 188 free(file);
+2 -4
builtin/merge-tree.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "tree-walk.h" ··· 499 498 if (!result.clean) { 500 499 struct string_list conflicted_files = STRING_LIST_INIT_NODUP; 501 500 const char *last = NULL; 502 - int i; 503 501 504 502 merge_get_conflicted_files(&result, &conflicted_files); 505 - for (i = 0; i < conflicted_files.nr; i++) { 503 + for (size_t i = 0; i < conflicted_files.nr; i++) { 506 504 const char *name = conflicted_files.items[i].string; 507 505 struct stage_info *c = conflicted_files.items[i].util; 508 506 if (!o->name_only) ··· 586 584 587 585 if (xopts.nr && o.mode == MODE_TRIVIAL) 588 586 die(_("--trivial-merge is incompatible with all other options")); 589 - for (int x = 0; x < xopts.nr; x++) 587 + for (size_t x = 0; x < xopts.nr; x++) 590 588 if (parse_merge_opt(&o.merge_options, xopts.v[x])) 591 589 die(_("unknown strategy option: -X%s"), xopts.v[x]); 592 590
+1 -3
builtin/pack-redundant.c
··· 7 7 */ 8 8 9 9 #define USE_THE_REPOSITORY_VARIABLE 10 - #define DISABLE_SIGN_COMPARE_WARNINGS 11 10 12 11 #include "builtin.h" 13 12 #include "gettext.h" ··· 391 390 static void sort_pack_list(struct pack_list **pl) 392 391 { 393 392 struct pack_list **ary, *p; 394 - int i; 395 393 size_t n = pack_list_size(*pl); 396 394 397 395 if (n < 2) ··· 405 403 QSORT(ary, n, cmp_remaining_objects); 406 404 407 405 /* link them back again */ 408 - for (i = 0; i < n - 1; i++) 406 + for (size_t i = 0; i < n - 1; i++) 409 407 ary[i]->next = ary[i + 1]; 410 408 ary[n - 1]->next = NULL; 411 409 *pl = ary[0];
+1 -3
builtin/pull.c
··· 7 7 */ 8 8 9 9 #define USE_THE_REPOSITORY_VARIABLE 10 - #define DISABLE_SIGN_COMPARE_WARNINGS 11 10 12 11 #include "builtin.h" 13 12 #include "advice.h" ··· 943 942 static int already_up_to_date(struct object_id *orig_head, 944 943 struct oid_array *merge_heads) 945 944 { 946 - int i; 947 945 struct commit *ours; 948 946 949 947 ours = lookup_commit_reference(the_repository, orig_head); 950 - for (i = 0; i < merge_heads->nr; i++) { 948 + for (size_t i = 0; i < merge_heads->nr; i++) { 951 949 struct commit_list *list = NULL; 952 950 struct commit *theirs; 953 951 int ok;
+2 -3
builtin/push.c
··· 3 3 */ 4 4 5 5 #define USE_THE_REPOSITORY_VARIABLE 6 - #define DISABLE_SIGN_COMPARE_WARNINGS 7 6 8 7 #include "builtin.h" 9 8 #include "advice.h" ··· 420 419 const struct string_list *push_options, 421 420 struct remote *remote) 422 421 { 423 - int i, errs; 422 + int errs; 424 423 struct strvec *url; 425 424 struct refspec *push_refspec = &rs; 426 425 ··· 435 434 } 436 435 errs = 0; 437 436 url = push_url_of_remote(remote); 438 - for (i = 0; i < url->nr; i++) { 437 + for (size_t i = 0; i < url->nr; i++) { 439 438 struct transport *transport = 440 439 transport_get(remote, url->v[i]); 441 440 if (flags & TRANSPORT_PUSH_OPTIONS)
+4 -5
builtin/rerere.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "config.h" ··· 57 56 struct repository *repo UNUSED) 58 57 { 59 58 struct string_list merge_rr = STRING_LIST_INIT_DUP; 60 - int i, autoupdate = -1, flags = 0; 59 + int autoupdate = -1, flags = 0; 61 60 62 61 struct option options[] = { 63 62 OPT_SET_INT(0, "rerere-autoupdate", &autoupdate, ··· 100 99 if (setup_rerere(the_repository, &merge_rr, 101 100 flags | RERERE_READONLY) < 0) 102 101 return 0; 103 - for (i = 0; i < merge_rr.nr; i++) 102 + for (size_t i = 0; i < merge_rr.nr; i++) 104 103 printf("%s\n", merge_rr.items[i].string); 105 104 } else if (!strcmp(argv[0], "remaining")) { 106 105 rerere_remaining(the_repository, &merge_rr); 107 - for (i = 0; i < merge_rr.nr; i++) { 106 + for (size_t i = 0; i < merge_rr.nr; i++) { 108 107 if (merge_rr.items[i].util != RERERE_RESOLVED) 109 108 printf("%s\n", merge_rr.items[i].string); 110 109 else ··· 116 115 if (setup_rerere(the_repository, &merge_rr, 117 116 flags | RERERE_READONLY) < 0) 118 117 return 0; 119 - for (i = 0; i < merge_rr.nr; i++) { 118 + for (size_t i = 0; i < merge_rr.nr; i++) { 120 119 const char *path = merge_rr.items[i].string; 121 120 const struct rerere_id *id = merge_rr.items[i].util; 122 121 if (diff_two(rerere_path(id, "preimage"), path, path, path))
+2 -5
builtin/stash.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "abspath.h" ··· 875 874 struct tree *tree[ARRAY_SIZE(oid)]; 876 875 struct tree_desc tree_desc[ARRAY_SIZE(oid)]; 877 876 struct unpack_trees_options unpack_tree_opt = { 0 }; 878 - int i; 879 877 880 - for (i = 0; i < ARRAY_SIZE(oid); i++) { 878 + for (size_t i = 0; i < ARRAY_SIZE(oid); i++) { 881 879 tree[i] = parse_tree_indirect(oid[i]); 882 880 if (parse_tree(tree[i]) < 0) 883 881 die(_("failed to parse tree")); ··· 1559 1557 1560 1558 repo_read_index_preload(the_repository, NULL, 0); 1561 1559 if (!include_untracked && ps->nr) { 1562 - int i; 1563 1560 char *ps_matched = xcalloc(ps->nr, 1); 1564 1561 1565 1562 /* TODO: audit for interaction with sparse-index. */ 1566 1563 ensure_full_index(the_repository->index); 1567 - for (i = 0; i < the_repository->index->cache_nr; i++) 1564 + for (size_t i = 0; i < the_repository->index->cache_nr; i++) 1568 1565 ce_path_match(the_repository->index, the_repository->index->cache[i], ps, 1569 1566 ps_matched); 1570 1567
+3 -5
builtin/submodule--helper.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "abspath.h" ··· 196 195 struct pathspec *pathspec, 197 196 struct module_list *list) 198 197 { 199 - int i, result = 0; 198 + int result = 0; 200 199 char *ps_matched = NULL; 201 200 202 201 parse_pathspec(pathspec, 0, ··· 209 208 if (repo_read_index(the_repository) < 0) 210 209 die(_("index file corrupt")); 211 210 212 - for (i = 0; i < the_repository->index->cache_nr; i++) { 211 + for (size_t i = 0; i < the_repository->index->cache_nr; i++) { 213 212 const struct cache_entry *ce = the_repository->index->cache[i]; 214 213 215 214 if (!match_pathspec(the_repository->index, pathspec, ce->name, ce_namelen(ce), ··· 3398 3397 die(_("index file corrupt")); 3399 3398 3400 3399 if (ps.nr) { 3401 - int i; 3402 3400 char *ps_matched = xcalloc(ps.nr, 1); 3403 3401 3404 3402 /* TODO: audit for interaction with sparse-index. */ ··· 3408 3406 * Since there is only one pathspec, we just need to 3409 3407 * check ps_matched[0] to know if a cache entry matched. 3410 3408 */ 3411 - for (i = 0; i < the_repository->index->cache_nr; i++) { 3409 + for (size_t i = 0; i < the_repository->index->cache_nr; i++) { 3412 3410 ce_path_match(the_repository->index, the_repository->index->cache[i], &ps, 3413 3411 ps_matched); 3414 3412
+1 -3
builtin/var.c
··· 5 5 */ 6 6 7 7 #define USE_THE_REPOSITORY_VARIABLE 8 - #define DISABLE_SIGN_COMPARE_WARNINGS 9 8 10 9 #include "builtin.h" 11 10 ··· 181 180 if ((val = ptr->read(0))) { 182 181 if (ptr->multivalued && *val) { 183 182 struct string_list list = STRING_LIST_INIT_DUP; 184 - int i; 185 183 186 184 string_list_split(&list, val, '\n', -1); 187 - for (i = 0; i < list.nr; i++) 185 + for (size_t i = 0; i < list.nr; i++) 188 186 printf("%s=%s\n", ptr->name, list.items[i].string); 189 187 string_list_clear(&list, 0); 190 188 } else {
+1 -3
commit.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "tag.h" ··· 1766 1765 { &compat_sig, r->compat_hash_algo }, 1767 1766 { &sig, r->hash_algo }, 1768 1767 }; 1769 - int i; 1770 1768 1771 1769 /* 1772 1770 * We write algorithms in the order they were implemented in ··· 1780 1778 * We traverse each algorithm in order, and apply the signature 1781 1779 * to each buffer. 1782 1780 */ 1783 - for (i = 0; i < ARRAY_SIZE(bufs); i++) { 1781 + for (size_t i = 0; i < ARRAY_SIZE(bufs); i++) { 1784 1782 if (!bufs[i].algo) 1785 1783 continue; 1786 1784 add_header_signature(&buffer, bufs[i].sig, bufs[i].algo);
+1 -4
compat/fsmonitor/fsm-listen-darwin.c
··· 23 23 #endif 24 24 #endif 25 25 26 - #define DISABLE_SIGN_COMPARE_WARNINGS 27 - 28 26 #include "git-compat-util.h" 29 27 #include "fsmonitor-ll.h" 30 28 #include "fsm-listen.h" ··· 210 208 const char *slash; 211 209 char *resolved = NULL; 212 210 struct strbuf tmp = STRBUF_INIT; 213 - int k; 214 211 215 212 /* 216 213 * Build a list of all filesystem changes into a private/local 217 214 * list and without holding any locks. 218 215 */ 219 - for (k = 0; k < num_of_events; k++) { 216 + for (size_t k = 0; k < num_of_events; k++) { 220 217 /* 221 218 * On Mac, we receive an array of absolute paths. 222 219 */
+1 -4
compat/terminal.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "compat/terminal.h" 5 3 #include "gettext.h" ··· 261 259 void restore_term(void) 262 260 { 263 261 if (use_stty) { 264 - int i; 265 262 struct child_process cp = CHILD_PROCESS_INIT; 266 263 267 264 if (stty_restore.nr == 0) 268 265 return; 269 266 270 267 strvec_push(&cp.args, "stty"); 271 - for (i = 0; i < stty_restore.nr; i++) 268 + for (size_t i = 0; i < stty_restore.nr; i++) 272 269 strvec_push(&cp.args, stty_restore.items[i].string); 273 270 run_command(&cp); 274 271 string_list_clear(&stty_restore, 0);
+3 -5
diagnose.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "diagnose.h" ··· 32 31 33 32 int option_parse_diagnose(const struct option *opt, const char *arg, int unset) 34 33 { 35 - int i; 36 34 enum diagnose_mode *diagnose = opt->value; 37 35 38 36 if (!arg) { ··· 40 38 return 0; 41 39 } 42 40 43 - for (i = 0; i < ARRAY_SIZE(diagnose_options); i++) { 41 + for (size_t i = 0; i < ARRAY_SIZE(diagnose_options); i++) { 44 42 if (!strcmp(arg, diagnose_options[i].option_name)) { 45 43 *diagnose = diagnose_options[i].mode; 46 44 return 0; ··· 187 185 char **argv_copy = NULL; 188 186 int stdout_fd = -1, archiver_fd = -1; 189 187 struct strbuf buf = STRBUF_INIT; 190 - int res, i; 188 + int res; 191 189 struct archive_dir archive_dirs[] = { 192 190 { ".git", 0 }, 193 191 { ".git/hooks", 0 }, ··· 240 238 241 239 /* Only include this if explicitly requested */ 242 240 if (mode == DIAGNOSE_ALL) { 243 - for (i = 0; i < ARRAY_SIZE(archive_dirs); i++) { 241 + for (size_t i = 0; i < ARRAY_SIZE(archive_dirs); i++) { 244 242 if (add_directory_to_archiver(&archiver_args, 245 243 archive_dirs[i].path, 246 244 archive_dirs[i].recursive)) {
+1 -3
diffcore-rename.c
··· 4 4 */ 5 5 6 6 #define USE_THE_REPOSITORY_VARIABLE 7 - #define DISABLE_SIGN_COMPARE_WARNINGS 8 7 9 8 #include "git-compat-util.h" 10 9 #include "diff.h" ··· 689 688 struct hashmap_iter iter; 690 689 struct strmap_entry *entry; 691 690 struct string_list to_remove = STRING_LIST_INIT_NODUP; 692 - int i; 693 691 694 692 if (!info->setup) 695 693 return; ··· 735 733 if (strintmap_contains(counts, UNKNOWN_DIR)) 736 734 strintmap_remove(counts, UNKNOWN_DIR); 737 735 } 738 - for (i = 0; i < to_remove.nr; ++i) 736 + for (size_t i = 0; i < to_remove.nr; ++i) 739 737 strmap_remove(info->dir_rename_count, 740 738 to_remove.items[i].string, 1); 741 739 string_list_clear(&to_remove, 0);
+2 -3
entry.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "object-store-ll.h" ··· 442 441 static void mark_colliding_entries(const struct checkout *state, 443 442 struct cache_entry *ce, struct stat *st) 444 443 { 445 - int i, trust_ino = check_stat; 444 + int trust_ino = check_stat; 446 445 447 446 #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__) 448 447 trust_ino = 0; ··· 452 451 453 452 /* TODO: audit for interaction with sparse-index. */ 454 453 ensure_full_index(state->istate); 455 - for (i = 0; i < state->istate->cache_nr; i++) { 454 + for (size_t i = 0; i < state->istate->cache_nr; i++) { 456 455 struct cache_entry *dup = state->istate->cache[i]; 457 456 458 457 if (dup == ce) {
+1 -5
ewah/ewah_bitmap.c
··· 17 17 * along with this program; if not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 20 - #define DISABLE_SIGN_COMPARE_WARNINGS 21 - 22 20 #include "git-compat-util.h" 23 21 #include "ewok.h" 24 22 #include "ewok_rlw.h" ··· 258 256 ++pointer; 259 257 260 258 for (k = 0; k < rlw_get_literal_words(word); ++k) { 261 - int c; 262 - 263 259 /* todo: zero count optimization */ 264 - for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) { 260 + for (size_t c = 0; c < BITS_IN_EWORD; ++c, ++pos) { 265 261 if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0) 266 262 callback(pos, payload); 267 263 }
+13 -20
git.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "builtin.h" 5 4 #include "config.h" ··· 56 55 57 56 static void exclude_helpers_from_list(struct string_list *list) 58 57 { 59 - int i = 0; 58 + size_t i = 0; 60 59 61 60 while (i < list->nr) { 62 61 if (strstr(list->items[i].string, "--")) ··· 76 75 static int list_cmds(const char *spec) 77 76 { 78 77 struct string_list list = STRING_LIST_INIT_DUP; 79 - int i; 80 78 int nongit; 81 79 82 80 /* ··· 114 112 if (*spec == ',') 115 113 spec++; 116 114 } 117 - for (i = 0; i < list.nr; i++) 115 + for (size_t i = 0; i < list.nr; i++) 118 116 puts(list.items[i].string); 119 117 string_list_clear(&list, 0); 120 118 return 0; ··· 323 321 trace2_cmd_name("_query_"); 324 322 if (!strcmp(cmd, "parseopt")) { 325 323 struct string_list list = STRING_LIST_INIT_DUP; 326 - int i; 327 324 328 325 list_builtins(&list, NO_PARSEOPT); 329 - for (i = 0; i < list.nr; i++) 326 + for (size_t i = 0; i < list.nr; i++) 330 327 printf("%s ", list.items[i].string); 331 328 string_list_clear(&list, 0); 332 329 exit(0); ··· 652 649 653 650 static struct cmd_struct *get_builtin(const char *s) 654 651 { 655 - int i; 656 - for (i = 0; i < ARRAY_SIZE(commands); i++) { 652 + for (size_t i = 0; i < ARRAY_SIZE(commands); i++) { 657 653 struct cmd_struct *p = commands + i; 658 654 if (!strcmp(s, p->cmd)) 659 655 return p; ··· 668 664 669 665 static void list_builtins(struct string_list *out, unsigned int exclude_option) 670 666 { 671 - int i; 672 - for (i = 0; i < ARRAY_SIZE(commands); i++) { 667 + for (size_t i = 0; i < ARRAY_SIZE(commands); i++) { 673 668 if (exclude_option && 674 669 (commands[i].option & exclude_option)) 675 670 continue; ··· 680 675 void load_builtin_commands(const char *prefix, struct cmdnames *cmds) 681 676 { 682 677 const char *name; 683 - int i; 684 678 685 679 /* 686 680 * Callers can ask for a subset of the commands based on a certain ··· 691 685 if (!skip_prefix(prefix, "git-", &prefix)) 692 686 BUG("prefix '%s' must start with 'git-'", prefix); 693 687 694 - for (i = 0; i < ARRAY_SIZE(commands); i++) 688 + for (size_t i = 0; i < ARRAY_SIZE(commands); i++) 695 689 if (skip_prefix(commands[i].cmd, prefix, &name)) 696 690 add_cmdname(cmds, name, strlen(name)); 697 691 } ··· 813 807 handle_builtin(args); 814 808 else if (get_builtin(args->v[0])) { 815 809 struct child_process cmd = CHILD_PROCESS_INIT; 816 - int i; 810 + int err; 817 811 818 812 /* 819 813 * The current process is committed to launching a ··· 827 821 commit_pager_choice(); 828 822 829 823 strvec_push(&cmd.args, "git"); 830 - for (i = 0; i < args->nr; i++) 824 + for (size_t i = 0; i < args->nr; i++) 831 825 strvec_push(&cmd.args, args->v[i]); 832 826 833 827 trace_argv_printf(cmd.args.v, "trace: exec:"); ··· 840 834 cmd.clean_on_exit = 1; 841 835 cmd.wait_after_clean = 1; 842 836 cmd.trace2_child_class = "git_alias"; 843 - i = run_command(&cmd); 844 - if (i >= 0 || errno != ENOENT) 845 - exit(i); 837 + err = run_command(&cmd); 838 + if (err >= 0 || errno != ENOENT) 839 + exit(err); 846 840 die("could not execute builtin %s", args->v[0]); 847 841 } 848 842 ··· 851 845 852 846 seen = unsorted_string_list_lookup(&cmd_list, args->v[0]); 853 847 if (seen) { 854 - int i; 855 848 struct strbuf sb = STRBUF_INIT; 856 - for (i = 0; i < cmd_list.nr; i++) { 849 + for (size_t i = 0; i < cmd_list.nr; i++) { 857 850 struct string_list_item *item = &cmd_list.items[i]; 858 851 859 852 strbuf_addf(&sb, "\n %s", item->string); ··· 947 940 */ 948 941 setup_path(); 949 942 950 - for (size_t i = 0; i < argc; i++) 943 + for (int i = 0; i < argc; i++) 951 944 strvec_push(&args, argv[i]); 952 945 953 946 while (1) {
+3 -5
help.h
··· 60 60 #define define_list_config_array(array) \ 61 61 void list_config_##array(struct string_list *list, const char *prefix) \ 62 62 { \ 63 - int i; \ 64 - for (i = 0; i < ARRAY_SIZE(array); i++) \ 63 + for (size_t i = 0; i < ARRAY_SIZE(array); i++) \ 65 64 if (array[i]) \ 66 65 list_config_item(list, prefix, array[i]); \ 67 66 } \ ··· 70 69 #define define_list_config_array_extra(array, values) \ 71 70 void list_config_##array(struct string_list *list, const char *prefix) \ 72 71 { \ 73 - int i; \ 74 72 static const char *extra[] = values; \ 75 - for (i = 0; i < ARRAY_SIZE(extra); i++) \ 73 + for (size_t i = 0; i < ARRAY_SIZE(extra); i++) \ 76 74 list_config_item(list, prefix, extra[i]); \ 77 - for (i = 0; i < ARRAY_SIZE(array); i++) \ 75 + for (size_t i = 0; i < ARRAY_SIZE(array); i++) \ 78 76 if (array[i]) \ 79 77 list_config_item(list, prefix, array[i]); \ 80 78 } \
+2 -5
hex.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "hash.h" ··· 8 7 static int get_hash_hex_algop(const char *hex, unsigned char *hash, 9 8 const struct git_hash_algo *algop) 10 9 { 11 - int i; 12 - for (i = 0; i < algop->rawsz; i++) { 10 + for (size_t i = 0; i < algop->rawsz; i++) { 13 11 int val = hex2chr(hex); 14 12 if (val < 0) 15 13 return -1; ··· 84 82 { 85 83 static const char hex[] = "0123456789abcdef"; 86 84 char *buf = buffer; 87 - int i; 88 85 89 86 /* 90 87 * Our struct object_id has been memset to 0, so default to printing ··· 93 90 if (algop == &hash_algos[0]) 94 91 algop = the_hash_algo; 95 92 96 - for (i = 0; i < algop->rawsz; i++) { 93 + for (size_t i = 0; i < algop->rawsz; i++) { 97 94 unsigned int val = *hash++; 98 95 *buf++ = hex[val >> 4]; 99 96 *buf++ = hex[val & 0xf];
+1 -3
http-push.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "environment.h" ··· 1339 1338 1340 1339 static int get_delta(struct rev_info *revs, struct remote_lock *lock) 1341 1340 { 1342 - int i; 1343 1341 struct commit *commit; 1344 1342 struct object_list **p = &objects; 1345 1343 int count = 0; ··· 1352 1350 count += add_send_request(&commit->object, lock); 1353 1351 } 1354 1352 1355 - for (i = 0; i < revs->pending.nr; i++) { 1353 + for (size_t i = 0; i < revs->pending.nr; i++) { 1356 1354 struct object_array_entry *entry = revs->pending.objects + i; 1357 1355 struct object *obj = entry->item; 1358 1356 const char *name = entry->name;
+1 -4
list-objects-filter-options.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "config.h" ··· 395 394 struct list_objects_filter_options *dest, 396 395 const struct list_objects_filter_options *src) 397 396 { 398 - int i; 399 - 400 397 /* Copy everything. We will overwrite the pointers shortly. */ 401 398 memcpy(dest, src, sizeof(struct list_objects_filter_options)); 402 399 ··· 405 402 dest->sparse_oid_name = xstrdup_or_null(src->sparse_oid_name); 406 403 407 404 ALLOC_ARRAY(dest->sub, dest->sub_alloc); 408 - for (i = 0; i < src->sub_nr; i++) 405 + for (size_t i = 0; i < src->sub_nr; i++) 409 406 list_objects_filter_copy(&dest->sub[i], &src->sub[i]); 410 407 } 411 408
+2 -6
list-objects.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "tag.h" ··· 284 283 int sparse) 285 284 { 286 285 struct commit_list *list; 287 - int i; 288 286 289 287 if (sparse) { 290 288 struct oidset set; ··· 321 319 } 322 320 323 321 if (revs->edge_hint_aggressive) { 324 - for (i = 0; i < revs->cmdline.nr; i++) { 322 + for (size_t i = 0; i < revs->cmdline.nr; i++) { 325 323 struct object *obj = revs->cmdline.rev[i].item; 326 324 struct commit *commit = (struct commit *)obj; 327 325 if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING)) ··· 344 342 static void traverse_non_commits(struct traversal_context *ctx, 345 343 struct strbuf *base) 346 344 { 347 - int i; 348 - 349 345 assert(base->len == 0); 350 346 351 - for (i = 0; i < ctx->revs->pending.nr; i++) { 347 + for (size_t i = 0; i < ctx->revs->pending.nr; i++) { 352 348 struct object_array_entry *pending = ctx->revs->pending.objects + i; 353 349 struct object *obj = pending->item; 354 350 const char *name = pending->name;
+1 -4
ls-refs.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "environment.h" ··· 54 53 */ 55 54 static int ref_match(const struct strvec *prefixes, const char *refname) 56 55 { 57 - int i; 58 - 59 56 if (!prefixes->nr) 60 57 return 1; /* no restriction */ 61 58 62 - for (i = 0; i < prefixes->nr; i++) { 59 + for (size_t i = 0; i < prefixes->nr; i++) { 63 60 const char *prefix = prefixes->v[i]; 64 61 65 62 if (starts_with(refname, prefix))
+2 -3
merge.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "gettext.h" ··· 26 25 const char *head_arg, struct commit_list *remotes) 27 26 { 28 27 struct child_process cmd = CHILD_PROCESS_INIT; 29 - int i, ret; 28 + int ret; 30 29 struct commit_list *j; 31 30 32 31 strvec_pushf(&cmd.args, "merge-%s", strategy); 33 - for (i = 0; i < xopts_nr; i++) 32 + for (size_t i = 0; i < xopts_nr; i++) 34 33 strvec_pushf(&cmd.args, "--%s", xopts[i]); 35 34 for (j = common; j; j = j->next) 36 35 strvec_push(&cmd.args, merge_argument(j->item));
+2 -3
path.c
··· 3 3 */ 4 4 5 5 #define USE_THE_REPOSITORY_VARIABLE 6 - #define DISABLE_SIGN_COMPARE_WARNINGS 7 6 8 7 #include "git-compat-util.h" 9 8 #include "abspath.h" ··· 1141 1140 */ 1142 1141 int longest_ancestor_length(const char *path, struct string_list *prefixes) 1143 1142 { 1144 - int i, max_len = -1; 1143 + int max_len = -1; 1145 1144 1146 1145 if (!strcmp(path, "/")) 1147 1146 return -1; 1148 1147 1149 - for (i = 0; i < prefixes->nr; i++) { 1148 + for (size_t i = 0; i < prefixes->nr; i++) { 1150 1149 const char *ceil = prefixes->items[i].string; 1151 1150 int len = strlen(ceil); 1152 1151
+1 -4
pkt-line.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "copy.h" 5 3 #include "pkt-line.h" ··· 41 39 42 40 static void packet_trace(const char *buf, unsigned int len, int write) 43 41 { 44 - int i; 45 42 struct strbuf out; 46 43 static int in_pack, sideband; 47 44 ··· 74 71 get_trace_prefix(), write ? '>' : '<'); 75 72 76 73 /* XXX we should really handle printable utf8 */ 77 - for (i = 0; i < len; i++) { 74 + for (unsigned int i = 0; i < len; i++) { 78 75 /* suppress newlines */ 79 76 if (buf[i] == '\n') 80 77 continue;
+1 -4
refs/debug.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "hex.h" 5 3 #include "refs-internal.h" ··· 85 83 86 84 static void print_transaction(struct ref_transaction *transaction) 87 85 { 88 - int i; 89 86 trace_printf_key(&trace_refs, "transaction {\n"); 90 - for (i = 0; i < transaction->nr; i++) { 87 + for (size_t i = 0; i < transaction->nr; i++) { 91 88 struct ref_update *u = transaction->updates[i]; 92 89 print_update(i, u->refname, &u->old_oid, &u->new_oid, u->flags, 93 90 u->type, u->msg);
+2 -4
send-pack.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "config.h" ··· 73 72 */ 74 73 struct child_process po = CHILD_PROCESS_INIT; 75 74 FILE *po_in; 76 - int i; 77 75 int rc; 78 76 79 77 trace2_region_enter("send_pack", "pack_objects", the_repository); ··· 105 103 * parameters by writing to the pipe. 106 104 */ 107 105 po_in = xfdopen(po.in, "w"); 108 - for (i = 0; i < advertised->nr; i++) 106 + for (size_t i = 0; i < advertised->nr; i++) 109 107 feed_object(&advertised->oid[i], po_in, 1); 110 - for (i = 0; i < negotiated->nr; i++) 108 + for (size_t i = 0; i < negotiated->nr; i++) 111 109 feed_object(&negotiated->oid[i], po_in, 1); 112 110 113 111 while (refs) {
+2 -6
serve.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "repository.h" ··· 164 163 { 165 164 struct strbuf capability = STRBUF_INIT; 166 165 struct strbuf value = STRBUF_INIT; 167 - int i; 168 166 169 167 /* serve by default supports v2 */ 170 168 packet_write_fmt(1, "version 2\n"); 171 169 172 - for (i = 0; i < ARRAY_SIZE(capabilities); i++) { 170 + for (size_t i = 0; i < ARRAY_SIZE(capabilities); i++) { 173 171 struct protocol_capability *c = &capabilities[i]; 174 172 175 173 if (c->advertise(the_repository, &value)) { ··· 195 193 196 194 static struct protocol_capability *get_capability(const char *key, const char **value) 197 195 { 198 - int i; 199 - 200 196 if (!key) 201 197 return NULL; 202 198 203 - for (i = 0; i < ARRAY_SIZE(capabilities); i++) { 199 + for (size_t i = 0; i < ARRAY_SIZE(capabilities); i++) { 204 200 struct protocol_capability *c = &capabilities[i]; 205 201 const char *out; 206 202 if (!skip_prefix(key, c->name, &out))
+1 -4
strvec.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "strvec.h" 5 3 #include "strbuf.h" ··· 129 127 void strvec_clear(struct strvec *array) 130 128 { 131 129 if (array->v != empty_strvec) { 132 - int i; 133 - for (i = 0; i < array->nr; i++) 130 + for (size_t i = 0; i < array->nr; i++) 134 131 free((char *)array->v[i]); 135 132 free(array->v); 136 133 }
+2 -8
t/helper/test-bloom.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "bloom.h" ··· 12 11 13 12 static void add_string_to_filter(const char *data, struct bloom_filter *filter) { 14 13 struct bloom_key key; 15 - int i; 16 14 17 15 fill_bloom_key(data, strlen(data), &key, &settings); 18 16 printf("Hashes:"); 19 - for (i = 0; i < settings.num_hashes; i++){ 17 + for (size_t i = 0; i < settings.num_hashes; i++) 20 18 printf("0x%08x|", key.hashes[i]); 21 - } 22 19 printf("\n"); 23 20 add_key_to_filter(&key, filter, &settings); 24 21 clear_bloom_key(&key); 25 22 } 26 23 27 24 static void print_bloom_filter(struct bloom_filter *filter) { 28 - int i; 29 - 30 25 if (!filter) { 31 26 printf("No filter.\n"); 32 27 return; 33 28 } 34 29 printf("Filter_Length:%d\n", (int)filter->len); 35 30 printf("Filter_Data:"); 36 - for (i = 0; i < filter->len; i++) { 31 + for (size_t i = 0; i < filter->len; i++) 37 32 printf("%02x|", filter->data[i]); 38 - } 39 33 printf("\n"); 40 34 } 41 35
+1 -3
t/helper/test-dump-fsmonitor.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "read-cache-ll.h" ··· 9 8 int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED) 10 9 { 11 10 struct index_state *istate = the_repository->index; 12 - int i; 13 11 14 12 setup_git_directory(); 15 13 if (do_read_index(istate, the_repository->index_file, 0) < 0) ··· 20 18 } 21 19 printf("fsmonitor last update %s\n", istate->fsmonitor_last_update); 22 20 23 - for (i = 0; i < istate->cache_nr; i++) 21 + for (size_t i = 0; i < istate->cache_nr; i++) 24 22 printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-"); 25 23 26 24 return 0;
+1 -3
t/helper/test-dump-split-index.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "hex.h" ··· 17 16 int cmd__dump_split_index(int ac UNUSED, const char **av) 18 17 { 19 18 struct split_index *si; 20 - int i; 21 19 22 20 setup_git_directory(); 23 21 ··· 29 27 return 0; 30 28 } 31 29 printf("base %s\n", oid_to_hex(&si->base_oid)); 32 - for (i = 0; i < the_repository->index->cache_nr; i++) { 30 + for (size_t i = 0; i < the_repository->index->cache_nr; i++) { 33 31 struct cache_entry *ce = the_repository->index->cache[i]; 34 32 printf("%06o %s %d\t%s\n", ce->ce_mode, 35 33 oid_to_hex(&ce->oid), ce_stage(ce), ce->name);
+3 -4
t/helper/test-dump-untracked-cache.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "dir.h" ··· 24 23 25 24 static void dump(struct untracked_cache_dir *ucd, struct strbuf *base) 26 25 { 27 - int i, len; 26 + int len; 28 27 QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked); 29 28 QSORT(ucd->dirs, ucd->dirs_nr, compare_dir); 30 29 len = base->len; ··· 38 37 if (ucd->valid) 39 38 fputs(" valid", stdout); 40 39 printf("\n"); 41 - for (i = 0; i < ucd->untracked_nr; i++) 40 + for (size_t i = 0; i < ucd->untracked_nr; i++) 42 41 printf("%s\n", ucd->untracked[i]); 43 - for (i = 0; i < ucd->dirs_nr; i++) 42 + for (size_t i = 0; i < ucd->dirs_nr; i++) 44 43 dump(ucd->dirs[i], base); 45 44 strbuf_setlen(base, len); 46 45 }
+2 -5
t/helper/test-hash-speed.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "test-tool.h" 4 2 #include "hash.h" 5 3 ··· 18 16 unsigned char hash[GIT_MAX_RAWSZ]; 19 17 clock_t initial, start, end; 20 18 unsigned bufsizes[] = { 64, 256, 1024, 8192, 16384 }; 21 - int i; 22 19 void *p; 23 20 const struct git_hash_algo *algo = NULL; 24 21 25 22 if (ac == 2) { 26 - for (i = 1; i < GIT_HASH_NALGOS; i++) { 23 + for (size_t i = 1; i < GIT_HASH_NALGOS; i++) { 27 24 if (!strcmp(av[1], hash_algos[i].name)) { 28 25 algo = &hash_algos[i]; 29 26 break; ··· 38 35 39 36 printf("algo: %s\n", algo->name); 40 37 41 - for (i = 0; i < ARRAY_SIZE(bufsizes); i++) { 38 + for (size_t i = 0; i < ARRAY_SIZE(bufsizes); i++) { 42 39 unsigned long j, kb; 43 40 double kb_per_sec; 44 41 p = xcalloc(1, bufsizes[i]);
+2 -5
t/helper/test-parse-options.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "test-tool.h" 4 2 #include "parse-options.h" 5 3 #include "strbuf.h" ··· 176 174 OPT_ALIAS('Z', "alias-target", "alias-source"), 177 175 OPT_END(), 178 176 }; 179 - int i; 180 177 int ret = 0; 181 178 182 179 trace2_cmd_name("_parse_"); ··· 200 197 show(&expect, &ret, "dry run: %s", dry_run ? "yes" : "no"); 201 198 show(&expect, &ret, "file: %s", file ? file : "(not set)"); 202 199 203 - for (i = 0; i < list.nr; i++) 200 + for (size_t i = 0; i < list.nr; i++) 204 201 show(&expect, &ret, "list: %s", list.items[i].string); 205 202 206 - for (i = 0; i < argc; i++) 203 + for (int i = 0; i < argc; i++) 207 204 show(&expect, &ret, "arg %02d: %s", i, argv[i]); 208 205 209 206 expect.strdup_strings = 1;
+1 -3
t/helper/test-reach.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "commit.h" ··· 14 13 15 14 static void print_sorted_commit_ids(struct commit_list *list) 16 15 { 17 - int i; 18 16 struct string_list s = STRING_LIST_INIT_DUP; 19 17 20 18 while (list) { ··· 24 22 25 23 string_list_sort(&s); 26 24 27 - for (i = 0; i < s.nr; i++) 25 + for (size_t i = 0; i < s.nr; i++) 28 26 printf("%s\n", s.items[i].string); 29 27 30 28 string_list_clear(&s, 0);
+1 -3
t/helper/test-ref-store.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-tool.h" 5 4 #include "hex.h" ··· 25 24 static unsigned int parse_flags(const char *str, struct flag_definition *defs) 26 25 { 27 26 struct string_list masks = STRING_LIST_INIT_DUP; 28 - int i = 0; 29 27 unsigned int result = 0; 30 28 31 29 if (!strcmp(str, "0")) 32 30 return 0; 33 31 34 32 string_list_split(&masks, str, ',', 64); 35 - for (; i < masks.nr; i++) { 33 + for (size_t i = 0; i < masks.nr; i++) { 36 34 const char *name = masks.items[i].string; 37 35 struct flag_definition *def = defs; 38 36 int found = 0;
+1 -4
t/helper/test-tool.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "git-compat-util.h" 4 2 #include "test-tool.h" 5 3 #include "test-tool-utils.h" ··· 103 101 104 102 int cmd_main(int argc, const char **argv) 105 103 { 106 - int i; 107 104 const char *working_directory = NULL; 108 105 struct option options[] = { 109 106 OPT_STRING('C', NULL, &working_directory, "directory", ··· 122 119 if (working_directory && chdir(working_directory) < 0) 123 120 die("Could not cd to '%s'", working_directory); 124 121 125 - for (i = 0; i < ARRAY_SIZE(cmds); i++) { 122 + for (size_t i = 0; i < ARRAY_SIZE(cmds); i++) { 126 123 if (!strcmp(cmds[i].name, argv[1])) { 127 124 argv++; 128 125 argc--;
+2 -3
t/unit-tests/t-example-decorate.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "test-lib.h" 5 4 #include "object.h" ··· 43 42 44 43 static void t_loop(struct test_vars *vars) 45 44 { 46 - int i, objects_noticed = 0; 45 + int objects_noticed = 0; 47 46 48 - for (i = 0; i < vars->n.size; i++) { 47 + for (size_t i = 0; i < vars->n.size; i++) { 49 48 if (vars->n.entries[i].base) 50 49 objects_noticed++; 51 50 }
+1 -3
t/unit-tests/t-prio-queue.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 - 3 1 #include "test-lib.h" 4 2 #include "prio-queue.h" 5 3 ··· 27 25 struct prio_queue pq = { intcmp }; 28 26 int j = 0; 29 27 30 - for (int i = 0; i < input_size; i++) { 28 + for (size_t i = 0; i < input_size; i++) { 31 29 void *peek, *get; 32 30 switch(input[i]) { 33 31 case GET:
+1 -3
tmp-objdir.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "tmp-objdir.h" ··· 238 237 { 239 238 size_t src_len = src->len, dst_len = dst->len; 240 239 struct string_list paths = STRING_LIST_INIT_DUP; 241 - int i; 242 240 int ret = 0; 243 241 244 242 if (read_dir_paths(&paths, src->buf) < 0) ··· 246 244 paths.cmp = pack_copy_cmp; 247 245 string_list_sort(&paths); 248 246 249 - for (i = 0; i < paths.nr; i++) { 247 + for (size_t i = 0; i < paths.nr; i++) { 250 248 const char *name = paths.items[i].string; 251 249 enum finalize_object_file_flags flags_copy = flags; 252 250
+1 -3
trailer.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "config.h" ··· 523 522 struct conf_info *conf; 524 523 char *name = NULL; 525 524 enum trailer_info_type type; 526 - int i; 527 525 528 526 if (!skip_prefix(conf_key, "trailer.", &trailer_item)) 529 527 return 0; ··· 533 531 return 0; 534 532 535 533 variable_name++; 536 - for (i = 0; i < ARRAY_SIZE(trailer_config_items); i++) { 534 + for (size_t i = 0; i < ARRAY_SIZE(trailer_config_items); i++) { 537 535 if (strcmp(trailer_config_items[i].name, variable_name)) 538 536 continue; 539 537 name = xstrndup(trailer_item, variable_name - trailer_item - 1);
+6 -8
transport-helper.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "transport.h" ··· 314 313 struct string_list *list) 315 314 { 316 315 struct strbuf buf = STRBUF_INIT; 317 - int i, ret = 0; 316 + int ret = 0; 318 317 319 - for (i = 0; i < list->nr; i++) { 318 + for (size_t i = 0; i < list->nr; i++) { 320 319 strbuf_addf(&buf, "option %s ", name); 321 320 quote_c_style(list->items[i].string, &buf, NULL, 0); 322 321 strbuf_addch(&buf, '\n'); ··· 334 333 { 335 334 struct helper_data *data = transport->data; 336 335 struct strbuf buf = STRBUF_INIT; 337 - int i, ret, is_bool = 0; 336 + int ret, is_bool = 0; 338 337 339 338 get_helper(transport); 340 339 ··· 345 344 return string_list_set_helper_option(data, name, 346 345 (struct string_list *)value); 347 346 348 - for (i = 0; i < ARRAY_SIZE(unsupported_options); i++) { 347 + for (size_t i = 0; i < ARRAY_SIZE(unsupported_options); i++) { 349 348 if (!strcmp(name, unsupported_options[i])) 350 349 return 1; 351 350 } 352 351 353 - for (i = 0; i < ARRAY_SIZE(boolean_options); i++) { 352 + for (size_t i = 0; i < ARRAY_SIZE(boolean_options); i++) { 354 353 if (!strcmp(name, boolean_options[i])) { 355 354 is_bool = 1; 356 355 break; ··· 482 481 { 483 482 struct helper_data *data = transport->data; 484 483 struct child_process *helper = get_helper(transport); 485 - int i; 486 484 487 485 child_process_init(fastexport); 488 486 ··· 498 496 if (data->import_marks) 499 497 strvec_pushf(&fastexport->args, "--import-marks=%s", data->import_marks); 500 498 501 - for (i = 0; i < revlist_args->nr; i++) 499 + for (size_t i = 0; i < revlist_args->nr; i++) 502 500 strvec_push(&fastexport->args, revlist_args->items[i].string); 503 501 504 502 fastexport->git_cmd = 1;
+4 -10
transport.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "advice.h" ··· 48 47 "color.transport.rejected" 49 48 }, *key = "color.transport"; 50 49 char *value; 51 - int i; 52 50 static int initialized; 53 51 54 52 if (initialized) ··· 61 59 if (!want_color_stderr(transport_use_color)) 62 60 return 0; 63 61 64 - for (i = 0; i < ARRAY_SIZE(keys); i++) 62 + for (size_t i = 0; i < ARRAY_SIZE(keys); i++) 65 63 if (!git_config_get_string(keys[i], &value)) { 66 64 if (!value) 67 65 return config_error_nonbool(keys[i]); ··· 154 152 { 155 153 struct bundle_transport_data *data = transport->data; 156 154 struct ref *result = NULL; 157 - int i; 158 155 159 156 if (for_push) 160 157 return NULL; 161 158 162 159 get_refs_from_bundle_inner(transport); 163 160 164 - for (i = 0; i < data->header.references.nr; i++) { 161 + for (size_t i = 0; i < data->header.references.nr; i++) { 165 162 struct string_list_item *e = data->header.references.items + i; 166 163 const char *name = e->string; 167 164 struct ref *ref = alloc_ref(name); ··· 1282 1279 1283 1280 static void die_with_unpushed_submodules(struct string_list *needs_pushing) 1284 1281 { 1285 - int i; 1286 - 1287 1282 fprintf(stderr, _("The following submodule paths contain changes that can\n" 1288 1283 "not be found on any remote:\n")); 1289 - for (i = 0; i < needs_pushing->nr; i++) 1284 + for (size_t i = 0; i < needs_pushing->nr; i++) 1290 1285 fprintf(stderr, " %s\n", needs_pushing->items[i].string); 1291 1286 fprintf(stderr, _("\nPlease try\n\n" 1292 1287 " git push --recurse-submodules=on-demand\n\n" ··· 1602 1597 void transport_unlock_pack(struct transport *transport, unsigned int flags) 1603 1598 { 1604 1599 int in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER); 1605 - int i; 1606 1600 1607 - for (i = 0; i < transport->pack_lockfiles.nr; i++) 1601 + for (size_t i = 0; i < transport->pack_lockfiles.nr; i++) 1608 1602 if (in_signal_handler) 1609 1603 unlink(transport->pack_lockfiles.items[i].string); 1610 1604 else
+1 -3
usage.c
··· 4 4 * Copyright (C) Linus Torvalds, 2005 5 5 */ 6 6 7 - #define DISABLE_SIGN_COMPARE_WARNINGS 8 - 9 7 #include "git-compat-util.h" 10 8 #include "gettext.h" 11 9 #include "trace2.h" ··· 192 190 static const char *fmt_with_err(char *buf, int n, const char *fmt) 193 191 { 194 192 char str_error[256], *err; 195 - int i, j; 193 + size_t i, j; 196 194 197 195 err = strerror(errno); 198 196 for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
+1 -3
version.c
··· 1 - #define DISABLE_SIGN_COMPARE_WARNINGS 2 1 #include "git-compat-util.h" 3 2 #include "version.h" 4 3 #include "strbuf.h" ··· 25 24 26 25 if (!agent) { 27 26 struct strbuf buf = STRBUF_INIT; 28 - int i; 29 27 30 28 strbuf_addstr(&buf, git_user_agent()); 31 29 strbuf_trim(&buf); 32 - for (i = 0; i < buf.len; i++) { 30 + for (size_t i = 0; i < buf.len; i++) { 33 31 if (buf.buf[i] <= 32 || buf.buf[i] >= 127) 34 32 buf.buf[i] = '.'; 35 33 }
+1 -3
versioncmp.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 - #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" 5 4 #include "config.h" ··· 78 77 int off, 79 78 int *diff) 80 79 { 81 - int i; 82 80 struct suffix_match match1 = { -1, off, -1 }; 83 81 struct suffix_match match2 = { -1, off, -1 }; 84 82 85 - for (i = 0; i < prereleases->nr; i++) { 83 + for (size_t i = 0; i < prereleases->nr; i++) { 86 84 const char *suffix = prereleases->items[i].string; 87 85 int start, suffix_len = strlen(suffix); 88 86 if (suffix_len < off)