From: Jason Ish Date: Tue, 6 Aug 2024 16:10:43 +0000 (-0600) Subject: rust: fix clippy warnings for match as if statements X-Git-Tag: suricata-7.0.7~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3f7bcc091aebef62ec7aa68c55899ea933f44c6;p=thirdparty%2Fsuricata.git rust: fix clippy warnings for match as if statements Fix done by clippy --fix. --- diff --git a/rust/src/dcerpc/dcerpc_udp.rs b/rust/src/dcerpc/dcerpc_udp.rs index 7c83bbc04a..05d49973c8 100644 --- a/rust/src/dcerpc/dcerpc_udp.rs +++ b/rust/src/dcerpc/dcerpc_udp.rs @@ -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); } } } diff --git a/rust/src/detect/uint.rs b/rust/src/detect/uint.rs index 3d6a5baab0..312dad0ca9 100644 --- a/rust/src/detect/uint.rs +++ b/rust/src/detect/uint.rs @@ -417,11 +417,8 @@ mod tests { assert!(false); } } - match detect_parse_uint::("2kb") { - Ok((_, _val)) => { - assert!(false); - } - Err(_) => {} + if let Ok((_, _val)) = detect_parse_uint::("2kb") { + assert!(false); } match detect_parse_uint::("3MB") { Ok((_, val)) => { diff --git a/rust/src/http2/parser.rs b/rust/src/http2/parser.rs index 1a46437d65..158feed709 100644 --- a/rust/src/http2/parser.rs +++ b/rust/src/http2/parser.rs @@ -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); } diff --git a/rust/src/ssh/parser.rs b/rust/src/ssh/parser.rs index bfad8c005a..8a33b3591b 100644 --- a/rust/src/ssh/parser.rs +++ b/rust/src/ssh/parser.rs @@ -552,11 +552,8 @@ mod tests { ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00]; let mut hassh_string: Vec = vec!(); let mut hassh: Vec = 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 = vec!(); let mut hassh_server: Vec = 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()); }