use size_t for loop indices to avoid signedness warnings; from emaste@freebsd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
diff --git a/lib/diff3.c b/lib/diff3.c
index 0526cfd..861cb6f 100644
--- a/lib/diff3.c
+++ b/lib/diff3.c
@@ -264,9 +264,8 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
char *dp13, *dp23, *path1, *path2, *path3;
BUF *b1, *b2, *b3, *d1, *d2, *diffb;
u_char *data, *patch;
- size_t dlen, plen;
+ size_t dlen, plen, i;
struct diff3_state *d3s;
- int i;
*overlapcnt = 0;
diff --git a/lib/error.c b/lib/error.c
index 92ce7a5..6cbb7ca 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -40,7 +40,7 @@
const struct got_error *
got_error(int code)
{
- int i;
+ size_t i;
for (i = 0; i < nitems(got_errors); i++) {
if (code == got_errors[i].code)
@@ -54,7 +54,7 @@ const struct got_error *
got_error_msg(int code, const char *msg)
{
static struct got_error err;
- int i;
+ size_t i;
for (i = 0; i < nitems(got_errors); i++) {
if (code == got_errors[i].code) {
@@ -178,7 +178,7 @@ got_error_path(const char *path, int code)
{
static struct got_error err;
static char msg[PATH_MAX + 128];
- int i;
+ size_t i;
for (i = 0; i < nitems(got_errors); i++) {
if (code == got_errors[i].code) {
diff --git a/lib/fetch.c b/lib/fetch.c
index 718d957..91dc86a 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -359,9 +359,10 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
int fetchfd, struct got_repository *repo,
got_fetch_progress_cb progress_cb, void *progress_arg)
{
+ size_t i;
int imsg_fetchfds[2], imsg_idxfds[2];
int packfd = -1, npackfd = -1, idxfd = -1, nidxfd = -1, nfetchfd = -1;
- int tmpfds[3], i;
+ int tmpfds[3];
int fetchstatus, idxstatus, done = 0;
const struct got_error *err;
struct imsgbuf fetchibuf, idxibuf;
diff --git a/lib/gitconfig.c b/lib/gitconfig.c
index 69956c3..c4d930b 100644
--- a/lib/gitconfig.c
+++ b/lib/gitconfig.c
@@ -309,7 +309,7 @@ conf_parse(struct got_gitconfig *conf, int trans, char *buf, size_t sz)
const struct got_error *
got_gitconfig_open(struct got_gitconfig **conf, int fd)
{
- unsigned int i;
+ size_t i;
*conf = calloc(1, sizeof(**conf));
if (*conf == NULL)
@@ -325,7 +325,7 @@ static void
conf_clear(struct got_gitconfig *conf)
{
struct got_gitconfig_binding *cb;
- int i;
+ size_t i;
if (conf->addr) {
for (i = 0; i < nitems(conf->bindings); i++)
@@ -502,7 +502,7 @@ got_gitconfig_get_section_list(struct got_gitconfig_list **sections,
struct got_gitconfig_list *list = NULL;
struct got_gitconfig_list_node *node = 0;
struct got_gitconfig_binding *cb;
- int i;
+ size_t i;
*sections = NULL;
diff --git a/lib/object_parse.c b/lib/object_parse.c
index 2428cdc..87a2ed4 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -167,7 +167,7 @@ got_object_parse_header(struct got_object **obj, char *buf, size_t len)
};
int type = 0;
size_t size = 0, hdrlen = 0;
- int i;
+ size_t i;
*obj = NULL;
diff --git a/lib/privsep.c b/lib/privsep.c
index 55eb3a4..a17a878 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -2265,7 +2265,7 @@ got_privsep_unveil_exec_helpers(void)
GOT_PATH_PROG_FETCH_PACK,
GOT_PATH_PROG_INDEX_PACK,
};
- int i;
+ size_t i;
for (i = 0; i < nitems(helpers); i++) {
if (unveil(helpers[i], "x") == 0)
diff --git a/lib/reference.c b/lib/reference.c
index 6df30b6..ef042bc 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -264,7 +264,7 @@ is_valid_ref_name(const char *name)
const char *forbidden_seq[] = { "//", "..", "@{" };
const char *lfs = GOT_LOCKFILE_SUFFIX;
const size_t lfs_len = sizeof(GOT_LOCKFILE_SUFFIX) - 1;
- int i;
+ size_t i;
if (name[0] == '@' && name[1] == '\0')
return 0;
@@ -439,7 +439,8 @@ got_ref_open(struct got_reference **ref, struct got_repository *repo,
const char *subdirs[] = {
GOT_REF_HEADS, GOT_REF_TAGS, GOT_REF_REMOTES
};
- int i, well_known = is_well_known_ref(refname);
+ size_t i;
+ int well_known = is_well_known_ref(refname);
struct got_lockfile *lf = NULL;
*ref = NULL;
diff --git a/lib/repository.c b/lib/repository.c
index dfc1bf5..d5c352f 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -590,7 +590,7 @@ got_repo_open(struct got_repository **repop, const char *path,
struct got_repository *repo = NULL;
const struct got_error *err = NULL;
char *abspath, *repo_path = NULL;
- int i;
+ size_t i;
*repop = NULL;
@@ -692,7 +692,7 @@ const struct got_error *
got_repo_close(struct got_repository *repo)
{
const struct got_error *err = NULL, *child_err;
- int i;
+ size_t i;
for (i = 0; i < nitems(repo->packidx_cache); i++) {
if (repo->packidx_cache[i] == NULL)
@@ -875,7 +875,7 @@ cache_packidx(struct got_repository *repo, struct got_packidx *packidx,
const char *path_packidx)
{
const struct got_error *err = NULL;
- int i;
+ size_t i;
for (i = 0; i < nitems(repo->packidx_cache); i++) {
if (repo->packidx_cache[i] == NULL)
@@ -928,7 +928,7 @@ got_repo_search_packidx(struct got_packidx **packidx, int *idx,
DIR *packdir;
struct dirent *dent;
char *path_packidx;
- int i;
+ size_t i;
/* Search pack index cache. */
for (i = 0; i < nitems(repo->packidx_cache); i++) {
@@ -1066,7 +1066,7 @@ got_repo_cache_pack(struct got_pack **packp, struct got_repository *repo,
const struct got_error *err = NULL;
struct got_pack *pack = NULL;
struct stat sb;
- int i;
+ size_t i;
if (packp)
*packp = NULL;
@@ -1134,7 +1134,7 @@ struct got_pack *
got_repo_get_cached_pack(struct got_repository *repo, const char *path_packfile)
{
struct got_pack *pack = NULL;
- int i;
+ size_t i;
for (i = 0; i < nitems(repo->packs); i++) {
pack = &repo->packs[i];
@@ -1164,7 +1164,7 @@ got_repo_init(const char *repo_path)
"\tfilemode = true\n"
"\tbare = true\n";
char *path;
- int i;
+ size_t i;
if (!got_path_dir_is_empty(repo_path))
return got_error(GOT_ERR_DIR_NOT_EMPTY);