From 2a42386c288d0ec4dd8edf69ea489d748e343e16 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 3 Oct 2022 16:20:06 -0600 Subject: [PATCH] rust: fix clippy lint for null comparison Use .is_null() instead of checking for equality against std::ptr::null(). --- rust/src/applayer.rs | 4 ++-- rust/src/jsonbuilder.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 523c62a68f..bff17d7a8e 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -134,10 +134,10 @@ impl Default for AppLayerTxData { impl Drop for AppLayerTxData { fn drop(&mut self) { - if self.de_state != std::ptr::null_mut() { + if !self.de_state.is_null() { core::sc_detect_engine_state_free(self.de_state); } - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } } diff --git a/rust/src/jsonbuilder.rs b/rust/src/jsonbuilder.rs index dc7236c42c..515a8be319 100644 --- a/rust/src/jsonbuilder.rs +++ b/rust/src/jsonbuilder.rs @@ -732,7 +732,7 @@ pub unsafe extern "C" fn jb_set_string_from_bytes( pub unsafe extern "C" fn jb_set_base64( js: &mut JsonBuilder, key: *const c_char, bytes: *const u8, len: u32, ) -> bool { - if bytes == std::ptr::null() || len == 0 { + if bytes.is_null() || len == 0 { return false; } if let Ok(key) = CStr::from_ptr(key).to_str() { @@ -746,7 +746,7 @@ pub unsafe extern "C" fn jb_set_base64( pub unsafe extern "C" fn jb_set_hex( js: &mut JsonBuilder, key: *const c_char, bytes: *const u8, len: u32, ) -> bool { - if bytes == std::ptr::null() || len == 0 { + if bytes.is_null() || len == 0 { return false; } if let Ok(key) = CStr::from_ptr(key).to_str() { @@ -805,7 +805,7 @@ pub unsafe extern "C" fn jb_append_string_from_bytes( pub unsafe extern "C" fn jb_append_base64( js: &mut JsonBuilder, bytes: *const u8, len: u32, ) -> bool { - if bytes == std::ptr::null() || len == 0 { + if bytes.is_null() || len == 0 { return false; } let val = std::slice::from_raw_parts(bytes, len as usize);