]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy lints for clippy::collapsible_if
authorJason Ish <jason.ish@oisf.net>
Wed, 5 Oct 2022 15:00:21 +0000 (09:00 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 09:20:09 +0000 (11:20 +0200)
rust/src/dcerpc/dcerpc_udp.rs
rust/src/http2/detect.rs
rust/src/ike/ikev2.rs
rust/src/smb/smb.rs
rust/src/smb/smb1.rs
rust/src/smb/smb2.rs

index ea82074653a81fbe8a15a0bcf58163836cbe72ed..85618ac200d0e7a3b2fd31591a476d8b4f066c97 100644 (file)
@@ -128,12 +128,9 @@ impl DCERPCUDPState {
 
     fn find_incomplete_tx(&mut self, hdr: &DCERPCHdrUdp) -> Option<&mut DCERPCTransaction> {
         for tx in &mut self.transactions {
-            if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid {
-                if (hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) ||
-                   (hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done) {
-                    SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
-                    return Some(tx);
-                }
+            if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid && ((hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) || (hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done)) {
+                SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
+                return Some(tx);
             }
         }
         None
index 9a3a6a57a22d48fe4a4b50682a8fa1b103f89881..9c233cd4dcf7dd46dfbacd9997477eb68c98ef40 100644 (file)
@@ -308,10 +308,8 @@ fn http2_detect_sizeupdate_match(
     blocks: &[parser::HTTP2FrameHeaderBlock], ctx: &DetectUintData<u64>,
 ) -> std::os::raw::c_int {
     for block in blocks.iter() {
-        if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate {
-            if detect_match_uint(ctx, block.sizeupdate) {
-                return 1;
-            }
+        if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate && detect_match_uint(ctx, block.sizeupdate) {
+            return 1;
         }
     }
     return 0;
index 37004780a4af093b44fa9b3f743e41924083c6ab..cd2e5518122491c830a3e1f5a9152bdac45eee3a 100644 (file)
@@ -278,14 +278,12 @@ fn add_proposals(
             IkeV2Transform::Auth(IkeTransformAuthType::NONE) => false,
             IkeV2Transform::Auth(_) => true,
             _ => false,
-        }) {
-            if !transforms.iter().any(|x| match *x {
+        }) && !transforms.iter().any(|x| match *x {
                 IkeV2Transform::Encryption(ref enc) => enc.is_aead(),
                 _ => false,
             }) {
-                SCLogDebug!("No integrity transform found");
-                tx.set_event(IkeEvent::WeakCryptoNoAuth);
-            }
+            SCLogDebug!("No integrity transform found");
+            tx.set_event(IkeEvent::WeakCryptoNoAuth);
         }
         // Finally
         if direction == Direction::ToClient {
index 4ab807c46d1ee9782d1366093dffcf29b9a81e47..a7c9db9e39dcd327d58133f21b03e6b130c5a63d 100644 (file)
@@ -2086,10 +2086,8 @@ fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, be
 
 fn smb_probe_tcp(flags: u8, slice: &[u8], rdir: *mut u8, begins: bool) -> AppProto
 {
-    if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM {
-        if smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 {
-            unsafe { return ALPROTO_SMB; }
-        }
+    if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM && smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 {
+        unsafe { return ALPROTO_SMB; }
     }
     match parse_nbss_record_partial(slice) {
         Ok((_, ref hdr)) => {
index ec24d7e1c0ae4735f5f975da9dfb69cf1992f427..ddeccf64d2a08a227480de0d8264ec3e777982d8 100644 (file)
@@ -570,15 +570,13 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
             false
         },
     };
-    if !have_tx {
-        if smb1_create_new_tx(command) {
-            let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
-            let tx = state.new_generic_tx(1, command as u16, tx_key);
-            SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command));
-            tx.set_events(events);
-            if no_response_expected {
-                tx.response_done = true;
-            }
+    if !have_tx && smb1_create_new_tx(command) {
+        let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
+        let tx = state.new_generic_tx(1, command as u16, tx_key);
+        SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command));
+        tx.set_events(events);
+        if no_response_expected {
+            tx.response_done = true;
         }
     }
 }
index 96f169ccbd126fca15851c269f4c95ceab268f7c..e925747fc8e920996e1a20bebce5f00eb0c89f88 100644 (file)
@@ -635,14 +635,12 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
         },
     };
     /* if we don't have a tx, create it here (maybe) */
-    if !have_tx {
-        if smb2_create_new_tx(r.command) {
-            let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
-            let tx = state.new_generic_tx(2, r.command, tx_key);
-            SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}",
-                    tx.id, r.command, r.session_id, r.tree_id, r.message_id);
-            tx.set_events(events);
-        }
+    if !have_tx && smb2_create_new_tx(r.command) {
+        let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
+        let tx = state.new_generic_tx(2, r.command, tx_key);
+        SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}",
+                tx.id, r.command, r.session_id, r.tree_id, r.message_id);
+        tx.set_events(events);
     }
 }