diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/delta.c | 21 | ||||
-rw-r--r-- | src/delta.h | 36 | ||||
-rw-r--r-- | src/diff_output.c | 14 | ||||
-rw-r--r-- | src/hash/hash_win32.c | 4 | ||||
-rw-r--r-- | src/index.c | 21 | ||||
-rw-r--r-- | src/iterator.c | 2 | ||||
-rw-r--r-- | src/pack-objects.c | 25 | ||||
-rw-r--r-- | src/reflog.c | 23 | ||||
-rw-r--r-- | src/revparse.c | 39 | ||||
-rw-r--r-- | src/stash.c | 2 | ||||
-rw-r--r-- | src/transports/cred.c | 6 | ||||
-rw-r--r-- | src/transports/smart.c | 2 | ||||
-rw-r--r-- | src/transports/smart.h | 2 | ||||
-rw-r--r-- | src/transports/smart_protocol.c | 10 | ||||
-rw-r--r-- | src/transports/winhttp.c | 2 | ||||
-rw-r--r-- | src/tree.c | 18 | ||||
-rw-r--r-- | src/vector.c | 2 | ||||
-rw-r--r-- | src/win32/posix_w32.c | 6 |
18 files changed, 123 insertions, 112 deletions
diff --git a/src/delta.c b/src/delta.c index 49f7df017..2514dccaf 100644 --- a/src/delta.c +++ b/src/delta.c @@ -148,7 +148,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize) /* Determine index hash size. Note that indexing skips the first byte to allow for optimizing the Rabin's polynomial initialization in create_delta(). */ - entries = (bufsize - 1) / RABIN_WINDOW; + entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW; if (bufsize >= 0xffffffffUL) { /* * Current delta format can't encode offsets into @@ -317,9 +317,12 @@ unsigned long git_delta_sizeof_index(struct git_delta_index *index) #define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7) void * -git_delta_create(const struct git_delta_index *index, - const void *trg_buf, unsigned long trg_size, - unsigned long *delta_size, unsigned long max_size) +git_delta_create( + const struct git_delta_index *index, + const void *trg_buf, + unsigned long trg_size, + unsigned long *delta_size, + unsigned long max_size) { unsigned int i, outpos, outsize, moff, msize, val; int inscnt; @@ -332,7 +335,7 @@ git_delta_create(const struct git_delta_index *index, outpos = 0; outsize = 8192; if (max_size && outsize >= max_size) - outsize = max_size + MAX_OP_SIZE + 1; + outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1); out = git__malloc(outsize); if (!out) return NULL; @@ -377,19 +380,19 @@ git_delta_create(const struct git_delta_index *index, for (entry = index->hash[i]; entry < index->hash[i+1]; entry++) { const unsigned char *ref = entry->ptr; const unsigned char *src = data; - unsigned int ref_size = ref_top - ref; + unsigned int ref_size = (unsigned int)(ref_top - ref); if (entry->val != val) continue; if (ref_size > (unsigned int)(top - src)) - ref_size = top - src; + ref_size = (unsigned int)(top - src); if (ref_size <= msize) break; while (ref_size-- && *src++ == *ref) ref++; if (msize < (unsigned int)(ref - entry->ptr)) { /* this is our best match so far */ - msize = ref - entry->ptr; - moff = entry->ptr - ref_data; + msize = (unsigned int)(ref - entry->ptr); + moff = (unsigned int)(entry->ptr - ref_data); if (msize >= 4096) /* good enough */ break; } diff --git a/src/delta.h b/src/delta.h index b0b8e4183..4ca327992 100644 --- a/src/delta.h +++ b/src/delta.h @@ -46,11 +46,12 @@ extern unsigned long git_delta_sizeof_index(struct git_delta_index *index); * returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ -extern void * -git_delta_create(const struct git_delta_index *index, - const void *buf, unsigned long bufsize, - unsigned long *delta_size, - unsigned long max_delta_size); +extern void *git_delta_create( + const struct git_delta_index *index, + const void *buf, + unsigned long bufsize, + unsigned long *delta_size, + unsigned long max_delta_size); /* * diff_delta: create a delta from source buffer to target buffer @@ -60,15 +61,16 @@ git_delta_create(const struct git_delta_index *index, * pointer to the buffer with the delta data is returned and *delta_size is * updated with its size. The returned buffer must be freed by the caller. */ -GIT_INLINE(void *) -git_delta(const void *src_buf, unsigned long src_bufsize, - const void *trg_buf, unsigned long trg_bufsize, - unsigned long *delta_size, unsigned long max_delta_size) +GIT_INLINE(void *) git_delta( + const void *src_buf, unsigned long src_bufsize, + const void *trg_buf, unsigned long trg_bufsize, + unsigned long *delta_size, + unsigned long max_delta_size) { struct git_delta_index *index = git_delta_create_index(src_buf, src_bufsize); if (index) { - void *delta = git_delta_create(index, trg_buf, trg_bufsize, - delta_size, max_delta_size); + void *delta = git_delta_create( + index, trg_buf, trg_bufsize, delta_size, max_delta_size); git_delta_free_index(index); return delta; } @@ -82,9 +84,10 @@ git_delta(const void *src_buf, unsigned long src_bufsize, * *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ -extern void *git_delta_patch(const void *src_buf, unsigned long src_size, - const void *delta_buf, unsigned long delta_size, - unsigned long *dst_size); +extern void *git_delta_patch( + const void *src_buf, unsigned long src_size, + const void *delta_buf, unsigned long delta_size, + unsigned long *dst_size); /* the smallest possible delta size is 4 bytes */ #define GIT_DELTA_SIZE_MIN 4 @@ -93,9 +96,8 @@ extern void *git_delta_patch(const void *src_buf, unsigned long src_size, * This must be called twice on the delta data buffer, first to get the * expected source buffer size, and again to get the target buffer size. */ -GIT_INLINE(unsigned long) -git_delta_get_hdr_size(const unsigned char **datap, - const unsigned char *top) +GIT_INLINE(unsigned long) git_delta_get_hdr_size( + const unsigned char **datap, const unsigned char *top) { const unsigned char *data = *datap; unsigned long cmd, size = 0; diff --git a/src/diff_output.c b/src/diff_output.c index 804325e47..3d5e03a29 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -262,7 +262,7 @@ static int get_blob_content( return error; map->data = (void *)git_blob_rawcontent(*blob); - map->len = git_blob_rawsize(*blob); + map->len = (size_t)git_blob_rawsize(*blob); return diff_delta_is_binary_by_content(ctxt, delta, file, map); } @@ -1236,14 +1236,18 @@ static void set_data_from_blob( git_blob *blob, git_map *map, git_diff_file *file) { if (blob) { - map->data = (char *)git_blob_rawcontent(blob); - file->size = map->len = git_blob_rawsize(blob); + file->size = git_blob_rawsize(blob); git_oid_cpy(&file->oid, git_object_id((const git_object *)blob)); file->mode = 0644; + + map->len = (size_t)file->size; + map->data = (char *)git_blob_rawcontent(blob); } else { - map->data = ""; - file->size = map->len = 0; + file->size = 0; file->flags |= GIT_DIFF_FILE_NO_DATA; + + map->len = 0; + map->data = ""; } } diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c index a89dffa7c..469ce7807 100644 --- a/src/hash/hash_win32.c +++ b/src/hash/hash_win32.c @@ -155,7 +155,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_ { assert(ctx->ctx.cryptoapi.valid); - if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, len, 0)) + if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0)) return -1; return 0; @@ -219,7 +219,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx) GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len) { - if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, len, 0) < 0) + if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0) return -1; return 0; diff --git a/src/index.c b/src/index.c index ef644a618..f3ced9e39 100644 --- a/src/index.c +++ b/src/index.c @@ -488,10 +488,10 @@ int git_index_write_tree_to(git_oid *oid, git_index *index, git_repository *repo return git_tree__write_index(oid, index, repo); } -unsigned int git_index_entrycount(const git_index *index) +size_t git_index_entrycount(const git_index *index) { assert(index); - return (unsigned int)index->entries.length; + return index->entries.length; } const git_index_entry *git_index_get_byindex( @@ -852,7 +852,7 @@ int git_index_conflict_add(git_index *index, const git_index_entry *their_entry) { git_index_entry *entries[3] = { 0 }; - size_t i; + unsigned short i; int ret = 0; assert (index); @@ -890,7 +890,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out, git_index_entry **their_out, git_index *index, const char *path) { - int pos, stage; + int pos, posmax, stage; git_index_entry *conflict_entry; int error = GIT_ENOTFOUND; @@ -903,7 +903,8 @@ int git_index_conflict_get(git_index_entry **ancestor_out, if ((pos = git_index_find(index, path)) < 0) return pos; - while ((unsigned int)pos < git_index_entrycount(index)) { + for (posmax = (int)git_index_entrycount(index); pos < posmax; ++pos) { + conflict_entry = git_vector_get(&index->entries, pos); if (index->entries_cmp_path(conflict_entry->path, path) != 0) @@ -927,8 +928,6 @@ int git_index_conflict_get(git_index_entry **ancestor_out, default: break; }; - - ++pos; } return error; @@ -936,7 +935,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out, int git_index_conflict_remove(git_index *index, const char *path) { - int pos; + int pos, posmax; git_index_entry *conflict_entry; int error = 0; @@ -945,7 +944,9 @@ int git_index_conflict_remove(git_index *index, const char *path) if ((pos = git_index_find(index, path)) < 0) return pos; - while ((unsigned int)pos < git_index_entrycount(index)) { + posmax = (int)git_index_entrycount(index); + + while (pos < posmax) { conflict_entry = git_vector_get(&index->entries, pos); if (index->entries_cmp_path(conflict_entry->path, path) != 0) @@ -1520,7 +1521,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file) memset(&extension, 0x0, sizeof(struct index_extension)); memcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4); - extension.extension_size = reuc_buf.size; + extension.extension_size = (uint32_t)reuc_buf.size; error = write_extension(file, &extension, &reuc_buf); diff --git a/src/iterator.c b/src/iterator.c index a68a0050b..6be45a4bb 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -329,7 +329,7 @@ int git_iterator_for_tree_range( typedef struct { git_iterator base; git_index *index; - unsigned int current; + size_t current; bool free_index; } index_iterator; diff --git a/src/pack-objects.c b/src/pack-objects.c index e2840a745..008d8f288 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -229,7 +229,7 @@ static int gen_pack_object_header( } *hdr++ = c; - return hdr - hdr_base; + return (int)(hdr - hdr_base); } static int get_delta(void **out, git_odb *odb, git_pobject *po) @@ -244,9 +244,10 @@ static int get_delta(void **out, git_odb *odb, git_pobject *po) git_odb_read(&trg, odb, &po->id) < 0) goto on_error; - delta_buf = git_delta(git_odb_object_data(src), git_odb_object_size(src), - git_odb_object_data(trg), git_odb_object_size(trg), - &delta_size, 0); + delta_buf = git_delta( + git_odb_object_data(src), (unsigned long)git_odb_object_size(src), + git_odb_object_data(trg), (unsigned long)git_odb_object_size(trg), + &delta_size, 0); if (!delta_buf || delta_size != po->delta_size) { giterr_set(GITERR_INVALID, "Delta size changed"); @@ -287,7 +288,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po) goto on_error; data = (void *)git_odb_object_data(obj); - size = git_odb_object_size(obj); + size = (unsigned long)git_odb_object_size(obj); type = git_odb_object_type(obj); } @@ -315,7 +316,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po) if (po->delta) git__free(data); data = zbuf.ptr; - size = zbuf.size; + size = (unsigned long)zbuf.size; } if (git_buf_put(buf, data, size) < 0 || @@ -707,7 +708,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg, return 0; /* Now some size filtering heuristics. */ - trg_size = trg_object->size; + trg_size = (unsigned long)trg_object->size; if (!trg_object->delta) { max_size = trg_size/2 - 20; ref_depth = 1; @@ -721,7 +722,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg, if (max_size == 0) return 0; - src_size = src_object->size; + src_size = (unsigned long)src_object->size; sizediff = src_size < trg_size ? trg_size - src_size : 0; if (sizediff >= max_size) return 0; @@ -733,7 +734,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg, if (git_odb_read(&obj, pb->odb, &trg_object->id) < 0) return -1; - sz = git_odb_object_size(obj); + sz = (unsigned long)git_odb_object_size(obj); trg->data = git__malloc(sz); GITERR_CHECK_ALLOC(trg->data); memcpy(trg->data, git_odb_object_data(obj), sz); @@ -752,7 +753,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg, if (git_odb_read(&obj, pb->odb, &src_object->id) < 0) return -1; - sz = git_odb_object_size(obj); + sz = (unsigned long)git_odb_object_size(obj); src->data = git__malloc(sz); GITERR_CHECK_ALLOC(src->data); memcpy(src->data, git_odb_object_data(obj), sz); @@ -835,7 +836,7 @@ static unsigned long free_unpacked(struct unpacked *n) git_delta_free_index(n->index); n->index = NULL; if (n->data) { - freed_mem += n->object->size; + freed_mem += (unsigned long)n->object->size; git__free(n->data); n->data = NULL; } @@ -941,7 +942,7 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list, GITERR_CHECK_ALLOC(po->delta_data); memcpy(po->delta_data, zbuf.ptr, zbuf.size); - po->z_delta_size = zbuf.size; + po->z_delta_size = (unsigned long)zbuf.size; git_buf_clear(&zbuf); git_packbuilder__cache_lock(pb); diff --git a/src/reflog.c b/src/reflog.c index 72a34f695..ac481fb81 100644 --- a/src/reflog.c +++ b/src/reflog.c @@ -275,7 +275,7 @@ int git_reflog_write(git_reflog *reflog) if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0) goto cleanup; } - + error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE); goto success; @@ -411,18 +411,20 @@ size_t git_reflog_entrycount(git_reflog *reflog) return reflog->entries.length; } -const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx) +GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total) { - int pos; + return (total - 1) - idx; +} +const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx) +{ assert(reflog); - pos = git_reflog_entrycount(reflog) - (idx + 1); - - if (pos < 0) + if (idx >= reflog->entries.length) return NULL; - return git_vector_get(&reflog->entries, pos); + return git_vector_get( + &reflog->entries, reflog_inverse_index(idx, reflog->entries.length)); } const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry) @@ -454,7 +456,7 @@ int git_reflog_drop( size_t idx, int rewrite_previous_entry) { - unsigned int entrycount; + size_t entrycount; git_reflog_entry *entry, *previous; assert(reflog); @@ -468,7 +470,8 @@ int git_reflog_drop( reflog_entry_free(entry); - if (git_vector_remove(&reflog->entries, entrycount - (idx + 1)) < 0) + if (git_vector_remove( + &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0) return -1; if (!rewrite_previous_entry) @@ -489,7 +492,7 @@ int git_reflog_drop( /* ...clear the oid_old member of the "new" oldest entry */ if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0) return -1; - + return 0; } diff --git a/src/revparse.c b/src/revparse.c index 79900c4cc..308b92923 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -161,7 +161,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const static int try_parse_numeric(int *n, const char *curly_braces_content) { - int content; + int32_t content; const char *end_ptr; if (git__strtol32(&content, curly_braces_content, &end_ptr, 10) < 0) @@ -170,16 +170,17 @@ static int try_parse_numeric(int *n, const char *curly_braces_content) if (*end_ptr != '\0') return -1; - *n = content; + *n = (int)content; return 0; } -static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, unsigned int position) +static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, size_t position) { git_reference *ref = NULL; git_reflog *reflog = NULL; regex_t preg; - int numentries, i, cur, error = -1; + int error = -1; + size_t i, numentries, cur; const git_reflog_entry *entry; const char *msg; regmatch_t regexmatches[2]; @@ -204,7 +205,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out, for (i = 0; i < numentries; i++) { entry = git_reflog_entry_byindex(reflog, i); msg = git_reflog_entry_message(entry); - + if (regexec(&preg, msg, 2, regexmatches, 0)) continue; @@ -212,7 +213,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out, if (cur > 0) continue; - + git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so); if ((error = disambiguate_refname(base_ref, repo, git_buf_cstr(&buf))) == 0) @@ -225,7 +226,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out, goto cleanup; } - + error = GIT_ENOTFOUND; cleanup: @@ -236,27 +237,25 @@ cleanup: return error; } -static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned int identifier) +static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier) { git_reflog *reflog; int error = -1; - unsigned int numentries; + size_t numentries; const git_reflog_entry *entry; bool search_by_pos = (identifier <= 100000000); if (git_reflog_read(&reflog, ref) < 0) return -1; - numentries = git_reflog_entrycount(reflog); + numentries = git_reflog_entrycount(reflog); if (search_by_pos) { if (numentries < identifier + 1) { giterr_set( GITERR_REFERENCE, - "Reflog for '%s' has only %d entries, asked for %d", - git_reference_name(ref), - numentries, - identifier); + "Reflog for '%s' has only "PRIuZ" entries, asked for "PRIuZ, + git_reference_name(ref), numentries, identifier); error = GIT_ENOTFOUND; goto cleanup; @@ -268,14 +267,14 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i goto cleanup; } else { - unsigned int i; + size_t i; git_time commit_time; for (i = 0; i < numentries; i++) { entry = git_reflog_entry_byindex(reflog, i); commit_time = git_reflog_entry_committer(entry)->when; - - if (commit_time.time - identifier > 0) + + if (commit_time.time > (git_time_t)identifier) continue; git_oid_cpy(oid, git_reflog_entry_id_new(entry)); @@ -291,7 +290,7 @@ cleanup: return error; } -static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, unsigned int position) +static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position) { git_reference *ref; git_oid oid; @@ -380,7 +379,7 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s if (git__date_parse(×tamp, curly_braces_content) < 0) goto cleanup; - error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (unsigned int)timestamp); + error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp); cleanup: git_buf_free(&identifier); @@ -394,7 +393,7 @@ static git_otype parse_obj_type(const char *str) if (!strcmp(str, "tree")) return GIT_OBJ_TREE; - + if (!strcmp(str, "blob")) return GIT_OBJ_BLOB; diff --git a/src/stash.c b/src/stash.c index 2efdd91c5..b16637e59 100644 --- a/src/stash.c +++ b/src/stash.c @@ -56,7 +56,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit) static int append_commit_description(git_buf *out, git_commit* commit) { const char *message; - int pos = 0, len; + size_t pos = 0, len; if (append_abbreviated_oid(out, git_commit_id(commit)) < 0) return -1; diff --git a/src/transports/cred.c b/src/transports/cred.c index 55295372f..e137ca9ac 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -11,7 +11,7 @@ static void plaintext_free(struct git_cred *cred) { git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; - int pass_len = strlen(c->password); + size_t pass_len = strlen(c->password); git__free(c->username); @@ -19,6 +19,8 @@ static void plaintext_free(struct git_cred *cred) memset(c->password, 0x0, pass_len); git__free(c->password); + memset(c, 0, sizeof(*c)); + git__free(c); } @@ -54,4 +56,4 @@ int git_cred_userpass_plaintext_new( *cred = &c->parent; return 0; -}
\ No newline at end of file +} diff --git a/src/transports/smart.c b/src/transports/smart.c index 8f9715a3f..195ea285c 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -24,7 +24,7 @@ static int git_smart__recv_cb(gitno_buffer *buf) buf->offset += bytes_read; if (t->packetsize_cb) - t->packetsize_cb(bytes_read, t->packetsize_payload); + t->packetsize_cb((int)bytes_read, t->packetsize_payload); return (int)(buf->offset - old_len); } diff --git a/src/transports/smart.h b/src/transports/smart.h index 046bc89a4..b37c4ba96 100644 --- a/src/transports/smart.h +++ b/src/transports/smart.h @@ -94,7 +94,7 @@ typedef struct transport_smart_caps { include_tag:1; } transport_smart_caps; -typedef void (*packetsize_cb)(int received, void *payload); +typedef void (*packetsize_cb)(size_t received, void *payload); typedef struct { git_transport parent; diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index 06424cb17..99d34e23b 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -367,7 +367,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack, return 0; } -struct network_packetsize_payload +struct network_packetsize_payload { git_transfer_progress_callback callback; void *payload; @@ -375,7 +375,7 @@ struct network_packetsize_payload size_t last_fired_bytes; }; -static void network_packetsize(int received, void *payload) +static void network_packetsize(size_t received, void *payload) { struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload; @@ -384,8 +384,8 @@ static void network_packetsize(int received, void *payload) /* Fire notification if the threshold is reached */ if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) { - npp->last_fired_bytes = npp->stats->received_bytes; - npp->callback(npp->stats, npp->payload); + npp->last_fired_bytes = npp->stats->received_bytes; + npp->callback(npp->stats, npp->payload); } } @@ -414,7 +414,7 @@ int git_smart__download_pack( /* We might have something in the buffer already from negotiate_fetch */ if (t->buffer.offset > 0) - t->packetsize_cb(t->buffer.offset, t->packetsize_payload); + t->packetsize_cb((int)t->buffer.offset, t->packetsize_payload); } if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index df6cd87ec..f3abe8598 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -376,7 +376,7 @@ replay: if (!WinHttpReadData(s->request, (LPVOID)buffer, - buf_size, + (DWORD)buf_size, &dw_bytes_read)) { giterr_set(GITERR_OS, "Failed to read data"); diff --git a/src/tree.c b/src/tree.c index 177ccb98d..b3f5c302d 100644 --- a/src/tree.c +++ b/src/tree.c @@ -353,10 +353,9 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj) return tree_parse_buffer(tree, (char *)obj->raw.data, (char *)obj->raw.data + obj->raw.len); } -static unsigned int find_next_dir(const char *dirname, git_index *index, unsigned int start) +static size_t find_next_dir(const char *dirname, git_index *index, size_t start) { - unsigned int i, entries = git_index_entrycount(index); - size_t dirlen; + size_t dirlen, i, entries = git_index_entrycount(index); dirlen = strlen(dirname); for (i = start; i < entries; ++i) { @@ -399,11 +398,10 @@ static int write_tree( git_repository *repo, git_index *index, const char *dirname, - unsigned int start) + size_t start) { git_treebuilder *bld = NULL; - - unsigned int i, entries = git_index_entrycount(index); + size_t i, entries = git_index_entrycount(index); int error; size_t dirname_len = strlen(dirname); const git_tree_cache *cache; @@ -411,13 +409,11 @@ static int write_tree( cache = git_tree_cache_get(index->tree, dirname); if (cache != NULL && cache->entries >= 0){ git_oid_cpy(oid, &cache->oid); - return find_next_dir(dirname, index, start); + return (int)find_next_dir(dirname, index, start); } - error = git_treebuilder_create(&bld, NULL); - if (bld == NULL) { + if ((error = git_treebuilder_create(&bld, NULL)) < 0 || bld == NULL) return -1; - } /* * This loop is unfortunate, but necessary. The index doesn't have @@ -494,7 +490,7 @@ static int write_tree( goto on_error; git_treebuilder_free(bld); - return i; + return (int)i; on_error: git_treebuilder_free(bld); diff --git a/src/vector.c b/src/vector.c index c758583b6..5d3bc0887 100644 --- a/src/vector.c +++ b/src/vector.c @@ -165,7 +165,7 @@ int git_vector_search2( for (i = 0; i < v->length; ++i) { if (key_lookup(key, v->contents[i]) == 0) - return i; + return (int)i; } return GIT_ENOTFOUND; diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index e301290dc..3a4398bbd 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -520,17 +520,17 @@ int p_inet_pton(int af, const char* src, void* dst) struct sockaddr_in6 sin6; struct sockaddr_in sin; } sa; - size_t srcsize; + int srcsize; switch(af) { case AF_INET: sa.sin.sin_family = AF_INET; - srcsize = sizeof (sa.sin); + srcsize = (int)sizeof(sa.sin); break; case AF_INET6: sa.sin6.sin6_family = AF_INET6; - srcsize = sizeof (sa.sin6); + srcsize = (int)sizeof(sa.sin6); break; default: errno = WSAEPFNOSUPPORT; |