-
Notifications
You must be signed in to change notification settings - Fork 14.8k
tools: add script to run clang-tidy to fix uninitialized variables #25994
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
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,179 @@ | |||
| #!/usr/bin/env python3 | |||
| """ | |||
| Fix uninitialized member variables using clang-tidy. | |||
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.
Perhaps
| Fix uninitialized member variables using clang-tidy. | |
| Initializes uninitialized member variables to 0, using clang-tidy. |
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'm going to leave the rest of the reviews to the developer team who will actually use this. It's a good idea though, and you might want to update the contribution section of the docs to point to this (and other) tools that are useful.
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.
it zero initializes primitives and default constructs classes
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.
Perhaps say that then. If you aren't sure that most developers will know why and when you want to do that, perhaps add a note on that too. This is why I suggested adding a link to the contribution section - so that people can find it and know when to use it. Otherwise they'll probably end up manually updating.
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 mostly opened this PR just to share the solution with Silvan and Mahima, since they just ran into a real bug caused by this. I'll probably leave this open until if/when we decide to fix all of our files.
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.
Fair enough. I think it might be interesting to add it to CI as a "test" to show uninitialized variables and offer to fix them - give people a chance to spot these cases over time rather than do it as a big-bang. Reasoning being that it's a lot less risky to fix small things than big things.
Dependencies
Note: The version number (14) may vary depending on your Ubuntu version. The script will detect the installed version and provide the correct symlink command if needed
Usage