rust: fix unnecessary_unwrap warnings

warning: called `unwrap` on `rd.pipe` after checking its variant with `is_some`
   --> src/smb/smb1.rs:858:28
    |
857 |             if rd.pipe.is_some() {
    |             -------------------- help: try: `if let Some(<item>) = rd.pipe`
858 |                 let pipe = rd.pipe.unwrap();
    |                            ^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#unnecessary_unwrap
    = note: `#[warn(clippy::unnecessary_unwrap)]` on by default
pull/14683/head
Philippe Antoine 3 months ago
parent 9df5fd180e
commit 02cb0f2ac2

@ -541,26 +541,27 @@ impl POP3State {
flow, flow,
direction::Direction::ToClient as i32, direction::Direction::ToClient as i32,
); );
if response.status == sawp_pop3::Status::OK && tx.request.is_some() { if response.status == sawp_pop3::Status::OK {
let command = tx.request.as_ref().unwrap(); if let Some(command) = &tx.request {
SCLogDebug!("command {:?}", command); SCLogDebug!("command {:?}", command);
match &command.keyword { match &command.keyword {
sawp_pop3::Keyword::STLS => { sawp_pop3::Keyword::STLS => {
unsafe { unsafe {
SCAppLayerRequestProtocolTLSUpgrade(flow); SCAppLayerRequestProtocolTLSUpgrade(flow);
}; };
}
sawp_pop3::Keyword::RETR => {
// Don't hold onto the whole email body
// TODO: pass off to mime parser
response.data.clear();
}
sawp_pop3::Keyword::AUTH => {
SCLogDebug!("OK on AUTH, expect base64 blob");
auth_ok = true;
}
_ => {}
} }
sawp_pop3::Keyword::RETR => {
// Don't hold onto the whole email body
// TODO: pass off to mime parser
response.data.clear();
}
sawp_pop3::Keyword::AUTH => {
SCLogDebug!("OK on AUTH, expect base64 blob");
auth_ok = true;
}
_ => {}
} }
} }
tx.response = Some(response); tx.response = Some(response);

@ -854,8 +854,7 @@ pub fn smb1_trans_request_record(state: &mut SMBState, r: &SmbRecord)
/* if we have a fid, store it so the response can pick it up */ /* if we have a fid, store it so the response can pick it up */
let mut pipe_dcerpc = false; let mut pipe_dcerpc = false;
if rd.pipe.is_some() { if let Some(pipe) = rd.pipe {
let pipe = rd.pipe.unwrap();
state.ssn2vec_cache.put(SMBCommonHdr::from1(r, SMBHDR_TYPE_GUID), state.ssn2vec_cache.put(SMBCommonHdr::from1(r, SMBHDR_TYPE_GUID),
pipe.fid.to_vec()); pipe.fid.to_vec());

Loading…
Cancel
Save