]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
rust(lint): use is_null() instead of ptr::null()
authorSam Muhammed <ghostinthehive.vx@gmail.com>
Sun, 17 Oct 2021 23:26:41 +0000 (01:26 +0200)
committerVictor Julien <victor@inliniac.net>
Sun, 31 Oct 2021 13:54:44 +0000 (14:54 +0100)
Bug: #4594

rust/src/applayer.rs
rust/src/conf.rs
rust/src/jsonbuilder.rs
rust/src/lib.rs
rust/src/nfs/nfs.rs

index abe556c7587b0e348e9422368998a14757afcfe1..9518606cef7e3676d2a9f8c0fe64cc9336f506f8 100644 (file)
@@ -479,7 +479,7 @@ pub unsafe fn get_event_info<T: AppLayerEvent>(
     event_id: *mut std::os::raw::c_int,
     event_type: *mut core::AppLayerEventType,
 ) -> std::os::raw::c_int {
-    if event_name == std::ptr::null() {
+    if event_name.is_null() {
         return -1;
     }
 
index e52e53a59140b8adeec454afe523224bd5482934..b3f996945c06103059ef1867473e3fc30da5d9c4 100644 (file)
@@ -48,7 +48,7 @@ pub fn conf_get(key: &str) -> Option<&str> {
         }
     }
 
-    if vptr == ptr::null() {
+    if vptr.is_null() {
         return None;
     }
 
@@ -103,7 +103,7 @@ impl ConfNode {
             }
         }
 
-        if vptr == ptr::null() {
+        if vptr.is_null() {
             return None;
         }
 
index 7f8569224641a0acb9e716582adcf8208c270df9..82636176a3ce594295474497aca462bc0c9b7f85 100644 (file)
@@ -630,7 +630,7 @@ pub unsafe extern "C" fn jb_open_array(js: &mut JsonBuilder, key: *const c_char)
 pub unsafe extern "C" fn jb_set_string(
     js: &mut JsonBuilder, key: *const c_char, val: *const c_char,
 ) -> bool {
-    if val == std::ptr::null() {
+    if val.is_null() {
         return false;
     }
     if let Ok(key) = CStr::from_ptr(key).to_str() {
@@ -645,7 +645,7 @@ pub unsafe extern "C" fn jb_set_string(
 pub unsafe extern "C" fn jb_set_string_from_bytes(
     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() {
@@ -680,7 +680,7 @@ pub unsafe extern "C" fn jb_set_object(
 
 #[no_mangle]
 pub unsafe extern "C" fn jb_append_string(js: &mut JsonBuilder, val: *const c_char) -> bool {
-    if val == std::ptr::null() {
+    if val.is_null() {
         return false;
     }
     if let Ok(val) = CStr::from_ptr(val).to_str() {
@@ -693,7 +693,7 @@ pub unsafe extern "C" fn jb_append_string(js: &mut JsonBuilder, val: *const c_ch
 pub unsafe extern "C" fn jb_append_string_from_bytes(
     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);
index 9fc781732f645964613a9c052ffa63ccafb51fec..a7399d9f51a47f567447310deade3e7bbda4ad28 100644 (file)
@@ -41,7 +41,6 @@
 #![allow(clippy::for_loops_over_fallibles)]
 #![allow(clippy::needless_lifetimes)]
 #![allow(clippy::single_match)]
-#![allow(clippy::cmp_null)]
 #![allow(clippy::upper_case_acronyms)]
 #![allow(clippy::ptr_arg)]
 #![allow(clippy::new_without_default)]
index cbd1fb13604729a8eabf67bda278477b9a3deebc..4df1f403fa71571c79d3d68a7d9aacb6eed4ff3c 100644 (file)
@@ -1649,7 +1649,7 @@ pub unsafe extern "C" fn rs_nfs_state_get_event_info(event_name: *const std::os:
                                               event_type: *mut AppLayerEventType)
                                               -> std::os::raw::c_int
 {
-    if event_name == std::ptr::null() {
+    if event_name.is_null() {
         return -1;
     }
     let c_event_name: &CStr = CStr::from_ptr(event_name);