Skip to content

Commit a351772

Browse files
authored
Call .ok() immediately after rcl function call (#211)
1 parent a37705c commit a351772

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

rclrs/src/node/publisher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ where
132132
pub fn publish<'a, M: MessageCow<'a, T>>(&self, message: M) -> Result<(), RclrsError> {
133133
let rmw_message = T::into_rmw_message(message.into_cow());
134134
let rcl_publisher = &mut *self.rcl_publisher_mtx.lock();
135-
let ret = unsafe {
135+
unsafe {
136136
// SAFETY: The message type is guaranteed to match the publisher type by the type system.
137137
// The message does not need to be valid beyond the duration of this function call.
138138
// The third argument is explictly allowed to be NULL.
@@ -141,8 +141,8 @@ where
141141
rmw_message.as_ref() as *const <T as Message>::RmwMsg as *mut _,
142142
std::ptr::null_mut(),
143143
)
144-
};
145-
ret.ok()
144+
.ok()
145+
}
146146
}
147147
}
148148

rclrs/src/node/subscription.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ where
143143
/// Fetches a new message.
144144
///
145145
/// When there is no new message, this will return a
146-
/// [`SubscriptionTakeFailed`][1]..
146+
/// [`SubscriptionTakeFailed`][1].
147147
///
148148
/// [1]: crate::RclrsError
149149
//
@@ -165,7 +165,7 @@ where
165165
pub fn take(&self) -> Result<T, RclrsError> {
166166
let mut rmw_message = <T as Message>::RmwMsg::default();
167167
let rcl_subscription = &mut *self.handle.lock();
168-
let ret = unsafe {
168+
unsafe {
169169
// SAFETY: The first two pointers are valid/initialized, and do not need to be valid
170170
// beyond the function call.
171171
// The latter two pointers are explicitly allowed to be NULL.
@@ -175,8 +175,8 @@ where
175175
std::ptr::null_mut(),
176176
std::ptr::null_mut(),
177177
)
178+
.ok()?
178179
};
179-
ret.ok()?;
180180
Ok(T::from_rmw_message(rmw_message))
181181
}
182182
}

0 commit comments

Comments
 (0)