-
Notifications
You must be signed in to change notification settings - Fork 130
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
Group message initializations by their appropriate checks #350
Conversation
This patch will conflict with #334. Please rebase / update this patch once the referenced PR has been merged. |
@dirk-thomas you got it! |
5ef642d
to
b1099c7
Compare
@dirk-thomas rebased & ready |
The patch seems to change the initialization order of the members, no? If yes, the members should be initialized in the order they are defined in. |
@dirk-thomas I don't think the order is changed (at least it shouldn't be). The goal here was to collapse the Here's a diff of the generated ]--- /g/primitives_static__struct.hpp_old 2019-03-13 12:31:14.580896800 -0400
+++ /g/primitives_static__struct.hpp 2019-03-13 12:32:23.262555200 -0400
@@ -48,49 +48,17 @@
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->bool_value = false;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->byte_value = 0;
this->char_value = 0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->float32_value = 0.0f;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->float64_value = 0.0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int8_value = 0;
this->uint8_value = 0;
this->int16_value = 0;
this->uint16_value = 0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int32_value = 0l;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->uint32_value = 0ul;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int64_value = 0ll;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->uint64_value = 0ull;
}
}
@@ -102,49 +70,17 @@
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->bool_value = false;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->byte_value = 0;
this->char_value = 0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->float32_value = 0.0f;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->float64_value = 0.0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int8_value = 0;
this->uint8_value = 0;
this->int16_value = 0;
this->uint16_value = 0;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int32_value = 0l;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->uint32_value = 0ul;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->int64_value = 0ll;
- }
- if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
- rosidl_generator_cpp::MessageInitialization::ZERO == _init)
- {
this->uint64_value = 0ull;
}
} Since this is strictly removing, it does not appear to permute the order (although this is a rather trivial case). The two originals are in a gist here. Let me know if you want to see any specific files. |
Can you please try it with a message file which has a mixture of fields - some with default values, some without - and share the diff for that. Thanks. |
Do you have a particular file in mind? |
No, not really. I would just expect that case to have a changed order. |
@dirk-thomas yeah, that makes sense. I just ran I looking at I'll move this back to in progress and work on it a little later. Sorry for the noise. |
46ed046
to
f925ee7
Compare
a43c67b
to
026167b
Compare
Okay, @dirk-thomas I got all the tests passing and updated the gist I linked to. Here's the diff for Could you run CI on this for me please? Apparently I can't do that anymore (unless the way to do it has changed). |
@mikaelarguedas you might also be a good person to look at this. Let me know if this needs any changes. Attention was drawn to this by PVS studio, if anyone was curious. |
bcae336
to
79fb77e
Compare
@dirk-thomas thanks for the review -- ready for another round! |
@(line) | ||
@[ end for]@ | ||
@[ end for]@ |
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.
Indentation of this block is off.
Signed-off-by: Hunter L. Allen <[email protected]>
Signed-off-by: Hunter L. Allen <[email protected]>
Signed-off-by: Hunter L. Allen <[email protected]>
Signed-off-by: Hunter L. Allen <[email protected]>
Signed-off-by: Hunter L. Allen <[email protected]>
3a8be19
to
d94e7c1
Compare
Okay, I'm decently sure I've got the indentation in there correctly now (sorry about that -- can be a bit confusing). As for the CI problems, those are seemingly unrelated, as far as I can tell. I rebased on top of the current @dirk-thomas What should I look at in order to rule out these failures? |
Thanks for the patch and for iterating on it. |
@dirk-thomas my pleasure, as always. 👍 |
I was going through message generation, and found that there were several redundant checks on message initialization.
This clears it up.
This change is