rust: fix clippy lint for partialeq_to_none

Use .is_some() and .is_none() instead of comparing against None.
Comparing against None requires a value to impl PartialEq, is_none() and
is_some() do not and are more idiomatic.
pull/7966/head
Jason Ish 3 years ago committed by Victor Julien
parent 7d623f0854
commit f60e1b30f6

@ -163,7 +163,7 @@ impl IKEState {
.transactions
.iter()
.position(|tx| tx.tx_id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

@ -218,7 +218,7 @@ impl KRB5State {
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

@ -136,7 +136,7 @@ impl NTPState {
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

@ -103,7 +103,7 @@ impl SIPState {
.transactions
.iter()
.position(|tx| tx.id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

@ -132,7 +132,7 @@ fn parse_secblob_spnego(blob: &[u8]) -> Option<SpnegoRequest>
}
}
if have_ntlmssp && kticket == None {
if have_ntlmssp && kticket.is_none() {
SCLogDebug!("parsing expected NTLMSSP");
ntlmssp = parse_ntlmssp_blob(os);
}

@ -646,7 +646,7 @@ fn smb1_response_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command
},
_ => { None },
};
if d == None {
if d.is_none() {
tx.set_event(SMBEvent::NegotiateMalformedDialects);
}
(true, d)
@ -865,7 +865,7 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
/* if we have a fid, store it so the response can pick it up */
let mut pipe_dcerpc = false;
if rd.pipe != None {
if rd.pipe.is_some() {
let pipe = rd.pipe.unwrap();
state.ssn2vec_map.insert(SMBCommonHdr::from1(r, SMBHDR_TYPE_GUID),
pipe.fid.to_vec());

@ -114,7 +114,7 @@ pub fn parse_smb1_write_andx_request_record(i : &[u8], andx_offset: usize) -> IR
let (i, _padding_evasion) = cond(data_offset > ax+4+2*(wct as u16), |b| take(data_offset - (ax+4+2*(wct as u16)))(b))(i)?;
let (i, file_data) = rest(i)?;
let record = Smb1WriteRequestRecord {
offset: if high_offset != None { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
offset: if high_offset.is_some() { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
len: (((data_len_high as u32) << 16) as u32)|(data_len_low as u32),
fid,
data: file_data,
@ -514,7 +514,7 @@ pub fn parse_smb_read_andx_request_record(i: &[u8]) -> IResult<&[u8], SmbRequest
let record = SmbRequestReadAndXRecord {
fid,
size: (((max_count_high as u64) << 16)|max_count_low as u64),
offset: if high_offset != None { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
offset: if high_offset.is_some() { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
};
Ok((i, record))
}

@ -218,7 +218,7 @@ impl<'a> SNMPState<'a> {
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

@ -55,7 +55,7 @@ impl TFTPState {
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
debug_assert!(tx != None);
debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}

Loading…
Cancel
Save