-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
[3.x] Initialize class variables with default values #44125
Conversation
6392ef8
to
02463ad
Compare
8681e30
to
6e24d66
Compare
6e24d66
to
d2b40ca
Compare
@@ -43,6 +43,12 @@ | |||
Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : | |||
JointBullet() { | |||
|
|||
for (int i = 0; i < 3; i++) { |
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.
This has been fixed with a different code which is a bit cleaner on master:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) {
flags[i][j] = false;
}
}
Also, I'm wondering if memset
would be better in this case. I don't know if all compilers would optimize this loop properly.
That's a huge PR with a lot of surface for potential bugs. I'll try to review it soon but it takes time. To fix #35877, it would be better to make a dedicated PR with only that fix. |
d2b40ca
to
50fa21e
Compare
50fa21e
to
628b620
Compare
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.
@@ -980,6 +980,8 @@ ResourceInteractiveLoaderBinary::ResourceInteractiveLoaderBinary() : | |||
f(NULL), | |||
error(OK), | |||
stage(0) { | |||
ver_format = 0; | |||
importmd_ofs = 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 are some of these before the {
and some after it?
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.
Initializer list(before {) require to have all variables in same order as in class definition, so for me it was easier to write such code(in master initialization was moved from constructor)
Currently I don't have enough time to rebase such commits, so feel free to use them to create new PR. |
Part of #43636 for 3.x branch.
It should decrease number of Cppcheck errors from 791 to ~125(except buffers and some rendering things).
It should be really easy to check this commit, because it adds only to constructor values initializations(in opposite to similar commits to master branch when I moved a lot of things across code and also initialized structs members which was not shown in Cppcheck).