-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
|
641f3db
to
bdc2289
Compare
osquery/core/watcher.cpp
Outdated
change.footprint = 0; | ||
change.parent = 0; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
osquery/core/watcher.cpp
Outdated
change.footprint = 0; | ||
change.parent = 0; |
There was a problem hiding this comment.
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.
I have changed the code to initialize them in the first place. |
change
change
change
in PerformanceChange
This PR initializes
parent
andfootprint
of variablechange
right after it is declared, in case they are not initialized when an exception is thrown. (When control reaches line 422)