]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix cargo clippy --all-features
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 4 Nov 2022 10:13:07 +0000 (11:13 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 8 Nov 2022 04:44:02 +0000 (06:44 +0200)
rust/src/dns/detect.rs
rust/src/filecontainer.rs
rust/src/frames.rs
rust/src/smb/smb2_records.rs

index 53ed4c276cefc037a6a0aa8fdd83494e4bd0e533..9c96be392d379ad59af7c08679549fa2bdb3a45d 100644 (file)
@@ -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 {
index b6eabd4c1e4ceecd858c93d7f0e3c6bcd9256f95..bbe858409bacf96312df7645de780c5ee820c664 100644 (file)
@@ -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} {
index aa6bf4375ff47b01a133554f80236de85ea86e42..d94a58a18fca453e801978a22597ed41def78ee5 100644 (file)
@@ -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,
                 )
             };
index a252a32447df6aa71aad241eef56d5b2b0069969..ef2d9f731589d528442559f77291d27cacc0b6af 100644 (file)
@@ -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,