Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address spurious Microsoft compiler warnings #49

Merged
merged 4 commits into from
Nov 2, 2020
Merged
Changes from all commits
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
4 changes: 2 additions & 2 deletions source/core_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ static bool_ nextKeyValuePair( const char * buf,
size_t * valueLength )
{
bool_ ret = true;
size_t i, keyStart, valueStart = 0U;
size_t i, keyStart, valueStart = 0;

assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) );
assert( ( key != NULL ) && ( keyLength != NULL ) );
Expand Down Expand Up @@ -1248,7 +1248,7 @@ static JSONStatus_t search( char * buf,
size_t * outValueLength )
{
JSONStatus_t ret = JSONPartial;
size_t i = 0, key, keyLength, value, valueLength;
size_t i = 0, key, keyLength, value = 0, valueLength = 0;
Copy link

Choose a reason for hiding this comment

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

what abt key and keyLength?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no warnings for key and keyLength. I think it is better to enlist the compiler to tell me when I use an uninitialized variable, than to initialize everything and rob myself of that check. The only problem is when the compiler gets it wrong, as the Microsoft compiler does here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think that it's good practice to just initialize everything anyways as part of our style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not everything. I think the practice can do more harm than good in some cases.


assert( ( buf != NULL ) && ( queryKey != NULL ) );
assert( ( outValue != NULL ) && ( outValueLength != NULL ) );
Expand Down