]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/smb: fix manual_unwrap_or_default 13540/head 13544/head
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 27 Jun 2025 07:42:59 +0000 (09:42 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Fri, 27 Jun 2025 07:43:18 +0000 (09:43 +0200)
warning: match can be simplified with `.unwrap_or_default()`
   --> src/smb/smb2.rs:682:41
    |
682 |                           let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
    |  _________________________________________^
683 | |                             Some(p) => p,
684 | |                             None => {
685 | |                                 SCLogDebug!("SMBv2 response: GUID NOT FOUND");
686 | |                                 Vec::new()
687 | |                             },
688 | |                         };
    | |_________________________^ help: replace it with: `state.ssn2vec_map.remove(&guid_key).unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
    = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default

rust/src/smb/smb2.rs

index a2fe021b0276f6b7a56d79385cd2c9963ea4c5be..98ed30da1cb58b18ddc8aee6ccb4e4f1611295db 100644 (file)
@@ -679,13 +679,7 @@ pub fn smb2_response_record(state: &mut SMBState, r: &Smb2Record)
                         /* search key-guid map */
                         let guid_key = SMBCommonHdr::new(SMBHDR_TYPE_GUID,
                                 r.session_id, r.tree_id, r.message_id);
-                        let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
-                            Some(p) => p,
-                            None => {
-                                SCLogDebug!("SMBv2 response: GUID NOT FOUND");
-                                Vec::new()
-                            },
-                        };
+                        let _guid_vec = state.ssn2vec_map.remove(&guid_key).unwrap_or_default();
                         SCLogDebug!("SMBv2 write response for GUID {:?}", _guid_vec);
                     }
                     _ => {