From: Sam Muhammed Date: Sun, 17 Oct 2021 23:26:41 +0000 (+0200) Subject: rust(lint): use is_null() instead of ptr::null() X-Git-Tag: suricata-7.0.0-beta1~1277 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23768c71814aa267672de772d43394727b3428a4;p=thirdparty%2Fsuricata.git rust(lint): use is_null() instead of ptr::null() Bug: #4594 --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index abe556c758..9518606cef 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -479,7 +479,7 @@ pub unsafe fn get_event_info( 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; } diff --git a/rust/src/conf.rs b/rust/src/conf.rs index e52e53a591..b3f996945c 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -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; } diff --git a/rust/src/jsonbuilder.rs b/rust/src/jsonbuilder.rs index 7f85692246..82636176a3 100644 --- a/rust/src/jsonbuilder.rs +++ b/rust/src/jsonbuilder.rs @@ -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); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 9fc781732f..a7399d9f51 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -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)] diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index cbd1fb1360..4df1f403fa 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -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);