]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy ling for needless borrows
authorJason Ish <jason.ish@oisf.net>
Mon, 3 Oct 2022 21:09:32 +0000 (15:09 -0600)
committerVictor Julien <vjulien@oisf.net>
Tue, 4 Oct 2022 09:22:02 +0000 (11:22 +0200)
Cleanup needless borrows found by clippy. This fix done automatically by
`cargo clippy --fix`.

12 files changed:
rust/src/dcerpc/detect.rs
rust/src/dcerpc/log.rs
rust/src/dns/detect.rs
rust/src/dns/dns.rs
rust/src/dns/log.rs
rust/src/http2/detect.rs
rust/src/quic/crypto.rs
rust/src/quic/cyu.rs
rust/src/quic/logger.rs
rust/src/smb/detect.rs
rust/src/smb/log.rs
rust/src/telnet/telnet.rs

index 59518b967651634f0054165b9b21f603b44eb319..662e2c20fd82e0e4a0ebdcebfe50b3911a55606c 100644 (file)
@@ -86,7 +86,7 @@ fn match_backuuid(
             }
 
             if let Some(x) = &if_data.du16 {
-                if !detect_match_uint(&x, uuidentry.version) {
+                if !detect_match_uint(x, uuidentry.version) {
                     SCLogDebug!("Interface version did not match");
                     ret &= 0;
                 }
index 317fab25596e5a554dc897344cfecf64b0c57a7f..c4e23d980d61e1c3f625ef1ad686dac68781bc2f 100644 (file)
@@ -123,14 +123,14 @@ fn log_dcerpc_header_udp(
 
 #[no_mangle]
 pub extern "C" fn rs_dcerpc_log_json_record_tcp(
-    state: &DCERPCState, tx: &DCERPCTransaction, mut jsb: &mut JsonBuilder,
+    state: &DCERPCState, tx: &DCERPCTransaction, jsb: &mut JsonBuilder,
 ) -> bool {
-    log_dcerpc_header_tcp(&mut jsb, state, tx).is_ok()
+    log_dcerpc_header_tcp(jsb, state, tx).is_ok()
 }
 
 #[no_mangle]
 pub extern "C" fn rs_dcerpc_log_json_record_udp(
-    state: &DCERPCUDPState, tx: &DCERPCTransaction, mut jsb: &mut JsonBuilder,
+    state: &DCERPCUDPState, tx: &DCERPCTransaction, jsb: &mut JsonBuilder,
 ) -> bool {
-    log_dcerpc_header_udp(&mut jsb, state, tx).is_ok()
+    log_dcerpc_header_udp(jsb, state, tx).is_ok()
 }
index 3172925676347a296c45d33ae07294735e0ac2c4..26cbb31d0913dace16287e51675603f611f96a51 100644 (file)
@@ -42,7 +42,7 @@ fn parse_opcode(opcode: &str) -> Result<DetectDnsOpcode, ()> {
                 negated = true;
             }
             _ => {
-                let code: u8 = (&opcode[i..]).parse().map_err(|_| ())?;
+                let code: u8 = opcode[i..].parse().map_err(|_| ())?;
                 return Ok(DetectDnsOpcode {
                     negate: negated,
                     opcode: code,
index cbb38824d2e0d8d02bda3bf5ce8230aee6534ee8..bd548a1544064ca3441c457556e61b0f35b627d2 100644 (file)
@@ -1474,7 +1474,7 @@ mod tests {
     #[test]
     fn test_dns_event_from_string() {
         let name = "malformed_data";
-        let event = DNSEvent::from_string(&name).unwrap();
+        let event = DNSEvent::from_string(name).unwrap();
         assert_eq!(event, DNSEvent::MalformedData);
         assert_eq!(event.to_cstring(), format!("{}\0", name));
     }
index 564e26a7afe6447fa296385bd38088c7aa41537d..fe3ff2f9d5b52e85ccefb94fe89f084a85affecf 100644 (file)
@@ -659,13 +659,13 @@ pub extern "C" fn rs_dns_log_json_query(tx: &mut DNSTransaction,
 
 #[no_mangle]
 pub extern "C" fn rs_dns_log_json_answer(tx: &mut DNSTransaction,
-                                         flags: u64, mut js: &mut JsonBuilder)
+                                         flags: u64, js: &mut JsonBuilder)
                                          -> bool
 {
     if let &Some(ref response) = &tx.response {
         for query in &response.queries {
             if dns_log_rrtype_enabled(query.rrtype, flags) {
-                return dns_log_json_answer(&mut js, response, flags as u64).is_ok();
+                return dns_log_json_answer(js, response, flags as u64).is_ok();
             }
         }
     }
index 72554a5277f62c1dfc8e0757d56198e0ed6c7c34..910756d5f05c036b6245e327675c4b54df412907 100644 (file)
@@ -256,7 +256,7 @@ fn http2_detect_settings_match(
                     return 1;
                 }
                 Some(x) => {
-                    if detect_match_uint(&x, set[i].value) {
+                    if detect_match_uint(x, set[i].value) {
                         return 1;
                     }
                 }
@@ -309,7 +309,7 @@ fn http2_detect_sizeupdate_match(
 ) -> std::os::raw::c_int {
     for block in blocks.iter() {
         if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate {
-            if detect_match_uint(&ctx, block.sizeupdate) {
+            if detect_match_uint(ctx, block.sizeupdate) {
                 return 1;
             }
         }
index 0b3ad5be419fb82335317c0f33d809462dc80172..22821728fc4c9c036b14351ddcbfc34e103103c4 100644 (file)
@@ -99,7 +99,7 @@ impl PacketKey {
         let (buffer, tag) = payload.split_at_mut(tag_pos);
         let taga = GenericArray::from_slice(tag);
         self.key
-            .decrypt_in_place_detached(GenericArray::from_slice(&nonce), header, buffer, &taga)
+            .decrypt_in_place_detached(GenericArray::from_slice(&nonce), header, buffer, taga)
             .map_err(|_| ())?;
         Ok(&payload[..tag_pos])
     }
index c3352d0d1c19cb0c1c799b6b6617e849ce1a186d..635ca2982ee63ba9f5b4a1d8bcd9edf3d73dd305 100644 (file)
@@ -62,7 +62,7 @@ impl Cyu {
                         let cyu_string = format!("{},{}", version, tags);
 
                         let mut hasher = Md5::new();
-                        hasher.update(&cyu_string.as_bytes());
+                        hasher.update(cyu_string.as_bytes());
                         let hash = hasher.finalize();
 
                         let cyu_hash = format!("{:x}", hash);
index c6df260fc193540d9174f49029cfdc5905e0af2d..77429ae118cd8247d1261623fc5a0d84585b8f27 100644 (file)
@@ -94,10 +94,10 @@ fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonEr
         js.set_string("version", String::from(tx.header.version).as_str())?;
 
         if let Some(sni) = &tx.sni {
-            js.set_string("sni", &String::from_utf8_lossy(&sni))?;
+            js.set_string("sni", &String::from_utf8_lossy(sni))?;
         }
         if let Some(ua) = &tx.ua {
-            js.set_string("ua", &String::from_utf8_lossy(&ua))?;
+            js.set_string("ua", &String::from_utf8_lossy(ua))?;
         }
     }
     if tx.cyu.len() > 0 {
@@ -117,7 +117,7 @@ fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonEr
         } else {
             js.open_object("ja3s")?;
         }
-        let hash = format!("{:x}", Md5::new().chain(&ja3).finalize());
+        let hash = format!("{:x}", Md5::new().chain(ja3).finalize());
         js.set_string("hash", &hash)?;
         js.set_string("string", ja3)?;
         js.close()?;
index ee6ccdb7a7601af9edef154520c5748941278588..4376a71749db5d7de40ed28c9a8435a3d6c6a310 100644 (file)
@@ -160,7 +160,7 @@ pub extern "C" fn rs_smb_tx_get_dce_iface(state: &mut SMBState,
 
         if i.acked && i.ack_result == 0 && i.uuid == if_uuid {
             if let Some(x) = &dce_data.du16 {
-                if detect_match_uint(&x, i.ver) {
+                if detect_match_uint(x, i.ver) {
                     return 1;
                 }
             } else {
index e5c5409196cb8566d2c1234549a19c6196c85615..4a2cb43b22c8e8db58fff7292444230563ef87c4 100644 (file)
@@ -100,7 +100,7 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
         (true, ntstatus) => {
             let status = smb_ntstatus_string(ntstatus);
             match status {
-                Some(x) => jsb.set_string("status", &x)?,
+                Some(x) => jsb.set_string("status", x)?,
                 None => {
                     let status_str = format!("{}", ntstatus);
                     jsb.set_string("status", &status_str)?
@@ -446,14 +446,14 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
 }
 
 #[no_mangle]
-pub extern "C" fn rs_smb_log_json_request(mut jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
+pub extern "C" fn rs_smb_log_json_request(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
 {
-    smb_common_header(&mut jsb, state, tx).is_ok()
+    smb_common_header(jsb, state, tx).is_ok()
 }
 
 #[no_mangle]
-pub extern "C" fn rs_smb_log_json_response(mut jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
+pub extern "C" fn rs_smb_log_json_response(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
 {
-    smb_common_header(&mut jsb, state, tx).is_ok()
+    smb_common_header(jsb, state, tx).is_ok()
 }
 
index 6fcb6b00ce49c0e1905293759b1cc077dfe8702a..f9998cff85fd13764b88075ca24928a20c826278 100644 (file)
@@ -231,7 +231,7 @@ impl TelnetState {
                                 self.state = TelnetProtocolState::PasswdRecv;
                             }
                             TelnetProtocolState::AuthOk => {
-                                let _message = std::str::from_utf8(&d);
+                                let _message = std::str::from_utf8(d);
                                 if let Ok(_message) = _message {
                                     SCLogDebug!("=> {}", _message);
                                 }
@@ -322,7 +322,7 @@ impl TelnetState {
                                 self.state = TelnetProtocolState::PasswdSent;
                             },
                             TelnetProtocolState::PasswdRecv => {
-                                if let Ok(message) = std::str::from_utf8(&d) {
+                                if let Ok(message) = std::str::from_utf8(d) {
                                     match message {
                                         "Login incorrect" => {
                                             SCLogDebug!("LOGIN FAILED");
@@ -339,7 +339,7 @@ impl TelnetState {
                                 }
                             },
                             TelnetProtocolState::AuthOk => {
-                                let _message = std::str::from_utf8(&d);
+                                let _message = std::str::from_utf8(d);
                                 if let Ok(_message) = _message {
                                     SCLogDebug!("<= {}", _message);
                                 }