8000 Fix C4703 uninitialized pointer variable warnings by ShiningMassXAcc · Pull Request #7154 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix C4703 uninitialized pointer variable warnings for VCPKG builds
  • Loading branch information
ShiningMassXAcc committed Oct 28, 2025
commit 09bdcf3d4ca2d82b335ee35b843dac02e7d459f6
2 changes: 1 addition & 1 deletion src/libgit2/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/fetchhead.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/libgit2/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libgit2/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))) {
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/transports/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/util/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int url_parse_authority(
size_t len)
{
const char *c, *hostport_end, *host_end = NULL,
Copy link
Contributor
@tyrielv tyrielv Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do only some of these need an individual = NULL and not others? You've added one for userpass_end but c and hostport_end still don't have one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up to the compiler to look at usage after this and whether or not it will get deterministically assigned versus for others. I can get these as well just for consistency versus only fixing ones that /SDL asked for given the usage afterwards.

*userpass_end, *user_end = NULL;
*userpass_end = NULL, *user_end = NULL;

enum {
HOSTPORT, HOST, IPV6, HOST_END, USERPASS, USER
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar, why does authority need it but not c?

size_t authority_len = 0, path_len = 0;
int error;

Expand Down Expand Up @@ -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;

Expand Down
0