Commit 9a193102d011633801855483a0c10af65a9cbf6d

Patrick Steinhardt 2018-08-24T11:01:39

Merge pull request #4774 from tiennou/fix/clang-analyzer Coverity flavored clang analyzer fixes

diff --git a/src/mailmap.c b/src/mailmap.c
index fe4d452..1f725b3 100644
--- a/src/mailmap.c
+++ b/src/mailmap.c
@@ -225,7 +225,7 @@ int git_mailmap_add_entry(
 
 static int mailmap_add_buffer(git_mailmap *mm, const char *buf, size_t len)
 {
-	int error;
+	int error = 0;
 	git_parse_ctx ctx;
 
 	/* Scratch buffers containing the real parsed names & emails */
diff --git a/src/remote.c b/src/remote.c
index ca73ede..9c0e88a 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -428,7 +428,7 @@ static int get_optional_config(
 
 int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
 {
-	git_remote *remote;
+	git_remote *remote = NULL;
 	git_buf buf = GIT_BUF_INIT;
 	const char *val;
 	int error = 0;
@@ -510,7 +510,7 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
 	if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0)
 		goto cleanup;
 
-	if (download_tags_value(remote, config) < 0)
+	if ((error = download_tags_value(remote, config)) < 0)
 		goto cleanup;
 
 	if ((error = lookup_remote_prune_config(remote, config, name)) < 0)
diff --git a/src/revwalk.c b/src/revwalk.c
index be647af..da84a44 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -550,7 +550,7 @@ cleanup:
 
 static int prepare_walk(git_revwalk *walk)
 {
-	int error;
+	int error = 0;
 	git_commit_list *list, *commits = NULL;
 	git_commit_list_node *next;
 
diff --git a/src/transports/http.c b/src/transports/http.c
index ea3e57a..bc3ab18 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -142,7 +142,7 @@ static int auth_context_match(
 	}
 
 	if (!scheme)
-		return 0;
+		return -1;
 
 	/* See if authentication has already started for this scheme */
 	git_vector_foreach(&t->auth_contexts, i, c) {