rust: fix clippy lints for clippy::collapsible_if

pull/8073/head
Jason Ish 4 years ago committed by Victor Julien
parent 572505870a
commit 119e02cf81

@ -128,12 +128,9 @@ impl DCERPCUDPState {
fn find_incomplete_tx(&mut self, hdr: &DCERPCHdrUdp) -> Option<&mut DCERPCTransaction> {
for tx in &mut self.transactions {
if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid {
if (hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) ||
(hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done) {
SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
return Some(tx);
}
if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid && ((hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) || (hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done)) {
SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
return Some(tx);
}
}
None

@ -308,10 +308,8 @@ fn http2_detect_sizeupdate_match(
blocks: &[parser::HTTP2FrameHeaderBlock], ctx: &DetectUintData<u64>,
) -> std::os::raw::c_int {
for block in blocks.iter() {
if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate {
if detect_match_uint(ctx, block.sizeupdate) {
return 1;
}
if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate && detect_match_uint(ctx, block.sizeupdate) {
return 1;
}
}
return 0;

@ -278,14 +278,12 @@ fn add_proposals(
IkeV2Transform::Auth(IkeTransformAuthType::NONE) => false,
IkeV2Transform::Auth(_) => true,
_ => false,
}) {
if !transforms.iter().any(|x| match *x {
}) && !transforms.iter().any(|x| match *x {
IkeV2Transform::Encryption(ref enc) => enc.is_aead(),
_ => false,
}) {
SCLogDebug!("No integrity transform found");
tx.set_event(IkeEvent::WeakCryptoNoAuth);
}
SCLogDebug!("No integrity transform found");
tx.set_event(IkeEvent::WeakCryptoNoAuth);
}
// Finally
if direction == Direction::ToClient {

@ -2086,10 +2086,8 @@ fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, be
fn smb_probe_tcp(flags: u8, slice: &[u8], rdir: *mut u8, begins: bool) -> AppProto
{
if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM {
if smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 {
unsafe { return ALPROTO_SMB; }
}
if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM && smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 {
unsafe { return ALPROTO_SMB; }
}
match parse_nbss_record_partial(slice) {
Ok((_, ref hdr)) => {

@ -570,15 +570,13 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
false
},
};
if !have_tx {
if smb1_create_new_tx(command) {
let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
let tx = state.new_generic_tx(1, command as u16, tx_key);
SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command));
tx.set_events(events);
if no_response_expected {
tx.response_done = true;
}
if !have_tx && smb1_create_new_tx(command) {
let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
let tx = state.new_generic_tx(1, command as u16, tx_key);
SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command));
tx.set_events(events);
if no_response_expected {
tx.response_done = true;
}
}
}

@ -635,14 +635,12 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
},
};
/* if we don't have a tx, create it here (maybe) */
if !have_tx {
if smb2_create_new_tx(r.command) {
let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
let tx = state.new_generic_tx(2, r.command, tx_key);
SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}",
tx.id, r.command, r.session_id, r.tree_id, r.message_id);
tx.set_events(events);
}
if !have_tx && smb2_create_new_tx(r.command) {
let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
let tx = state.new_generic_tx(2, r.command, tx_key);
SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}",
tx.id, r.command, r.session_id, r.tree_id, r.message_id);
tx.set_events(events);
}
}

Loading…
Cancel
Save