]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy lint for null comparison
authorJason Ish <jason.ish@oisf.net>
Mon, 3 Oct 2022 22:20:06 +0000 (16:20 -0600)
committerVictor Julien <vjulien@oisf.net>
Tue, 4 Oct 2022 09:22:02 +0000 (11:22 +0200)
Use .is_null() instead of checking for equality against
std::ptr::null().

rust/src/applayer.rs
rust/src/jsonbuilder.rs

index 523c62a68f4abeee495f85c334577102e2791a80..bff17d7a8e03475ec1070bf04d493b6745be435f 100644 (file)
@@ -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);
         }
     }
index dc7236c42c97e593cac88fa73a1ddf1084acb73c..515a8be319ae7a2009a57243f419ae4027a68faf 100644 (file)
@@ -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);