]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/clippy: fix lint: match_ref_pats
authorJason Ish <jason.ish@oisf.net>
Mon, 28 Nov 2022 21:32:28 +0000 (15:32 -0600)
committerVictor Julien <vjulien@oisf.net>
Tue, 6 Dec 2022 13:10:10 +0000 (14:10 +0100)
rust/src/dhcp/logger.rs
rust/src/lib.rs
rust/src/nfs/nfs4.rs
rust/src/smb/log.rs

index c64698a6fe17271e6b066de4482221261f4a6534..f82d9f2c29b1614da7afab88b54d5e7bb7a45319 100644 (file)
@@ -104,12 +104,12 @@ impl DHCPLogger {
         
         for option in options {
             let code = option.code;
-            match &option.option {
-                &DHCPOptionWrapper::ClientId(ref clientid) => {
+            match option.option {
+                DHCPOptionWrapper::ClientId(ref clientid) => {
                     js.set_string("client_id",
                                   &format_addr_hex(&clientid.data))?;
                 }
-                &DHCPOptionWrapper::TimeValue(ref time_value) => {
+                DHCPOptionWrapper::TimeValue(ref time_value) => {
                     match code {
                         DHCP_OPT_ADDRESS_TIME => {
                             if self.extended {
@@ -130,7 +130,7 @@ impl DHCPLogger {
                         _ => {}
                     }
                 }
-                &DHCPOptionWrapper::Generic(ref option) => {
+                DHCPOptionWrapper::Generic(ref option) => {
                     match code {
                         DHCP_OPT_SUBNET_MASK => {
                             if self.extended {
index c7ccdf7e4c03d26f2c28c6ac640396d6ee467184..c4742d1203e923742428b72f01f0fc0aaa88efbb 100644 (file)
@@ -37,7 +37,6 @@
 #![allow(clippy::for_loops_over_fallibles)]
 #![allow(clippy::manual_find)]
 #![allow(clippy::match_like_matches_macro)]
-#![allow(clippy::match_ref_pats)]
 #![allow(clippy::module_inception)]
 #![allow(clippy::needless_range_loop)]
 #![allow(clippy::never_loop)]
index da618e5ffad1afc7d3c07e67d0c2043c3bf6b2d8..7661221bbaa3f7c1bd53a630426c3574748cb327 100644 (file)
@@ -171,12 +171,12 @@ impl NFSState {
 
         for c in &cr.commands {
             SCLogDebug!("c {:?}", c);
-            match c {
-                &Nfs4RequestContent::PutFH(ref rd) => {
+            match *c {
+                Nfs4RequestContent::PutFH(ref rd) => {
                     last_putfh = Some(rd.value);
                     aux_opcodes.push(NFSPROC4_PUTFH);
                 }
-                &Nfs4RequestContent::Read(ref rd) => {
+                Nfs4RequestContent::Read(ref rd) => {
                     SCLogDebug!("READv4: {:?}", rd);
                     if let Some(fh) = last_putfh {
                         xidmap.chunk_offset = rd.offset;
@@ -184,33 +184,33 @@ impl NFSState {
                         self.xidmap_handle2name(xidmap);
                     }
                 }
-                &Nfs4RequestContent::Open(ref rd) => {
+                Nfs4RequestContent::Open(ref rd) => {
                     SCLogDebug!("OPENv4: {}", String::from_utf8_lossy(rd.filename));
                     xidmap.file_name = rd.filename.to_vec();
                 }
-                &Nfs4RequestContent::Lookup(ref rd) => {
+                Nfs4RequestContent::Lookup(ref rd) => {
                     SCLogDebug!("LOOKUPv4: {}", String::from_utf8_lossy(rd.filename));
                     xidmap.file_name = rd.filename.to_vec();
                 }
-                &Nfs4RequestContent::Write(ref rd) => {
+                Nfs4RequestContent::Write(ref rd) => {
                     SCLogDebug!("WRITEv4: {:?}", rd);
                     if let Some(fh) = last_putfh {
                         self.write_v4(r, rd, fh);
                     }
                 }
-                &Nfs4RequestContent::Commit => {
+                Nfs4RequestContent::Commit => {
                     SCLogDebug!("COMMITv4");
                     if let Some(fh) = last_putfh {
                         self.commit_v4(r, fh);
                     }
                 }
-                &Nfs4RequestContent::Close(ref _rd) => {
+                Nfs4RequestContent::Close(ref _rd) => {
                     SCLogDebug!("CLOSEv4: {:?}", _rd);
                     if let Some(fh) = last_putfh {
                         self.close_v4(r, fh);
                     }
                 }
-                &Nfs4RequestContent::Create(ref rd) => {
+                Nfs4RequestContent::Create(ref rd) => {
                     SCLogDebug!("CREATEv4: {:?}", rd);
                     if let Some(fh) = last_putfh {
                         xidmap.file_handle = fh.to_vec();
@@ -218,12 +218,12 @@ impl NFSState {
                     xidmap.file_name = rd.filename.to_vec();
                     main_opcode = NFSPROC4_CREATE;
                 }
-                &Nfs4RequestContent::Remove(rd) => {
+                Nfs4RequestContent::Remove(rd) => {
                     SCLogDebug!("REMOVEv4: {:?}", rd);
                     xidmap.file_name = rd.to_vec();
                     main_opcode = NFSPROC4_REMOVE;
                 }
-                &Nfs4RequestContent::SetClientId(ref _rd) => {
+                Nfs4RequestContent::SetClientId(ref _rd) => {
                     SCLogDebug!(
                         "SETCLIENTIDv4: client id {} r_netid {} r_addr {}",
                         String::from_utf8_lossy(_rd.client_id),
@@ -231,7 +231,7 @@ impl NFSState {
                         String::from_utf8_lossy(_rd.r_addr)
                     );
                 }
-                &_ => {}
+                _ => {}
             }
         }
 
@@ -319,70 +319,62 @@ impl NFSState {
 
         for c in &cr.commands {
             SCLogDebug!("c {:?}", c);
-            match c {
-                &Nfs4ResponseContent::ReadDir(_s, ref rd) => {
-                    if let &Some(ref rd) = rd {
-                        SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
-
-                        for d in &rd.listing {
-                            if let &Some(ref _d) = d {
-                                SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(_d.name));
-                            }
+            match *c {
+                Nfs4ResponseContent::ReadDir(_s, Some(ref rd)) => {
+                    SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
+                    
+                    for d in &rd.listing {
+                        if let &Some(ref _d) = d {
+                            SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(_d.name));
                         }
                     }
                 }
-                &Nfs4ResponseContent::Remove(s) => {
+                Nfs4ResponseContent::Remove(s) => {
                     SCLogDebug!("REMOVE4: status {}", s);
                     main_opcode_status = s;
                     main_opcode_status_set = true;
                 }
-                &Nfs4ResponseContent::Create(s) => {
+                Nfs4ResponseContent::Create(s) => {
                     SCLogDebug!("CREATE4: status {}", s);
                     main_opcode_status = s;
                     main_opcode_status_set = true;
                 }
-                &Nfs4ResponseContent::Read(s, ref rd) => {
-                    if let &Some(ref rd) = rd {
-                        SCLogDebug!(
-                            "READ4: xidmap {:?} status {} data {}",
-                            xidmap,
-                            s,
-                            rd.data.len()
-                        );
-                        // convert record to generic read reply
-                        let reply = NfsReplyRead {
-                            status: s,
-                            attr_follows: 0,
-                            attr_blob: &[],
-                            count: rd.count,
-                            eof: rd.eof,
-                            data_len: rd.data.len() as u32,
-                            data: rd.data,
-                        };
-                        self.process_read_record(r, &reply, Some(xidmap));
-                    }
+                Nfs4ResponseContent::Read(s, Some(ref rd)) => {
+                    SCLogDebug!(
+                        "READ4: xidmap {:?} status {} data {}",
+                        xidmap,
+                        s,
+                        rd.data.len()
+                    );
+                    // convert record to generic read reply
+                    let reply = NfsReplyRead {
+                        status: s,
+                        attr_follows: 0,
+                        attr_blob: &[],
+                        count: rd.count,
+                        eof: rd.eof,
+                        data_len: rd.data.len() as u32,
+                        data: rd.data,
+                    };
+                    self.process_read_record(r, &reply, Some(xidmap));
                 }
-                &Nfs4ResponseContent::Open(_s, ref rd) => {
-                    if let &Some(ref _rd) = rd {
-                        SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
-                        insert_filename_with_getfh = true;
-                    }
+                Nfs4ResponseContent::Open(_s, Some(ref _rd)) => {
+                    SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
+                    insert_filename_with_getfh = true;
                 }
-                &Nfs4ResponseContent::GetFH(_s, ref rd) => {
-                    if let &Some(ref rd) = rd {
-                        if insert_filename_with_getfh {
-                            self.namemap
-                                .insert(rd.value.to_vec(), xidmap.file_name.to_vec());
-                        }
+                Nfs4ResponseContent::GetFH(_s, Some(ref rd)) => {
+                    if insert_filename_with_getfh {
+                        self.namemap
+                            .insert(rd.value.to_vec(), xidmap.file_name.to_vec());
                     }
                 }
-                &Nfs4ResponseContent::PutRootFH(s) => {
+                Nfs4ResponseContent::PutRootFH(s) => {
                     if s == NFS4_OK && xidmap.file_name.is_empty() {
                         xidmap.file_name = b"<mount_root>".to_vec();
                         SCLogDebug!("filename {:?}", xidmap.file_name);
                     }
                 }
-                &_ => {}
+                _ => {}
             }
         }
 
index aaadf9899dc0dd190d6534a41a4ab87dc87e6b8e..b13d56cc9d4ae1cf45ebfc97d665f5f59069802f 100644 (file)
@@ -73,9 +73,9 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
         let dialect = &smb2_dialect_string(state.dialect);
         jsb.set_string("dialect", dialect)?;
     } else {
-        let dialect = match &state.dialect_vec {
-            &Some(ref d) => str::from_utf8(d).unwrap_or("invalid"),
-            &None        => "unknown",
+        let dialect = match state.dialect_vec {
+            Some(ref d) => str::from_utf8(d).unwrap_or("invalid"),
+            None        => "unknown",
         };
         jsb.set_string("dialect", dialect)?;
     }