]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/smb: fix clippy nightly warning 10691/head 10693/head
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 21 Mar 2024 15:15:53 +0000 (16:15 +0100)
committerPhilippe Antoine <pantoine@oisf.net>
Thu, 21 Mar 2024 15:15:53 +0000 (16:15 +0100)
error: unnecessary use of `to_vec`
    --> src/smb/smb.rs:1048:62
     |
1048 |         let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
     |                                                              ^^^^^^^^^^^^^^ help: replace it with: `guid`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
     = note: `#[deny(clippy::unnecessary_to_owned)]` implied by `#[deny(warnings)]`

And also other uses of to_vec() on already Vec

rust/src/dhcp/logger.rs
rust/src/smb/smb.rs
rust/src/smb/smb1.rs

index 3c86b1b7c56760838048645a360ca36f48312939..a9d8d983b6cb49186a106742207ffbb49b1f2bbb 100644 (file)
@@ -89,7 +89,7 @@ impl DHCPLogger {
         
         js.set_uint("id", header.txid as u64)?;
         js.set_string("client_mac",
-                      &format_addr_hex(&header.clienthw.to_vec()))?;
+                      &format_addr_hex(&header.clienthw))?;
         js.set_string("assigned_ip", &dns_print_addr(&header.yourip))?;
 
         if self.extended {
index a3462174634950f2269be45d7ed56189de033056..4f777d6846710ea2ab95a8dffb39d1bcd25e6aad 100644 (file)
@@ -1045,7 +1045,7 @@ impl SMBState {
 
     pub fn get_service_for_guid(&self, guid: &[u8]) -> (&'static str, bool)
     {
-        let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
+        let (name, is_dcerpc) = match self.guid2name_map.get(guid) {
             Some(n) => {
                 let mut s = n.as_slice();
                 // skip leading \ if we have it
index a353c5539ccd30eb5c4aff011a20da64169de363..ce1bb4b21297ac2d018d80ba6dac2a6cfb2bd2c3 100644 (file)
@@ -482,7 +482,7 @@ fn smb1_request_record_one(state: &mut SMBState, r: &SmbRecord, command: u8, and
                     state.ssn2vec_map.insert(name_key, name_val);
 
                     let tx_hdr = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
-                    let tx = state.new_create_tx(&cr.file_name.to_vec(),
+                    let tx = state.new_create_tx(&cr.file_name,
                             cr.disposition, del, dir, tx_hdr);
                     tx.vercmd.set_smb1_cmd(command);
                     SCLogDebug!("TS CREATE TX {} created", tx.id);