Fix C4703 uninitialized pointer variable warnings for VCPKG builds

This commit is contained in:
Nathan Baird
2025-10-28 12:58:29 -07:00
parent 58d9363f02
commit 09bdcf3d4c
7 changed files with 12 additions and 12 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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))) {

View File

@@ -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;

View File

@@ -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;