diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 3c493a44da..523c62a68f 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -662,18 +662,16 @@ pub trait AppLayerFrameType { fn to_cstring(&self) -> *const std::os::raw::c_char; /// Converts a C string formatted name to a frame type ID. - extern "C" fn ffi_id_from_name(name: *const std::os::raw::c_char) -> i32 where Self: Sized { + unsafe extern "C" fn ffi_id_from_name(name: *const std::os::raw::c_char) -> i32 where Self: Sized { if name.is_null() { return -1; } - unsafe { - let frame_id = if let Ok(s) = std::ffi::CStr::from_ptr(name).to_str() { - Self::from_str(s).map(|t| t.as_u8() as i32).unwrap_or(-1) - } else { - -1 - }; - frame_id - } + let frame_id = if let Ok(s) = std::ffi::CStr::from_ptr(name).to_str() { + Self::from_str(s).map(|t| t.as_u8() as i32).unwrap_or(-1) + } else { + -1 + }; + frame_id } /// Converts a variant ID to an FFI safe name. diff --git a/rust/src/frames.rs b/rust/src/frames.rs index 3f1953d5d2..aa6bf4375f 100644 --- a/rust/src/frames.rs +++ b/rust/src/frames.rs @@ -49,6 +49,7 @@ impl std::fmt::Debug for Frame { } impl Frame { + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn new( flow: *const Flow, stream_slice: &StreamSlice, frame_start: &[u8], frame_len: i64, frame_type: u8, @@ -92,18 +93,21 @@ impl Frame { } } + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn set_len(&self, flow: *const Flow, len: i64) { unsafe { AppLayerFrameSetLengthById(flow, self.direction(), self.id, len); }; } + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn set_tx(&self, flow: *const Flow, tx_id: u64) { unsafe { AppLayerFrameSetTxIdById(flow, self.direction(), self.id, tx_id); }; } + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn add_event(&self, flow: *const Flow, event: u8) { unsafe { AppLayerFrameAddEventById(flow, self.direction(), self.id, event);