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

Skip to content

Conversation

@ShiningMassXAcc
Copy link

Addresses C4703 uninitialized variables warnings that promote to errors with /sdl flag

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4703?view=msvc-170

@ShiningMassXAcc ShiningMassXAcc changed the title Fix C4703 uninitialized pointer variable warnings for VCPKG builds Fix C4703 uninitialized pointer variable warnings Oct 28, 2025
src/util/net.c Outdated
const char *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.

src/util/net.c Outdated
{
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?

Copy link
Contributor
@tyrielv tyrielv left a comment

Choose a reason for hiding this comment

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

I suspect more warnings will pop up since there are still uninitialized variables, but what's there is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0