diff --git a/src/libgit2/commit.c b/src/libgit2/commit.c index 10df43623..633279227 100644 --- a/src/libgit2/commit.c +++ b/src/libgit2/commit.c @@ -340,7 +340,7 @@ int git_commit_amend( { git_repository *repo; git_oid tree_id; - git_reference *ref; + git_reference *ref = NULL; int error; GIT_ASSERT_ARG(id); diff --git a/src/libgit2/fetchhead.c b/src/libgit2/fetchhead.c index 08be282a5..1555d1cd9 100644 --- a/src/libgit2/fetchhead.c +++ b/src/libgit2/fetchhead.c @@ -106,7 +106,7 @@ static int fetchhead_ref_write( git_fetchhead_ref *fetchhead_ref) { char oid[GIT_OID_MAX_HEXSIZE + 1]; - const char *type, *name; + const char *type = NULL, *name = NULL; int head = 0; GIT_ASSERT_ARG(file); diff --git a/src/libgit2/index.c b/src/libgit2/index.c index 2f1f1b8d5..e8a692169 100644 --- a/src/libgit2/index.c +++ b/src/libgit2/index.c @@ -2510,7 +2510,7 @@ static int read_entry( { size_t path_length, path_offset, entry_size; const char *path_ptr; - struct entry_common *source_common; + struct entry_common *source_common = NULL; index_entry_short_sha1 source_sha1; #ifdef GIT_EXPERIMENTAL_SHA256 index_entry_short_sha256 source_sha256; @@ -2862,7 +2862,7 @@ static int write_disk_entry( const char *last) { void *mem = NULL; - struct entry_common *ondisk_common; + struct entry_common *ondisk_common = NULL; size_t path_len, path_offset, disk_size; int varint_len = 0; char *path; @@ -2951,7 +2951,7 @@ static int write_disk_entry( path_offset = index_entry_path_offset(index->oid_type, entry->flags); if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) { - struct entry_common *ondisk_ext; + struct entry_common *ondisk_ext = NULL; uint16_t flags_extended = htons(entry->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS); diff --git a/src/libgit2/merge.c b/src/libgit2/merge.c index eabb4bfa3..b73454d77 100644 --- a/src/libgit2/merge.c +++ b/src/libgit2/merge.c @@ -936,7 +936,7 @@ static int merge_conflict_resolve_contents( git_merge_file_result result = {0}; git_merge_driver *driver; git_merge_driver__builtin builtin = {{0}}; - git_index_entry *merge_result; + git_index_entry *merge_result = NULL; git_odb *odb = NULL; const char *name; bool fallback = false; diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c index a88217e65..e648e8e1a 100644 --- a/src/libgit2/repository.c +++ b/src/libgit2/repository.c @@ -669,7 +669,7 @@ static int validate_ownership_path(bool *is_safe, const char *path) static int validate_ownership(git_repository *repo) { - const char *validation_paths[3] = { NULL }, *path; + const char *validation_paths[3] = { NULL }, *path = NULL; size_t validation_len = 0, i; bool is_safe = false; int error = 0; @@ -1412,7 +1412,7 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo) git_str xdg_buf = GIT_STR_INIT; git_str programdata_buf = GIT_STR_INIT; bool use_env = repo->use_env; - git_config *config; + git_config *config = NULL; if (!(error = config_path_system(&system_buf, use_env)) && !(error = config_path_global(&global_buf, use_env))) { diff --git a/src/libgit2/transports/httpclient.c b/src/libgit2/transports/httpclient.c index e25e0a73a..e27d40b5f 100644 --- a/src/libgit2/transports/httpclient.c +++ b/src/libgit2/transports/httpclient.c @@ -553,7 +553,7 @@ static int apply_credentials( { git_http_auth_context *auth = server->auth_context; git_vector *challenges = &server->auth_challenges; - const char *challenge; + const char *challenge = NULL; git_str token = GIT_STR_INIT; int error = 0; diff --git a/src/util/net.c b/src/util/net.c index d7ca48a59..136a97a7a 100644 --- a/src/util/net.c +++ b/src/util/net.c @@ -185,7 +185,7 @@ static int url_parse_authority( size_t len) { const char *c, *hostport_end, *host_end = NULL, - *userpass_end, *user_end = NULL; + *userpass_end = NULL, *user_end = NULL; enum { HOSTPORT, HOST, IPV6, HOST_END, USERPASS, USER @@ -574,7 +574,7 @@ int git_net_url_parse_http( const char *given) { git_net_url_parser parser = GIT_NET_URL_PARSER_INIT; - const char *c, *authority, *path = NULL; + const char *c, *authority = NULL, *path = NULL; size_t authority_len = 0, path_len = 0; int error; @@ -661,7 +661,7 @@ static bool has_at(const char *str) int git_net_url_parse_scp(git_net_url *url, const char *given) { const char *default_port = default_port_for_scheme("ssh"); - const char *c, *user, *host, *port = NULL, *path = NULL; + const char *c, *user = NULL, *host = NULL, *port = NULL, *path = NULL; size_t user_len = 0, host_len = 0, port_len = 0; unsigned short bracket = 0;