]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy warnings for match as if statements
authorJason Ish <jason.ish@oisf.net>
Tue, 6 Aug 2024 16:10:43 +0000 (10:10 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 7 Aug 2024 06:31:26 +0000 (08:31 +0200)
Fix done by clippy --fix.

rust/src/dcerpc/dcerpc_udp.rs
rust/src/detect/uint.rs
rust/src/http2/parser.rs
rust/src/ssh/parser.rs

index 7c83bbc04a58ddcb624f3c01840f2cd97f712ff0..05d49973c864d461794e750ba5058600a9b15cd9 100644 (file)
@@ -410,11 +410,8 @@ mod tests {
             0x1c, 0x7d, 0xcf, 0x11,
         ];
 
-        match parser::parse_dcerpc_udp_header(request) {
-            Ok((_rem, _header)) => {
-                { assert!(false); }
-            }
-            _ => {}
+        if let Ok((_rem, _header)) = parser::parse_dcerpc_udp_header(request) {
+            { assert!(false); }
         }
     }
 
index 3d6a5baab0ca539c4fe74ae939a2a65d56f25b8b..312dad0ca96af603e3f3d3b4cdcb33c0fef58179 100644 (file)
@@ -417,11 +417,8 @@ mod tests {
                 assert!(false);
             }
         }
-        match detect_parse_uint::<u8>("2kb") {
-            Ok((_, _val)) => {
-                assert!(false);
-            }
-            Err(_) => {}
+        if let Ok((_, _val)) = detect_parse_uint::<u8>("2kb") {
+            assert!(false);
         }
         match detect_parse_uint::<u32>("3MB") {
             Ok((_, val)) => {
index 1a46437d65a55d4f63d048036b9250991110de3c..158feed7098f7370f98de366f49d813ab5310231 100644 (file)
@@ -882,11 +882,8 @@ mod tests {
         match r {
             Ok((rem, ctx)) => {
                 assert_eq!(ctx.id, HTTP2SettingsId::EnablePush);
-                match ctx.value {
-                    Some(_) => {
-                        panic!("Unexpected value");
-                    }
-                    None => {}
+                if let Some(_) = ctx.value {
+                    panic!("Unexpected value");
                 }
                 assert_eq!(rem.len(), 0);
             }
index bfad8c005a9d4c8dcad2fafb5566e61c8aadd835..8a33b3591be9bff42f7320910582ae62f52d74ae 100644 (file)
@@ -552,11 +552,8 @@ mod tests {
         ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00];
         let mut hassh_string: Vec<u8> = vec!();
         let mut hassh: Vec<u8> = vec!();
-        match ssh_parse_key_exchange(&client_key_exchange){
-            Ok((_, key_exchange)) => { 
-                key_exchange.generate_hassh(&mut hassh_string, &mut hassh, &true); 
-            }
-            Err(_) => { }
+        if let Ok((_, key_exchange)) = ssh_parse_key_exchange(&client_key_exchange) { 
+            key_exchange.generate_hassh(&mut hassh_string, &mut hassh, &true); 
         }
 
         assert_eq!(hassh_string, "curve25519-sha256,curve25519-sha256@libssh.org,\
@@ -643,11 +640,8 @@ mod tests {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
         let mut hassh_server_string: Vec<u8> = vec!();
         let mut hassh_server: Vec<u8> = vec!();
-        match ssh_parse_key_exchange(&server_key_exchange){
-            Ok((_, key_exchange)) => { 
-                key_exchange.generate_hassh(&mut hassh_server_string, &mut hassh_server, &true);
-            }
-            Err(_) => { }
+        if let Ok((_, key_exchange)) = ssh_parse_key_exchange(&server_key_exchange) { 
+            key_exchange.generate_hassh(&mut hassh_server_string, &mut hassh_server, &true);
         }
         assert_eq!(hassh_server, "b12d2871a1189eff20364cf5333619ee".as_bytes().to_vec());
     }