]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix lint warnings about ptr_arg
authorKristina Jefferson <kristina.m.jefferson@gmail.com>
Thu, 13 Oct 2022 19:28:15 +0000 (14:28 -0500)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 09:20:10 +0000 (11:20 +0200)
Ticket: #4599

rust/src/dhcp/logger.rs
rust/src/ike/ikev1.rs
rust/src/lib.rs
rust/src/nfs/log.rs
rust/src/nfs/nfs.rs
rust/src/nfs/nfs4.rs
rust/src/smb/files.rs
rust/src/smb/smb.rs
rust/src/smb/smb1.rs
rust/src/smb/smb2.rs

index 4cd2580949c889cfad96d4e2c782fe8c77995ff6..36ac9aa4246f83c0e37a7f2170dfe916a583316d 100644 (file)
@@ -240,7 +240,7 @@ impl DHCPLogger {
 
 }
 
-fn format_addr_hex(input: &Vec<u8>) -> String {
+fn format_addr_hex(input: &[u8]) -> String {
     let parts: Vec<String> = input.iter()
         .map(|b| format!("{:02x}", b))
         .collect();
index 5d6c73fd0631e0697b28e01a44452ef4ab6df167..e8b58eb728741426ebd3325ebc3bdd75757a28b3 100644 (file)
@@ -53,10 +53,10 @@ impl Ikev1ParticipantData {
     }
 
     pub fn update(
-        &mut self, key_exchange: &String, nonce: &String, transforms: &Vec<Vec<SaAttribute>>,
+        &mut self, key_exchange: &str, nonce: &str, transforms: &Vec<Vec<SaAttribute>>,
     ) {
-        self.key_exchange = key_exchange.clone();
-        self.nonce = nonce.clone();
+        self.key_exchange = key_exchange.to_string();
+        self.nonce = nonce.to_string();
         if self.nb_transforms == 0 && !transforms.is_empty() {
             self.transform.extend(transforms[0].iter().cloned());
         }
index 85a741b2a11b72e166dda023018ae0e223d8fc01..42e2096b07ce2016ac5c900803a70ac477faa148 100644 (file)
@@ -47,7 +47,6 @@
 #![allow(clippy::never_loop)]
 #![allow(clippy::new_without_default)]
 #![allow(clippy::nonminimal_bool)]
-#![allow(clippy::ptr_arg)]
 #![allow(clippy::redundant_pattern_matching)]
 #![allow(clippy::result_unit_err)]
 #![allow(clippy::single_match)]
index f252cf2cb45c19ba836d44b4ff3fdd440801b7df..edcb21d833c21107c9a8953bb1abfe44e717c576 100644 (file)
@@ -81,7 +81,7 @@ fn nfs_handle2hex(bytes: &Vec<u8>) -> String {
     strings.join("")
 }
 */
-fn nfs_handle2crc(bytes: &Vec<u8>) -> u32 {
+fn nfs_handle2crc(bytes: &[u8]) -> u32 {
     let c = crc32::checksum_ieee(bytes);
     c
 }
index 8adaf3913d2217d999fc04e96b125c60e155e65b..7f75f4308f3e691a45ecc637dfc992e17cb88fe0 100644 (file)
@@ -286,7 +286,7 @@ impl NFSRequestXidMap {
 
 /// little wrapper around the FileTransferTracker::new_chunk method
 pub fn filetracker_newchunk(ft: &mut FileTransferTracker, files: &mut FileContainer,
-        flags: u16, name: &Vec<u8>, data: &[u8],
+        flags: u16, name: &[u8], data: &[u8],
         chunk_offset: u64, chunk_size: u32, fill_bytes: u8, is_last: bool, xid: &u32)
 {
     match unsafe {SURICATA_NFS_FILE_CONFIG} {
@@ -685,7 +685,7 @@ impl NFSState {
         }
     }
 
-    pub fn new_file_tx(&mut self, file_handle: &Vec<u8>, file_name: &Vec<u8>, direction: Direction)
+    pub fn new_file_tx(&mut self, file_handle: &[u8], file_name: &[u8], direction: Direction)
         -> &mut NFSTransaction
     {
         let mut tx = self.new_tx();
@@ -709,7 +709,7 @@ impl NFSState {
         return tx_ref.unwrap();
     }
 
-    pub fn get_file_tx_by_handle(&mut self, file_handle: &Vec<u8>, direction: Direction)
+    pub fn get_file_tx_by_handle(&mut self, file_handle: &[u8], direction: Direction)
         -> Option<&mut NFSTransaction>
     {
         let fh = file_handle.to_vec();
index 45081e4e8c15d437908d2e7d490b73137f486343..96ba21459e7d0c75912d062f2f487c1db49af516 100644 (file)
@@ -129,7 +129,7 @@ impl NFSState {
 
     fn new_tx_v4<'b>(
         &mut self, r: &RpcPacket<'b>, xidmap: &NFSRequestXidMap, procedure: u32,
-        _aux_opcodes: &Vec<u32>,
+        _aux_opcodes: &[u32],
     ) {
         let mut tx = self.new_tx();
         tx.xid = r.hdr.xid;
index e58f037e4b2b3864afc58c03928b1c6feb44b677..d0762e4c7b3e21e328dde28ca015fff449a65392 100644 (file)
@@ -52,7 +52,7 @@ impl SMBTransactionFile {
 
 /// little wrapper around the FileTransferTracker::new_chunk method
 pub fn filetracker_newchunk(ft: &mut FileTransferTracker, files: &mut FileContainer,
-        flags: u16, name: &Vec<u8>, data: &[u8],
+        flags: u16, name: &[u8], data: &[u8],
         chunk_offset: u64, chunk_size: u32, is_last: bool, xid: &u32)
 {
     match unsafe {SURICATA_SMB_FILE_CONFIG} {
@@ -64,7 +64,7 @@ pub fn filetracker_newchunk(ft: &mut FileTransferTracker, files: &mut FileContai
 }
 
 impl SMBState {
-    pub fn new_file_tx(&mut self, fuid: &Vec<u8>, file_name: &Vec<u8>, direction: Direction)
+    pub fn new_file_tx(&mut self, fuid: &[u8], file_name: &[u8], direction: Direction)
         -> &mut SMBTransaction
     {
         let mut tx = self.new_tx();
@@ -89,7 +89,7 @@ impl SMBState {
         return tx_ref.unwrap();
     }
 
-    pub fn get_file_tx_by_fuid(&mut self, fuid: &Vec<u8>, direction: Direction)
+    pub fn get_file_tx_by_fuid(&mut self, fuid: &[u8], direction: Direction)
         -> Option<&mut SMBTransaction>
     {
         let f = fuid.to_vec();
index 042fdf72d97bdaa6731a5f8088395050e8a18531..ac1c266ce85b91a63d85a78ce01afc80481b1bd3 100644 (file)
@@ -997,7 +997,7 @@ impl SMBState {
         return None;
     }
 
-    pub fn new_create_tx(&mut self, file_name: &Vec<u8>,
+    pub fn new_create_tx(&mut self, file_name: &[u8],
             disposition: u32, del: bool, dir: bool,
             hdr: SMBCommonHdr)
         -> &mut SMBTransaction
index ddeccf64d2a08a227480de0d8264ec3e777982d8..5b3bfc37df8b7af235f728602f84ffa008872665 100644 (file)
@@ -148,7 +148,7 @@ pub fn smb1_check_tx(cmd: u8) -> bool {
     }
 }
 
-fn smb1_close_file(state: &mut SMBState, fid: &Vec<u8>, direction: Direction)
+fn smb1_close_file(state: &mut SMBState, fid: &[u8], direction: Direction)
 {
     if let Some(tx) = state.get_file_tx_by_fuid(fid, direction) {
         SCLogDebug!("found tx {}", tx.id);
index e925747fc8e920996e1a20bebce5f00eb0c89f88..741f053b34ca664861d01c8496ef3525ca8643f1 100644 (file)
@@ -571,7 +571,7 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
                     state.ssn2vec_map.insert(name_key, cr.data.to_vec());
 
                     let tx_hdr = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
-                    let tx = state.new_create_tx(&cr.data.to_vec(),
+                    let tx = state.new_create_tx(cr.data,
                             cr.disposition, del, dir, tx_hdr);
                     tx.vercmd.set_smb2_cmd(r.command);
                     SCLogDebug!("TS CREATE TX {} created", tx.id);
@@ -590,7 +590,7 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
         SMB2_COMMAND_CLOSE => {
             match parse_smb2_request_close(r.data) {
                 Ok((_, cd)) => {
-                    let found_ts = match state.get_file_tx_by_fuid(&cd.guid.to_vec(), Direction::ToServer) {
+                    let found_ts = match state.get_file_tx_by_fuid(cd.guid, Direction::ToServer) {
                         Some(tx) => {
                             if !tx.request_done {
                                 if let Some(SMBTransactionTypeData::FILE(ref mut tdf)) = tx.type_data {
@@ -605,7 +605,7 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
                         },
                         None => { false },
                     };
-                    let found_tc = match state.get_file_tx_by_fuid(&cd.guid.to_vec(), Direction::ToClient) {
+                    let found_tc = match state.get_file_tx_by_fuid(cd.guid, Direction::ToClient) {
                         Some(tx) => {
                             if !tx.request_done {
                                 if let Some(SMBTransactionTypeData::FILE(ref mut tdf)) = tx.type_data {