Clean up annoying warnings The indexer code was generating warnings on Windows 64-bit. I looked closely at the logic and was able to simplify it a bit. Also this fixes some other Windows and Linux 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
diff --git a/src/indexer.c b/src/indexer.c
index 4ce69fc..1270488 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -50,7 +50,7 @@ struct git_indexer_stream {
/* Fields for calculating the packfile trailer (hash of everything before it) */
char inbuf[GIT_OID_RAWSZ];
- int inbuf_len;
+ size_t inbuf_len;
git_hash_ctx trailer;
};
@@ -378,13 +378,13 @@ static int do_progress_callback(git_indexer_stream *idx, git_transfer_progress *
/* Hash everything but the last 20B of input */
static void hash_partially(git_indexer_stream *idx, const uint8_t *data, size_t size)
{
- int to_expell, to_keep;
+ size_t to_expell, to_keep;
if (size == 0)
return;
/* Easy case, dump the buffer and the data minus the last 20 bytes */
- if (size >= 20) {
+ if (size >= GIT_OID_RAWSZ) {
git_hash_update(&idx->trailer, idx->inbuf, idx->inbuf_len);
git_hash_update(&idx->trailer, data, size - GIT_OID_RAWSZ);
@@ -402,8 +402,8 @@ static void hash_partially(git_indexer_stream *idx, const uint8_t *data, size_t
}
/* We need to partially drain the buffer and then append */
- to_expell = abs(size - (GIT_OID_RAWSZ - idx->inbuf_len));
- to_keep = abs(idx->inbuf_len - to_expell);
+ to_keep = GIT_OID_RAWSZ - size;
+ to_expell = idx->inbuf_len - to_keep;
git_hash_update(&idx->trailer, idx->inbuf, to_expell);
diff --git a/src/repository.c b/src/repository.c
index 64f1397..51cc76d 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -890,6 +890,8 @@ static bool are_symlinks_supported(const char *wd_path)
return symlinks_supported;
}
+#ifdef GIT_USE_ICONV
+
static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D.XXXXXX";
static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
@@ -938,6 +940,8 @@ fail:
return need_precompose;
}
+#endif
+
static int create_empty_file(const char *path, mode_t mode)
{
int fd;
@@ -994,7 +998,7 @@ static int repo_init_config(
SET_REPO_CONFIG(
bool, "core.filemode", is_chmod_supported(git_buf_cstr(&cfg_path)));
-#if __APPLE__
+#ifdef GIT_USE_ICONV
SET_REPO_CONFIG(
bool, "core.precomposeunicode",
should_precompose_unicode_paths(is_bare ? repo_dir : work_dir));
diff --git a/tests-clar/core/iconv.c b/tests-clar/core/iconv.c
index 5a3e1de..73bc99a 100644
--- a/tests-clar/core/iconv.c
+++ b/tests-clar/core/iconv.c
@@ -21,6 +21,7 @@ void test_core_iconv__unchanged(void)
size_t datalen = strlen(data);
cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
/* There are no high bits set, so this should leave data untouched */
cl_assert(data == original);
@@ -32,6 +33,7 @@ void test_core_iconv__decomposed_to_precomposed(void)
size_t datalen = strlen(nfd);
cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
/* The decomposed nfd string should be transformed to the nfc form
* (on platforms where iconv is enabled, of course).
@@ -49,6 +51,7 @@ void test_core_iconv__precomposed_is_unmodified(void)
size_t datalen = strlen(nfc);
cl_git_pass(git_path_iconv(&ic, &data, &datalen));
+ GIT_UNUSED(datalen);
/* data is already in precomposed form, so even though some bytes have
* the high-bit set, the iconv transform should result in no change.
diff --git a/tests-clar/online/push.c b/tests-clar/online/push.c
index 4c2bec7..957cef7 100644
--- a/tests-clar/online/push.c
+++ b/tests-clar/online/push.c
@@ -356,7 +356,7 @@ static int push_pack_progress_cb(int stage, unsigned int current, unsigned int t
static int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void* payload)
{
int *was_called = (int *) payload;
- GIT_UNUSED(current); GIT_UNUSED(total); GIT_UNUSED(bytes);
+ GIT_UNUSED(current); GIT_UNUSED(total); GIT_UNUSED(bytes);
*was_called = 1;
return 0;
}