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

Address spurious Microsoft compiler warnings #49

merged 4 commits into from
Nov 2, 2020

Conversation

dan4thewin
Copy link
Contributor

Different compilers seem to have different capacities to recognize use of an uninitialized variable. The GNU toolchain gives no warnings, but the Microsoft compiler does. Upon inspection, the variables are only ever used after being set, but it is simpler to provide throwaway defaults than to mute the warning.

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

@sarenameas sarenameas merged commit 3fcea77 into FreeRTOS:master Nov 2, 2020
@dan4thewin dan4thewin deleted the mscompiler-warnings branch November 4, 2020 02:11
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.

6 participants