rust(lint): use let for binding single value

`match` is better used with binding to multiple variables,
for binding to a single value, `let` statement is recommended.

Bug: #4616
pull/6552/head
Sam Muhammed 4 years ago committed by Victor Julien
parent 42d4eb6943
commit da0a976e23

@ -51,7 +51,6 @@
#![allow(clippy::needless_range_loop)] #![allow(clippy::needless_range_loop)]
#![allow(clippy::enum_variant_names)] #![allow(clippy::enum_variant_names)]
#![allow(clippy::if_same_then_else)] #![allow(clippy::if_same_then_else)]
#![allow(clippy::match_single_binding)]
#![allow(clippy::match_like_matches_macro)] #![allow(clippy::match_like_matches_macro)]
#![allow(clippy::extra_unused_lifetimes)] #![allow(clippy::extra_unused_lifetimes)]
#![allow(clippy::mixed_case_hex_literals)] #![allow(clippy::mixed_case_hex_literals)]

@ -883,9 +883,8 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
let mut frankenfid = pipe.fid.to_vec(); let mut frankenfid = pipe.fid.to_vec();
frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { let (_filename, is_dcerpc) = state.get_service_for_guid(&frankenfid);
(n, x) => (n, x),
};
SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}", SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}",
_filename, is_dcerpc); _filename, is_dcerpc);
pipe_dcerpc = is_dcerpc; pipe_dcerpc = is_dcerpc;
@ -924,9 +923,8 @@ pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
let mut frankenfid = fid.to_vec(); let mut frankenfid = fid.to_vec();
frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { let (_filename, is_dcerpc) = state.get_service_for_guid(&frankenfid);
(n, x) => (n, x),
};
SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}", SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}",
_filename, is_dcerpc); _filename, is_dcerpc);

@ -168,9 +168,7 @@ pub fn smb2_read_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
_ => { (Vec::new(), false) }, _ => { (Vec::new(), false) },
}; };
let mut is_dcerpc = if is_pipe || (share_name.len() == 0 && !is_pipe) { let mut is_dcerpc = if is_pipe || (share_name.len() == 0 && !is_pipe) {
match state.get_service_for_guid(&file_guid) { state.get_service_for_guid(&file_guid).1
(_, x) => x,
}
} else { } else {
false false
}; };
@ -280,9 +278,7 @@ pub fn smb2_write_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
_ => { (Vec::new(), false) }, _ => { (Vec::new(), false) },
}; };
let mut is_dcerpc = if is_pipe || (share_name.len() == 0 && !is_pipe) { let mut is_dcerpc = if is_pipe || (share_name.len() == 0 && !is_pipe) {
match state.get_service_for_guid(wr.guid) { state.get_service_for_guid(wr.guid).1
(_, x) => x,
}
} else { } else {
false false
}; };

@ -62,8 +62,10 @@ pub fn smb2_ioctl_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
match parse_smb2_request_ioctl(r.data) { match parse_smb2_request_ioctl(r.data) {
Ok((_, rd)) => { Ok((_, rd)) => {
SCLogDebug!("IOCTL request data: {:?}", rd); SCLogDebug!("IOCTL request data: {:?}", rd);
let is_dcerpc = rd.is_pipe && match state.get_service_for_guid(rd.guid) { let is_dcerpc = if rd.is_pipe {
(_, x) => x, state.get_service_for_guid(rd.guid).1
} else {
false
}; };
if is_dcerpc { if is_dcerpc {
SCLogDebug!("IOCTL request data is_pipe. Calling smb_write_dcerpc_record"); SCLogDebug!("IOCTL request data is_pipe. Calling smb_write_dcerpc_record");
@ -90,8 +92,10 @@ pub fn smb2_ioctl_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
Ok((_, rd)) => { Ok((_, rd)) => {
SCLogDebug!("IOCTL response data: {:?}", rd); SCLogDebug!("IOCTL response data: {:?}", rd);
let is_dcerpc = rd.is_pipe && match state.get_service_for_guid(rd.guid) { let is_dcerpc = if rd.is_pipe {
(_, x) => x, state.get_service_for_guid(rd.guid).1
} else {
false
}; };
if is_dcerpc { if is_dcerpc {
SCLogDebug!("IOCTL response data is_pipe. Calling smb_read_dcerpc_record"); SCLogDebug!("IOCTL response data is_pipe. Calling smb_read_dcerpc_record");

Loading…
Cancel
Save