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

Always initialize variable change in PerformanceChange #7176

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

endjkv
Copy link
Contributor

@endjkv endjkv commented Jun 24, 2021

This PR initializes parent and footprint of variable change right after it is declared, in case they are not initialized when an exception is thrown. (When control reaches line 422)

@endjkv endjkv requested review from a team as code owners June 24, 2021 06:37
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 24, 2021

CLA Signed

The committers are authorized under a signed CLA.

@endjkv endjkv force-pushed the fix-uninit-var branch 2 times, most recently from 641f3db to bdc2289 Compare June 24, 2021 07:05
Comment on lines 405 to 406
change.footprint = 0;
change.parent = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Why not do all 4 members?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change.iv and change.sustained_latency are initialized on line 409/447.

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather be consistent and initialize everything early, one way is to add a constructor to the structure or use the initializer-list form {0} for the member definitions. Or just set the other two members = 0 here.

Copy link
Member

@theopolis theopolis left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

Comment on lines 405 to 406
change.footprint = 0;
change.parent = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather be consistent and initialize everything early, one way is to add a constructor to the structure or use the initializer-list form {0} for the member definitions. Or just set the other two members = 0 here.

@endjkv
Copy link
Contributor Author

endjkv commented Jun 30, 2021

I have changed the code to initialize them in the first place.

@endjkv endjkv requested a review from theopolis June 30, 2021 08:40
@directionless directionless changed the title Fix potential Uninitialization of variable 'change' Always initialization of variable 'change' Jun 30, 2021
@directionless directionless changed the title Always initialization of variable 'change' Always initialize variable 'change' Jun 30, 2021
@directionless directionless changed the title Always initialize variable 'change' Always initialize variable change Jun 30, 2021
@directionless directionless merged commit 98568fe into osquery:master Jun 30, 2021
@directionless directionless changed the title Always initialize variable change Always initialize variable change in PerformanceChange Jun 30, 2021
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.

None yet

3 participants