]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/clippy: fix lint: explicit_counter_loop
authorJason Ish <jason.ish@oisf.net>
Mon, 28 Nov 2022 22:24:58 +0000 (16:24 -0600)
committerVictor Julien <vjulien@oisf.net>
Tue, 6 Dec 2022 13:10:10 +0000 (14:10 +0100)
rust/src/dcerpc/dcerpc.rs
rust/src/lib.rs
rust/src/smb/dcerpc.rs
rust/src/smb/smb2_records.rs

index 90bee6d20af6c0be657058baaecf8550dbb44aee..5038e7b3c82f50ce3311b725ed226a97601e7de1 100644 (file)
@@ -728,10 +728,9 @@ impl DCERPCState {
         match parser::parse_dcerpc_bindack(input) {
             Ok((leftover_bytes, mut back)) => {
                 if let Some(ref mut bind) = self.bind {
-                    let mut uuid_internal_id = 0;
-                    for r in back.ctxitems.iter() {
+                    for (uuid_internal_id, r) in back.ctxitems.iter().enumerate() {
                         for mut uuid in bind.uuid_list.iter_mut() {
-                            if uuid.internal_id == uuid_internal_id {
+                            if uuid.internal_id == uuid_internal_id as u16 {
                                 uuid.result = r.ack_result;
                                 if uuid.result != 0 {
                                     break;
@@ -740,7 +739,6 @@ impl DCERPCState {
                                 SCLogDebug!("DCERPC BINDACK accepted UUID: {:?}", uuid);
                             }
                         }
-                        uuid_internal_id += 1;
                     }
                     self.bindack = Some(back);
                 }
index b814bf85a94a65529018e00932287ebde52e327d..133bf9fe28f29bd23427e0a2321feea27581d636 100644 (file)
@@ -31,7 +31,6 @@
 #![allow(clippy::collapsible_else_if)]
 #![allow(clippy::collapsible_if)]
 #![allow(clippy::derive_partial_eq_without_eq)]
-#![allow(clippy::explicit_counter_loop)]
 #![allow(clippy::field_reassign_with_default)]
 #![allow(clippy::manual_find)]
 #![allow(clippy::match_like_matches_macro)]
index 9e93232bf4d5405358d51c44d1e57d966a081db8..502b243052dd898e820ccbed9ac4b32f7b3365a2 100644 (file)
@@ -347,15 +347,13 @@ fn smb_dcerpc_response_bindack(
             };
             if found {
                 if let Some(ref mut ifaces) = state.dcerpc_ifaces {
-                    let mut i = 0;
-                    for r in bindackr.results {
+                    for (i, r) in bindackr.results.into_iter().enumerate() {
                         if i >= ifaces.len() {
                             // TODO set event: more acks that requests
                             break;
                         }
                         ifaces[i].ack_result = r.ack_result;
                         ifaces[i].acked = true;
-                        i += 1;
                     }
                 }
             }
index 3db46aab92598210e8735fe2ee466b972bf2e5f8..b19379883a77799adb4c8482d5ade2a9448b98ea 100644 (file)
@@ -599,14 +599,12 @@ pub fn parse_smb2_response_record(i: &[u8]) -> IResult<&[u8], Smb2Record> {
 
 fn smb_basic_search(d: &[u8]) -> usize {
     let needle = b"SMB";
-    let mut r = 0_usize;
     // this could be replaced by aho-corasick
     let iter = d.windows(needle.len());
-    for window in iter {
+    for (r, window) in iter.enumerate() {
         if window == needle {
             return r;
         }
-        r += 1;
     }
     return 0;
 }