From: Philippe Antoine Date: Fri, 5 Jan 2024 09:30:33 +0000 (+0100) Subject: rust: fix single_match X-Git-Tag: suricata-8.0.0-beta1~1841 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b141eb9f1146bfe44bb9c4db136e27eee55e81a8;p=thirdparty%2Fsuricata.git rust: fix single_match warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/http2/parser.rs:882:17 | 882 | / match ctx.value { 883 | | Some(_) => { 884 | | panic!("Unexpected value"); 885 | | } 886 | | None => {} 887 | | } | |_________________^ --- diff --git a/rust/src/http2/parser.rs b/rust/src/http2/parser.rs index adabeb28c6..64799460aa 100644 --- a/rust/src/http2/parser.rs +++ b/rust/src/http2/parser.rs @@ -879,12 +879,7 @@ mod tests { match r { Ok((rem, ctx)) => { assert_eq!(ctx.id, HTTP2SettingsId::EnablePush); - match ctx.value { - Some(_) => { - panic!("Unexpected value"); - } - None => {} - } + assert!(ctx.value.is_none()); assert_eq!(rem.len(), 0); } Err(e) => { diff --git a/rust/src/ssh/parser.rs b/rust/src/ssh/parser.rs index bfad8c005a..0fbd17a412 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()); }