rust(lint): use is_null() instead of ptr::null()

Bug: #4594
pull/6552/head
Sam Muhammed 3 years ago committed by Victor Julien
parent da0a976e23
commit 23768c7181

@ -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;
}

@ -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;
}

@ -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);

@ -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)]

@ -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);

Loading…
Cancel
Save