]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/dcerpc: fix single_match clippy warning
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 9 Sep 2024 09:09:18 +0000 (11:09 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 11 Sep 2024 07:53:03 +0000 (09:53 +0200)
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

index 3e7322780342d39afb6d90b6d87ccdfbc8aece3a..297a1df2ef783705adfc45665506e35d93d7b91b 100644 (file)
@@ -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()?;
             },
             _ => {}
         }