Skip to content

Call .ok() immediately after rcl function call #211

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

Merged
merged 1 commit into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rclrs/src/node/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
pub fn publish<'a, M: MessageCow<'a, T>>(&self, message: M) -> Result<(), RclrsError> {
let rmw_message = T::into_rmw_message(message.into_cow());
let rcl_publisher = &mut *self.rcl_publisher_mtx.lock();
let ret = unsafe {
unsafe {
// SAFETY: The message type is guaranteed to match the publisher type by the type system.
// The message does not need to be valid beyond the duration of this function call.
// The third argument is explictly allowed to be NULL.
Expand All @@ -141,8 +141,8 @@ where
rmw_message.as_ref() as *const <T as Message>::RmwMsg as *mut _,
std::ptr::null_mut(),
)
};
ret.ok()
.ok()
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/node/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
/// Fetches a new message.
///
/// When there is no new message, this will return a
/// [`SubscriptionTakeFailed`][1]..
/// [`SubscriptionTakeFailed`][1].
///
/// [1]: crate::RclrsError
//
Expand All @@ -165,7 +165,7 @@ where
pub fn take(&self) -> Result<T, RclrsError> {
let mut rmw_message = <T as Message>::RmwMsg::default();
let rcl_subscription = &mut *self.handle.lock();
let ret = unsafe {
unsafe {
// SAFETY: The first two pointers are valid/initialized, and do not need to be valid
// beyond the function call.
// The latter two pointers are explicitly allowed to be NULL.
Expand All @@ -175,8 +175,8 @@ where
std::ptr::null_mut(),
std::ptr::null_mut(),
)
.ok()?
};
ret.ok()?;
Ok(T::from_rmw_message(rmw_message))
}
}
Expand Down