]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy ptr_arg warnings
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 8 Feb 2024 14:47:23 +0000 (15:47 +0100)
committerShivani Bhardwaj <shivanib134@gmail.com>
Fri, 9 Feb 2024 14:11:25 +0000 (19:41 +0530)
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
   --> src/dns/log.rs:371:29
    |
371 | pub fn dns_print_addr(addr: &Vec<u8>) -> std::string::String {
    |                             ^^^^^^^^ help: change this to: `&[u8]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

(cherry picked from commit 68b0052018079adc11ea1e35ab686c30716a8aad)

rust/src/dhcp/logger.rs
rust/src/dns/log.rs
rust/src/ike/ikev1.rs
rust/src/nfs/nfs.rs
rust/src/smb/log.rs

index b29e2158ef950c4e73f469dfebb3e71e7163f751..3c86b1b7c56760838048645a360ca36f48312939 100644 (file)
@@ -229,7 +229,7 @@ impl DHCPLogger {
     fn log_opt_dns_server(&self, js: &mut JsonBuilder, option: &DHCPOptGeneric) -> Result<(), JsonError> {
         js.open_array("dns_servers")?;
         for i in 0..(option.data.len() / 4) {
-            let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4].to_vec());
+            let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4]);
             js.append_string(&val)?;
         }
         js.close()?;
@@ -239,7 +239,7 @@ impl DHCPLogger {
     fn log_opt_routers(&self, js: &mut JsonBuilder, option: &DHCPOptGeneric) -> Result<(), JsonError> {
         js.open_array("routers")?;
         for i in 0..(option.data.len() / 4) {
-            let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4].to_vec());
+            let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4]);
             js.append_string(&val)?;
         }
         js.close()?;
index 5212b1a0da7ce39596f3d9e9b91eac99951286b4..86325d5f0735ae6b1d773fa5c3fc78c4b08015e0 100644 (file)
@@ -368,7 +368,7 @@ pub fn dns_rcode_string(flags: u16) -> String {
 }
 
 /// Format bytes as an IP address string.
-pub fn dns_print_addr(addr: &Vec<u8>) -> std::string::String {
+pub fn dns_print_addr(addr: &[u8]) -> std::string::String {
     if addr.len() == 4 {
         return format!("{}.{}.{}.{}", addr[0], addr[1], addr[2], addr[3]);
     } else if addr.len() == 16 {
index 1e79c293cdea2abec876fd0b2c4e553582124a5b..6f598f9806f6d31feee0f143855c3e2b5fb339fe 100644 (file)
@@ -53,7 +53,7 @@ impl Ikev1ParticipantData {
     }
 
     pub fn update(
-        &mut self, key_exchange: &str, nonce: &str, transforms: &Vec<Vec<SaAttribute>>,
+        &mut self, key_exchange: &str, nonce: &str, transforms: &[Vec<SaAttribute>],
     ) {
         self.key_exchange = key_exchange.to_string();
         self.nonce = nonce.to_string();
index dfb5e0e724454ccc4e6265f41b2cd8a2b9c7972b..4a1c3624ef35ada04e228edebbba80a569b93d0d 100644 (file)
@@ -497,7 +497,7 @@ impl NFSState {
     }
 
     // TODO maybe not enough users to justify a func
-    pub fn mark_response_tx_done(&mut self, xid: u32, rpc_status: u32, nfs_status: u32, resp_handle: &Vec<u8>)
+    pub fn mark_response_tx_done(&mut self, xid: u32, rpc_status: u32, nfs_status: u32, resp_handle: &[u8])
     {
         if let Some(mytx) = self.get_tx_by_xid(xid) {
             mytx.response_done = true;
index 84965749ba174e0e36f76bdad4cd70eb3dea0ad8..e242d02e486b2f1bf1e2045f4e2b3a2eb290e56d 100644 (file)
@@ -38,7 +38,7 @@ fn debug_add_progress(jsb: &mut JsonBuilder, tx: &SMBTransaction) -> Result<(),
 
 /// take in a file GUID (16 bytes) or FID (2 bytes). Also deal
 /// with our frankenFID (2 bytes + 4 user_id)
-fn fuid_to_string(fuid: &Vec<u8>) -> String {
+fn fuid_to_string(fuid: &[u8]) -> String {
     let fuid_len = fuid.len();
     if fuid_len == 16 {
         guid_to_string(fuid)
@@ -52,7 +52,7 @@ fn fuid_to_string(fuid: &Vec<u8>) -> String {
     }
 }
 
-fn guid_to_string(guid: &Vec<u8>) -> String {
+fn guid_to_string(guid: &[u8]) -> String {
     if guid.len() == 16 {
         let output = format!("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
                 guid[3],  guid[2],  guid[1],  guid[0],