Fix MSVC compilation 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 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
diff --git a/src/indexer.c b/src/indexer.c
index 70b2ce0..603c206 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -273,7 +273,7 @@ static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start,
if (ptr == NULL)
return -1;
- len = min(left, (size_t)size);
+ len = min(left, (unsigned int)size);
crc = crc32(crc, ptr, len);
size -= len;
start += len;
diff --git a/src/pack.c b/src/pack.c
index 6084508..3490c8b 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -621,7 +621,7 @@ ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t
return GIT_EBUFS;
obj->zstream.next_out = buffer;
- obj->zstream.avail_out = len;
+ obj->zstream.avail_out = (unsigned int)len;
obj->zstream.next_in = in;
st = inflate(&obj->zstream, Z_SYNC_FLUSH);
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index 1a471b7..808f6af 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -298,7 +298,7 @@ static int write_chunk(HINTERNET request, const char *buffer, size_t len)
return -1;
if (!WinHttpWriteData(request,
- git_buf_cstr(&buf), git_buf_len(&buf),
+ git_buf_cstr(&buf), (DWORD)git_buf_len(&buf),
&bytes_written)) {
git_buf_free(&buf);
giterr_set(GITERR_OS, "Failed to write chunk header");
@@ -309,7 +309,7 @@ static int write_chunk(HINTERNET request, const char *buffer, size_t len)
/* Chunk body */
if (!WinHttpWriteData(request,
- buffer, len,
+ buffer, (DWORD)len,
&bytes_written)) {
giterr_set(GITERR_OS, "Failed to write chunk");
return -1;
@@ -494,7 +494,7 @@ replay:
if (!WinHttpReadData(s->request,
(LPVOID)buffer,
- buf_size,
+ (DWORD)buf_size,
&dw_bytes_read))
{
giterr_set(GITERR_OS, "Failed to read data");
@@ -580,7 +580,7 @@ static int put_uuid_string(LPWSTR buffer, DWORD buffer_len_cch)
static int get_temp_file(LPWSTR buffer, DWORD buffer_len_cch)
{
- int len;
+ size_t len;
if (!GetTempPathW(buffer_len_cch, buffer)) {
giterr_set(GITERR_OS, "Failed to get temp path");
@@ -639,7 +639,7 @@ static int winhttp_stream_write_buffered(
}
}
- if (!WriteFile(s->post_body, buffer, len, &bytes_written, NULL)) {
+ if (!WriteFile(s->post_body, buffer, (DWORD)len, &bytes_written, NULL)) {
giterr_set(GITERR_OS, "Failed to write to temporary file");
return -1;
}
@@ -697,7 +697,7 @@ static int winhttp_stream_write_chunked(
}
else {
/* Append as much to the buffer as we can */
- int count = min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len);
+ int count = min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, (int)len);
if (!s->chunk_buffer)
s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE);
@@ -717,7 +717,7 @@ static int winhttp_stream_write_chunked(
/* Is there any remaining data from the source? */
if (len > 0) {
memcpy(s->chunk_buffer, buffer, len);
- s->chunk_buffer_len = len;
+ s->chunk_buffer_len = (unsigned int)len;
}
}
}
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index 9d22b73..f241abf 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -143,7 +143,7 @@ void test_clone_nonetwork__custom_autotag(void)
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
cl_git_pass(git_tag_list(&tags, g_repo));
- cl_assert_equal_i(0, tags.count);
+ cl_assert_equal_sz(0, tags.count);
git_strarray_free(&tags);
}
diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c
index 293a585..e2617ab 100644
--- a/tests-clar/revwalk/mergebase.c
+++ b/tests-clar/revwalk/mergebase.c
@@ -33,12 +33,12 @@ void test_revwalk_mergebase__single1(void)
cl_assert(git_oid_cmp(&result, &expected) == 0);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
- cl_assert_equal_i(ahead, 2);
- cl_assert_equal_i(behind, 1);
+ cl_assert_equal_sz(ahead, 2);
+ cl_assert_equal_sz(behind, 1);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &two, &one));
- cl_assert_equal_i(ahead, 1);
- cl_assert_equal_i(behind, 2);
+ cl_assert_equal_sz(ahead, 1);
+ cl_assert_equal_sz(behind, 2);
}
void test_revwalk_mergebase__single2(void)
@@ -54,12 +54,12 @@ void test_revwalk_mergebase__single2(void)
cl_assert(git_oid_cmp(&result, &expected) == 0);
cl_git_pass(git_graph_ahead_behind( &ahead, &behind, _repo, &one, &two));
- cl_assert_equal_i(ahead, 4);
- cl_assert_equal_i(behind, 1);
+ cl_assert_equal_sz(ahead, 4);
+ cl_assert_equal_sz(behind, 1);
cl_git_pass(git_graph_ahead_behind( &ahead, &behind, _repo, &two, &one));
- cl_assert_equal_i(ahead, 1);
- cl_assert_equal_i(behind, 4);
+ cl_assert_equal_sz(ahead, 1);
+ cl_assert_equal_sz(behind, 4);
}
void test_revwalk_mergebase__merged_branch(void)
@@ -78,12 +78,12 @@ void test_revwalk_mergebase__merged_branch(void)
cl_assert(git_oid_cmp(&result, &expected) == 0);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
- cl_assert_equal_i(ahead, 0);
- cl_assert_equal_i(behind, 3);
+ cl_assert_equal_sz(ahead, 0);
+ cl_assert_equal_sz(behind, 3);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &two, &one));
- cl_assert_equal_i(ahead, 3);
- cl_assert_equal_i(behind, 0);
+ cl_assert_equal_sz(ahead, 3);
+ cl_assert_equal_sz(behind, 0);
}
void test_revwalk_mergebase__two_way_merge(void)
@@ -95,13 +95,13 @@ void test_revwalk_mergebase__two_way_merge(void)
cl_git_pass(git_oid_fromstr(&two, "a953a018c5b10b20c86e69fef55ebc8ad4c5a417"));
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &one, &two));
- cl_assert_equal_i(ahead, 2);
- cl_assert_equal_i(behind, 8);
+ cl_assert_equal_sz(ahead, 2);
+ cl_assert_equal_sz(behind, 8);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &two, &one));
- cl_assert_equal_i(ahead, 8);
- cl_assert_equal_i(behind, 2);
+ cl_assert_equal_sz(ahead, 8);
+ cl_assert_equal_sz(behind, 2);
}
void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
@@ -119,8 +119,8 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
cl_assert_equal_i(GIT_ENOTFOUND, error);
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
- cl_assert_equal_i(2, ahead);
- cl_assert_equal_i(4, behind);
+ cl_assert_equal_sz(2, ahead);
+ cl_assert_equal_sz(4, behind);
}
void test_revwalk_mergebase__no_off_by_one_missing(void)