-
Notifications
You must be signed in to change notification settings - Fork 163
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
Make loaned messages const on the subscription side #992
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Nikolai Morin <[email protected]>
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 think this makes sense.
Can somebody help me understand why the Rpr__rcl__ubuntu_jammy_amd64 check is red? I'm not familiar with Jenkins, and in the console log it says "0 tests failed". |
It's because there are compiler warnings: https://build.ros2.org/job/Rpr__rcl__ubuntu_jammy_amd64/52/gcc/new/ |
Thanks. I'll get on it. |
Signed-off-by: Nikolai Morin <[email protected]>
Should I also do this change in the rmw layer? |
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 makes sense to me!
Yes, and after that it would be nice to cleanup the casts that will become unnecessary here. |
@nnmm there are some build failures related to the change. |
@ivanpauno I'm not sure how this can be tested, but it needs the changes to rclcpp as well. |
ah sorry, my bad. |
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.
Sorry, I know this has been sitting a long time. I just took a look and suggested a way to make this better if you are still interested in making this happen.
@@ -630,7 +630,8 @@ rcl_take_loaned_message( | |||
// Call rmw_take_with_info. | |||
bool taken = false; | |||
rmw_ret_t ret = rmw_take_loaned_message_with_info( | |||
subscription->impl->rmw_handle, loaned_message, &taken, message_info_local, allocation); | |||
subscription->impl->rmw_handle, (void **) loaned_message, &taken, message_info_local, |
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 seems to me that rather than doing this cast here, we should first change rmw_take_loaned_message_with_info
to take a const void ** loaned_message
. At that point, everything will be const and no casts will be needed.
Same goes below for rmw_return_loaned_message_from_subscription
.
It seems to me that it is an error for the receiver of a loaned message to modify it – other subscriptions could be reading the same message at the same time. Therefore, this PR makes the API stricter by handing out only const pointers.
I have also made corresponding changes in rclcpp, which I'll open a PR for as well and link here.