Commit 92d19d16711c059c768063956abd31db346d2e7b

Vicent Martí 2013-09-21T09:34:03

Merge pull request #1840 from linquize/warning Fix warning

diff --git a/include/git2/index.h b/include/git2/index.h
index b445356..ba0bcc9 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -219,7 +219,7 @@ GIT_EXTERN(unsigned int) git_index_caps(const git_index *index);
  * @param caps A combination of GIT_INDEXCAP values
  * @return 0 on success, -1 on failure
  */
-GIT_EXTERN(int) git_index_set_caps(git_index *index, unsigned int caps);
+GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
 
 /**
  * Update the contents of an existing index object in memory
diff --git a/src/attr_file.c b/src/attr_file.c
index 92702df..4eb7324 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -39,7 +39,7 @@ int git_attr_file__new(
 		attrs->key = git_pool_malloc(attrs->pool, (uint32_t)len + 3);
 		GITERR_CHECK_ALLOC(attrs->key);
 
-		attrs->key[0] = '0' + from;
+		attrs->key[0] = '0' + (char)from;
 		attrs->key[1] = '#';
 		memcpy(&attrs->key[2], path, len);
 		attrs->key[len + 2] = '\0';
diff --git a/src/buffer.c b/src/buffer.c
index f8d47d9..1371607 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -154,7 +154,7 @@ int git_buf_puts(git_buf *buf, const char *string)
 	return git_buf_put(buf, string, strlen(string));
 }
 
-static const char b64str[64] =
+static const char b64str[] =
 	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 int git_buf_put_base64(git_buf *buf, const char *data, size_t len)
diff --git a/src/config_file.c b/src/config_file.c
index d0910a2..1a845d8 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -132,7 +132,7 @@ int git_config_file_normalize_section(char *start, char *end)
 		if (end && scan >= end)
 			break;
 		if (isalnum(*scan))
-			*scan = tolower(*scan);
+			*scan = (char)tolower(*scan);
 		else if (*scan != '-' || scan == start)
 			return GIT_EINVALIDSPEC;
 	}
@@ -781,7 +781,7 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
 			break;
 		}
 
-		git_buf_putc(&buf, c);
+		git_buf_putc(&buf, (char)c);
 	} while ((c = line[rpos++]) != ']');
 
 	*section_name = git_buf_detach(&buf);
diff --git a/src/diff.c b/src/diff.c
index 4d9ace1..39facce 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -440,7 +440,8 @@ static int diff_list_apply_options(
 
 	/* If not given explicit `opts`, check `diff.xyz` configs */
 	if (!opts) {
-		diff->opts.context_lines = config_int(cfg, "diff.context", 3);
+		int context = config_int(cfg, "diff.context", 3);
+		diff->opts.context_lines = context >= 0 ? (uint16_t)context : 3;
 
 		/* add other defaults here */
 	}
diff --git a/src/index.c b/src/index.c
index 9b32222..b4f2a3b 100644
--- a/src/index.c
+++ b/src/index.c
@@ -408,9 +408,9 @@ static int create_index_error(int error, const char *msg)
 	return error;
 }
 
-int git_index_set_caps(git_index *index, unsigned int caps)
+int git_index_set_caps(git_index *index, int caps)
 {
-	int old_ignore_case;
+	unsigned int old_ignore_case;
 
 	assert(index);
 
@@ -438,7 +438,7 @@ int git_index_set_caps(git_index *index, unsigned int caps)
 	}
 
 	if (old_ignore_case != index->ignore_case) {
-		git_index__set_ignore_case(index, index->ignore_case);
+		git_index__set_ignore_case(index, (bool)index->ignore_case);
 	}
 
 	return 0;
@@ -2092,7 +2092,7 @@ int git_index_add_all(
 
 		/* check if path actually matches */
 		if (!git_pathspec__match(
-				&ps.pathspec, wd->path, no_fnmatch, ignorecase, &match, NULL))
+				&ps.pathspec, wd->path, no_fnmatch, (bool)ignorecase, &match, NULL))
 			continue;
 
 		/* skip ignored items that are not already in the index */
@@ -2184,7 +2184,7 @@ static int index_apply_to_all(
 
 		/* check if path actually matches */
 		if (!git_pathspec__match(
-				&ps.pathspec, entry->path, false, index->ignore_case,
+				&ps.pathspec, entry->path, false, (bool)index->ignore_case,
 				&match, NULL))
 			continue;
 
diff --git a/src/odb.c b/src/odb.c
index eef9748..b2c138a 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -168,7 +168,6 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type)
 		error = -1;
 
 		goto done;
-		return -1;
 	}
 
 	error = git_hash_final(out, &ctx);
@@ -623,7 +622,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
 		git_odb_backend *b = internal->backend;
 
 		if (b->exists != NULL)
-			found = b->exists(b, id);
+			found = (bool)b->exists(b, id);
 	}
 
 	return (int)found;
diff --git a/src/oid.c b/src/oid.c
index a70b7e0..d56b6af 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -211,7 +211,7 @@ int git_oid_strcmp(const git_oid *oid_a, const char *str)
 	for (a = oid_a->id; *str && (a - oid_a->id) < GIT_OID_RAWSZ; ++a) {
 		if ((hexval = git__fromhex(*str++)) < 0)
 			return -1;
-		strval = hexval << 4;
+		strval = (unsigned char)(hexval << 4);
 		if (*str) {
 			if ((hexval = git__fromhex(*str++)) < 0)
 				return -1;
diff --git a/src/remote.c b/src/remote.c
index bfcb3eb..1540f10 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -362,7 +362,7 @@ cleanup:
 static int update_config_refspec(const git_remote *remote, git_config *config, int direction)
 {
 	git_buf name = GIT_BUF_INIT;
-	int push;
+	unsigned int push;
 	const char *dir;
 	size_t i;
 	int error = 0;
@@ -1549,7 +1549,7 @@ int git_remote_add_push(git_remote *remote, const char *refspec)
 	return add_refspec(remote, refspec, false);
 }
 
-static int copy_refspecs(git_strarray *array, git_remote *remote, int push)
+static int copy_refspecs(git_strarray *array, git_remote *remote, unsigned int push)
 {
 	size_t i;
 	git_vector refspecs;
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index 29d4ba6..592460f 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -195,7 +195,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
 	}
 
 	/* Set proxy if necessary */
-	if (git_remote__get_http_proxy(t->owner->owner, t->use_ssl, &proxy_url) < 0)
+	if (git_remote__get_http_proxy(t->owner->owner, !!t->use_ssl, &proxy_url) < 0)
 		goto on_error;
 
 	if (proxy_url) {
@@ -939,7 +939,7 @@ static int winhttp_connect(
 	t->connection = WinHttpConnect(
 			t->session,
 			host,
-			port,
+			(INTERNET_PORT)port,
 			0);
 
 	if (!t->connection) {