Skip to content

Commit 02cb0f2

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
1 parent 9df5fd1 commit 02cb0f2

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
@@ -541,26 +541,27 @@ impl POP3State {
541541
flow,
542542
direction::Direction::ToClient as i32,
543543
);
544-
if response.status == sawp_pop3::Status::OK && tx.request.is_some() {
545-
let command = tx.request.as_ref().unwrap();
546-
SCLogDebug!("command {:?}", command);
547-
match &command.keyword {
548-
sawp_pop3::Keyword::STLS => {
549-
unsafe {
550-
SCAppLayerRequestProtocolTLSUpgrade(flow);
551-
};
544+
if response.status == sawp_pop3::Status::OK {
545+
if let Some(command) = &tx.request {
546+
SCLogDebug!("command {:?}", command);
547+
match &command.keyword {
548+
sawp_pop3::Keyword::STLS => {
549+
unsafe {
550+
SCAppLayerRequestProtocolTLSUpgrade(flow);
551+
};
552+
}
553+
sawp_pop3::Keyword::RETR => {
554+
// Don't hold onto the whole email body
555+
556+
// TODO: pass off to mime parser
557+
response.data.clear();
558+
}
559+
sawp_pop3::Keyword::AUTH => {
560+
SCLogDebug!("OK on AUTH, expect base64 blob");
561+
auth_ok = true;
562+
}
563+
_ => {}
552564
}
553-
sawp_pop3::Keyword::RETR => {
554-
// Don't hold onto the whole email body
555-
556-
// TODO: pass off to mime parser
557-
response.data.clear();
558-
}
559-
sawp_pop3::Keyword::AUTH => {
560-
SCLogDebug!("OK on AUTH, expect base64 blob");
561-
auth_ok = true;
562-
}
563-
_ => {}
564565
}
565566
}
566567
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)