Skip to content

Commit f5c8a8f

Browse files
committed
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 (cherry picked from commit 02cb0f2)
1 parent 626f6ef commit f5c8a8f

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

rust/src/pop3/pop3.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -522,26 +522,27 @@ impl POP3State {
522522
tx.error_flags_to_events(msg.error_flags);
523523
tx.complete = true;
524524
sc_app_layer_parser_trigger_raw_stream_inspection(flow, direction::Direction::ToClient as i32);
525-
if response.status == sawp_pop3::Status::OK && tx.request.is_some() {
526-
let command = tx.request.as_ref().unwrap();
527-
SCLogDebug!("command {:?}", command);
528-
match &command.keyword {
529-
sawp_pop3::Keyword::STLS => {
530-
unsafe {
531-
SCAppLayerRequestProtocolTLSUpgrade(flow);
532-
};
525+
if response.status == sawp_pop3::Status::OK {
526+
if let Some(command) = &tx.request {
527+
SCLogDebug!("command {:?}", command);
528+
match &command.keyword {
529+
sawp_pop3::Keyword::STLS => {
530+
unsafe {
531+
SCAppLayerRequestProtocolTLSUpgrade(flow);
532+
};
533+
}
534+
sawp_pop3::Keyword::RETR => {
535+
// Don't hold onto the whole email body
536+
537+
// TODO: pass off to mime parser
538+
response.data.clear();
539+
}
540+
sawp_pop3::Keyword::AUTH => {
541+
SCLogDebug!("OK on AUTH, expect base64 blob");
542+
auth_ok = true;
543+
}
544+
_ => {}
533545
}
534-
sawp_pop3::Keyword::RETR => {
535-
// Don't hold onto the whole email body
536-
537-
// TODO: pass off to mime parser
538-
response.data.clear();
539-
}
540-
sawp_pop3::Keyword::AUTH => {
541-
SCLogDebug!("OK on AUTH, expect base64 blob");
542-
auth_ok = true;
543-
}
544-
_ => {}
545546
}
546547
}
547548
tx.response = Some(response);

rust/src/smb/smb1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@ pub fn smb1_trans_request_record(state: &mut SMBState, r: &SmbRecord)
854854

855855
/* if we have a fid, store it so the response can pick it up */
856856
let mut pipe_dcerpc = false;
857-
if rd.pipe.is_some() {
858-
let pipe = rd.pipe.unwrap();
857+
if let Some(pipe) = rd.pipe {
859858
state.ssn2vec_cache.put(SMBCommonHdr::from1(r, SMBHDR_TYPE_GUID),
860859
pipe.fid.to_vec());
861860

0 commit comments

Comments
 (0)