Fix Win32 warnings
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
diff --git a/src/attr_file.c b/src/attr_file.c
index 650b58f..25c21b1 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -403,7 +403,8 @@ int git_attr_fnmatch__parse(
/* given an unrooted fullpath match from a file inside a repo,
* prefix the pattern with the relative directory of the source file
*/
- spec->pattern = git_pool_malloc(pool, sourcelen + spec->length + 1);
+ spec->pattern = git_pool_malloc(
+ pool, (uint32_t)(sourcelen + spec->length + 1));
if (spec->pattern) {
memcpy(spec->pattern, source, sourcelen);
memcpy(spec->pattern + sourcelen, pattern, spec->length);
diff --git a/src/diff.c b/src/diff.c
index b239031..5d70b82 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -313,7 +313,8 @@ static git_diff_list *git_diff_list_alloc(
if (!diff_pathspec_is_interesting(&opts->pathspec))
return diff;
- if (git_vector_init(&diff->pathspec, opts->pathspec.count, NULL) < 0)
+ if (git_vector_init(
+ &diff->pathspec, (unsigned int)opts->pathspec.count, NULL) < 0)
goto fail;
for (i = 0; i < opts->pathspec.count; ++i) {
diff --git a/src/indexer.c b/src/indexer.c
index 1f8b512..22a510a 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -376,7 +376,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
git__free(obj.data);
- stats->processed = ++processed;
+ stats->processed = (unsigned int)++processed;
}
return 0;
diff --git a/src/khash.h b/src/khash.h
index f9d2393..bd67fe1 100644
--- a/src/khash.h
+++ b/src/khash.h
@@ -196,8 +196,8 @@ static const double __ac_HASH_UPPER = 0.77;
SCOPE void kh_destroy_##name(kh_##name##_t *h) \
{ \
if (h) { \
- kfree(h->keys); kfree(h->flags); \
- kfree(h->vals); \
+ kfree((void *)h->keys); kfree(h->flags); \
+ kfree((void *)h->vals); \
kfree(h); \
} \
} \
@@ -235,11 +235,11 @@ static const double __ac_HASH_UPPER = 0.77;
if (!new_flags) return -1; \
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (h->n_buckets < new_n_buckets) { /* expand */ \
- khkey_t *new_keys = (khkey_t*)krealloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
+ khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
if (!new_keys) return -1; \
h->keys = new_keys; \
if (kh_is_map) { \
- khval_t *new_vals = (khval_t*)krealloc(h->vals, new_n_buckets * sizeof(khval_t)); \
+ khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
if (!new_vals) return -1; \
h->vals = new_vals; \
} \
@@ -275,8 +275,8 @@ static const double __ac_HASH_UPPER = 0.77;
} \
} \
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
- h->keys = (khkey_t*)krealloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
- if (kh_is_map) h->vals = (khval_t*)krealloc(h->vals, new_n_buckets * sizeof(khval_t)); \
+ h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
+ if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
} \
kfree(h->flags); /* free the working space */ \
h->flags = new_flags; \
@@ -376,8 +376,8 @@ static const double __ac_HASH_UPPER = 0.77;
*/
static inline khint_t __ac_X31_hash_string(const char *s)
{
- khint_t h = *s;
- if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
+ khint_t h = (khint_t)*s;
+ if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s;
return h;
}
/*! @function
diff --git a/src/pool.c b/src/pool.c
index 8f5c7e7..641292d 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -190,7 +190,7 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
assert(pool && str && pool->item_size == sizeof(char));
- if ((ptr = git_pool_malloc(pool, n + 1)) != NULL) {
+ if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) {
memcpy(ptr, str, n);
*(((char *)ptr) + n) = '\0';
}
@@ -216,7 +216,7 @@ char *git_pool_strcat(git_pool *pool, const char *a, const char *b)
len_a = a ? strlen(a) : 0;
len_b = b ? strlen(b) : 0;
- if ((ptr = git_pool_malloc(pool, len_a + len_b + 1)) != NULL) {
+ if ((ptr = git_pool_malloc(pool, (uint32_t)(len_a + len_b + 1))) != NULL) {
if (len_a)
memcpy(ptr, a, len_a);
if (len_b)
@@ -256,12 +256,12 @@ bool git_pool__ptr_in_pool(git_pool *pool, void *ptr)
{
git_pool_page *scan;
for (scan = pool->open; scan != NULL; scan = scan->next)
- if ( ((void *)scan->data) <= ptr &&
- (((void *)scan->data) + scan->size) > ptr)
+ if ((void *)scan->data <= ptr &&
+ (void *)(((char *)scan->data) + scan->size) > ptr)
return true;
for (scan = pool->full; scan != NULL; scan = scan->next)
- if ( ((void *)scan->data) <= ptr &&
- (((void *)scan->data) + scan->size) > ptr)
+ if ((void *)scan->data <= ptr &&
+ (void *)(((char *)scan->data) + scan->size) > ptr)
return true;
return false;
}
diff --git a/src/revwalk.c b/src/revwalk.c
index 4f2f827..c62bb4e 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -141,7 +141,7 @@ static commit_object **alloc_parents(
return (commit_object **)((char *)commit + sizeof(commit_object));
return (commit_object **)git_pool_malloc(
- &walk->commit_pool, n_parents * sizeof(commit_object *));
+ &walk->commit_pool, (uint32_t)(n_parents * sizeof(commit_object *)));
}