Commit aeb2b991b0e645100976db620e50da65c51db66e

Carlos Martín Nieto 2015-06-16T09:20:36

Merge pull request #3221 from git-up/build_warnings Fixed Xcode 6.1 build warnings

diff --git a/src/diff_patch.c b/src/diff_patch.c
index 63253c2..60648f8 100644
--- a/src/diff_patch.c
+++ b/src/diff_patch.c
@@ -285,7 +285,7 @@ done:
 
 static int diff_binary(git_diff_output *output, git_patch *patch)
 {
-	git_diff_binary binary = { 0 };
+	git_diff_binary binary = {{0}};
 	const char *old_data = patch->ofile.map.data;
 	const char *new_data = patch->nfile.map.data;
 	size_t old_len = patch->ofile.map.len,
diff --git a/src/diff_print.c b/src/diff_print.c
index ebae4ea..c586983 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -335,7 +335,6 @@ static int format_binary(
 	const char *typename = type == GIT_DIFF_BINARY_DELTA ?
 		"delta" : "literal";
 	const char *scan, *end;
-	int error = 0;
 
 	git_buf_printf(pi->buf, "%s %lu\n", typename, inflatedlen);
 	pi->line.num_lines++;
diff --git a/src/path.c b/src/path.c
index aca85f9..c04b506 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1045,7 +1045,7 @@ int git_path_direach(
 #endif
 
 	while ((de = readdir(dir)) != NULL) {
-		char *de_path = de->d_name;
+		const char *de_path = de->d_name;
 		size_t de_len = strlen(de_path);
 
 		if (git_path_is_dot_or_dotdot(de_path))
@@ -1305,7 +1305,7 @@ int git_path_diriter_next(git_path_diriter *diriter)
 
 #ifdef GIT_USE_ICONV
 	if ((diriter->flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0 &&
-		(error = git_path_iconv(&diriter->ic, (char **)&filename, &filename_len)) < 0)
+		(error = git_path_iconv(&diriter->ic, &filename, &filename_len)) < 0)
 		return error;
 #endif
 
diff --git a/src/refs.c b/src/refs.c
index ff5e240..7b53865 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -863,7 +863,7 @@ int git_reference__normalize_name(
 	const char *name,
 	unsigned int flags)
 {
-	char *current;
+	const char *current;
 	int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC;
 	unsigned int process_flags;
 	bool normalize = (buf != NULL);
diff --git a/tests/core/iconv.c b/tests/core/iconv.c
index cb85f45..498094b 100644
--- a/tests/core/iconv.c
+++ b/tests/core/iconv.c
@@ -24,7 +24,7 @@ void test_core_iconv__cleanup(void)
 void test_core_iconv__unchanged(void)
 {
 #ifdef GIT_USE_ICONV
-	char *data = "Ascii data", *original = data;
+	const char *data = "Ascii data", *original = data;
 	size_t datalen = strlen(data);
 
 	cl_git_pass(git_path_iconv(&ic, &data, &datalen));
@@ -38,7 +38,7 @@ void test_core_iconv__unchanged(void)
 void test_core_iconv__decomposed_to_precomposed(void)
 {
 #ifdef GIT_USE_ICONV
-	char *data = nfd;
+	const char *data = nfd;
 	size_t datalen, nfdlen = strlen(nfd);
 
 	datalen = nfdlen;
@@ -64,7 +64,7 @@ void test_core_iconv__decomposed_to_precomposed(void)
 void test_core_iconv__precomposed_is_unmodified(void)
 {
 #ifdef GIT_USE_ICONV
-	char *data = nfc;
+	const char *data = nfc;
 	size_t datalen = strlen(nfc);
 
 	cl_git_pass(git_path_iconv(&ic, &data, &datalen));
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 7fac1c5..424a53e 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -317,6 +317,8 @@ static int print_cb(
 {
 	git_buf *buf = (git_buf *)payload;
 
+	GIT_UNUSED(delta);
+
 	if (hunk)
 		git_buf_put(buf, hunk->header, hunk->header_len);
 
@@ -382,6 +384,8 @@ static int file_cb(
 {
 	struct diff_data *diff_data = payload;
 
+	GIT_UNUSED(progress);
+
 	if (delta->old_file.path)
 		diff_data->old_path = git__strdup(delta->old_file.path);
 
@@ -401,6 +405,8 @@ static int binary_cb(
 {
 	struct diff_data *diff_data = payload;
 
+	GIT_UNUSED(delta);
+
 	git_buf_encode_base85(&diff_data->old_binary_base85,
 		binary->old_file.data, binary->old_file.datalen);
 	diff_data->old_binary_inflatedlen = binary->old_file.inflatedlen;
@@ -419,6 +425,10 @@ static int hunk_cb(
 	const git_diff_hunk *hunk,
 	void *payload)
 {
+	GIT_UNUSED(delta);
+	GIT_UNUSED(hunk);
+	GIT_UNUSED(payload);
+
 	cl_fail("did not expect hunk callback");
 	return 0;
 }
@@ -429,6 +439,11 @@ static int line_cb(
 	const git_diff_line *line,
 	void *payload)
 {
+	GIT_UNUSED(delta);
+	GIT_UNUSED(hunk);
+	GIT_UNUSED(line);
+	GIT_UNUSED(payload);
+
 	cl_fail("did not expect line callback");
 	return 0;
 }
@@ -440,15 +455,6 @@ void test_diff_binary__blob_to_blob(void)
 	git_blob *old_blob, *new_blob;
 	git_oid old_id, new_id;
 	struct diff_data diff_data = {0};
-	const char *expected =
-		"diff --git a/untimely.txt b/untimely.txt\n" \
-		"index 9a69d960ae94b060f56c2a8702545e2bb1abb935..1111d4f11f4b35bf6759e0fb714fe09731ef0840 100644\n" \
-		"GIT binary patch\n" \
-		"delta 32\n" \
-		"nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
-		"\n" \
-		"delta 7\n" \
-		"Oc%18D`@*{63ljhg(E~C7\n";
 
 	opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
 	opts.id_abbrev = GIT_OID_HEXSZ;
diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c
index c735257..c6cdf80 100644
--- a/tests/diff/diff_helpers.c
+++ b/tests/diff/diff_helpers.c
@@ -164,6 +164,8 @@ int diff_foreach_via_iterator(
 {
 	size_t d, num_d = git_diff_num_deltas(diff);
 
+	GIT_UNUSED(binary_cb);
+
 	for (d = 0; d < num_d; ++d) {
 		git_patch *patch;
 		const git_diff_delta *delta;