From: Philippe Antoine Date: Fri, 4 Nov 2022 10:13:07 +0000 (+0100) Subject: rust: fix cargo clippy --all-features X-Git-Tag: suricata-7.0.0-rc1~404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=286bd2a7ed7dc1bd18db40021142714ed371e5d4;p=thirdparty%2Fsuricata.git rust: fix cargo clippy --all-features --- diff --git a/rust/src/dns/detect.rs b/rust/src/dns/detect.rs index 53ed4c276c..9c96be392d 100644 --- a/rust/src/dns/detect.rs +++ b/rust/src/dns/detect.rs @@ -79,11 +79,7 @@ pub extern "C" fn rs_dns_opcode_match( return 0; }; - if match_opcode(detect, header_flags) { - 1 - } else { - 0 - } + match_opcode(detect, header_flags).into() } fn match_opcode(detect: &DetectDnsOpcode, flags: u16) -> bool { diff --git a/rust/src/filecontainer.rs b/rust/src/filecontainer.rs index b6eabd4c1e..bbe858409b 100644 --- a/rust/src/filecontainer.rs +++ b/rust/src/filecontainer.rs @@ -69,9 +69,6 @@ impl Default for FileContainer { } impl FileContainer { - pub fn default() -> FileContainer { - FileContainer { head:ptr::null_mut(), tail:ptr::null_mut() } - } pub fn free(&mut self) { SCLogDebug!("freeing self"); if let Some(c) = unsafe {SC} { diff --git a/rust/src/frames.rs b/rust/src/frames.rs index aa6bf4375f..d94a58a18f 100644 --- a/rust/src/frames.rs +++ b/rust/src/frames.rs @@ -65,7 +65,7 @@ impl Frame { stream_slice, offset as u32, frame_len, - if stream_slice.flags() & STREAM_TOSERVER != 0 { 0 } else { 1 }, + (stream_slice.flags() & STREAM_TOSERVER == 0).into(), frame_type, ) }; diff --git a/rust/src/smb/smb2_records.rs b/rust/src/smb/smb2_records.rs index a252a32447..ef2d9f7315 100644 --- a/rust/src/smb/smb2_records.rs +++ b/rust/src/smb/smb2_records.rs @@ -87,8 +87,8 @@ struct SmbFlags { fn parse_smb2_flags(i: &[u8]) -> IResult<&[u8], SmbFlags> { let (i, val) = le_u32(i)?; - let direction = if val & SMB2_FLAGS_SERVER_TO_REDIR != 0 { 1 } else { 0 }; - let async_command = if val & SMB2_FLAGS_ASYNC_COMMAND != 0 { 1 } else { 0 }; + let direction = u8::from(val & SMB2_FLAGS_SERVER_TO_REDIR != 0); + let async_command = u8::from(val & SMB2_FLAGS_ASYNC_COMMAND != 0); Ok((i, SmbFlags { direction, async_command,