From 2a984e3b137a54832df8ae7f4f1bf04784f762dc Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Mon, 9 Sep 2024 11:09:18 +0200 Subject: [PATCH] rust/dcerpc: fix single_match clippy warning warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/dcerpc/log.rs:36:33 | 36 | DCERPC_TYPE_BIND => match &state.bind { | _________________________________^ 37 | | Some(bind) => { 38 | | jsb.open_array("interfaces")?; 39 | | for uuid in &bind.uuid_list { ... | 51 | | None => {} 52 | | }, | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` on by default --- rust/src/dcerpc/log.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/rust/src/dcerpc/log.rs b/rust/src/dcerpc/log.rs index 3e73227803..297a1df2ef 100644 --- a/rust/src/dcerpc/log.rs +++ b/rust/src/dcerpc/log.rs @@ -33,22 +33,19 @@ fn log_dcerpc_header_tcp( jsb.set_uint("stub_data_size", tx.stub_data_buffer_ts.len() as u64)?; jsb.close()?; } - DCERPC_TYPE_BIND => match &state.bind { - Some(bind) => { - jsb.open_array("interfaces")?; - for uuid in &bind.uuid_list { - jsb.start_object()?; - let ifstr = Uuid::from_slice(uuid.uuid.as_slice()); - let ifstr = ifstr.map(|uuid| uuid.to_hyphenated().to_string()).unwrap(); - jsb.set_string("uuid", &ifstr)?; - let vstr = format!("{}.{}", uuid.version, uuid.versionminor); - jsb.set_string("version", &vstr)?; - jsb.set_uint("ack_result", uuid.result as u64)?; - jsb.close()?; - } + DCERPC_TYPE_BIND => if let Some(bind) = &state.bind { + jsb.open_array("interfaces")?; + for uuid in &bind.uuid_list { + jsb.start_object()?; + let ifstr = Uuid::from_slice(uuid.uuid.as_slice()); + let ifstr = ifstr.map(|uuid| uuid.to_hyphenated().to_string()).unwrap(); + jsb.set_string("uuid", &ifstr)?; + let vstr = format!("{}.{}", uuid.version, uuid.versionminor); + jsb.set_string("version", &vstr)?; + jsb.set_uint("ack_result", uuid.result as u64)?; jsb.close()?; } - None => {} + jsb.close()?; }, _ => {} }