rust: fix clippy ling for needless borrows

Cleanup needless borrows found by clippy. This fix done automatically by
`cargo clippy --fix`.
pull/7966/head
Jason Ish 3 years ago committed by Victor Julien
parent 63b3d73ccc
commit c5b26e2043

@ -86,7 +86,7 @@ fn match_backuuid(
}
if let Some(x) = &if_data.du16 {
if !detect_match_uint(&x, uuidentry.version) {
if !detect_match_uint(x, uuidentry.version) {
SCLogDebug!("Interface version did not match");
ret &= 0;
}

@ -123,14 +123,14 @@ fn log_dcerpc_header_udp(
#[no_mangle]
pub extern "C" fn rs_dcerpc_log_json_record_tcp(
state: &DCERPCState, tx: &DCERPCTransaction, mut jsb: &mut JsonBuilder,
state: &DCERPCState, tx: &DCERPCTransaction, jsb: &mut JsonBuilder,
) -> bool {
log_dcerpc_header_tcp(&mut jsb, state, tx).is_ok()
log_dcerpc_header_tcp(jsb, state, tx).is_ok()
}
#[no_mangle]
pub extern "C" fn rs_dcerpc_log_json_record_udp(
state: &DCERPCUDPState, tx: &DCERPCTransaction, mut jsb: &mut JsonBuilder,
state: &DCERPCUDPState, tx: &DCERPCTransaction, jsb: &mut JsonBuilder,
) -> bool {
log_dcerpc_header_udp(&mut jsb, state, tx).is_ok()
log_dcerpc_header_udp(jsb, state, tx).is_ok()
}

@ -42,7 +42,7 @@ fn parse_opcode(opcode: &str) -> Result<DetectDnsOpcode, ()> {
negated = true;
}
_ => {
let code: u8 = (&opcode[i..]).parse().map_err(|_| ())?;
let code: u8 = opcode[i..].parse().map_err(|_| ())?;
return Ok(DetectDnsOpcode {
negate: negated,
opcode: code,

@ -1474,7 +1474,7 @@ mod tests {
#[test]
fn test_dns_event_from_string() {
let name = "malformed_data";
let event = DNSEvent::from_string(&name).unwrap();
let event = DNSEvent::from_string(name).unwrap();
assert_eq!(event, DNSEvent::MalformedData);
assert_eq!(event.to_cstring(), format!("{}\0", name));
}

@ -659,13 +659,13 @@ pub extern "C" fn rs_dns_log_json_query(tx: &mut DNSTransaction,
#[no_mangle]
pub extern "C" fn rs_dns_log_json_answer(tx: &mut DNSTransaction,
flags: u64, mut js: &mut JsonBuilder)
flags: u64, js: &mut JsonBuilder)
-> bool
{
if let &Some(ref response) = &tx.response {
for query in &response.queries {
if dns_log_rrtype_enabled(query.rrtype, flags) {
return dns_log_json_answer(&mut js, response, flags as u64).is_ok();
return dns_log_json_answer(js, response, flags as u64).is_ok();
}
}
}

@ -256,7 +256,7 @@ fn http2_detect_settings_match(
return 1;
}
Some(x) => {
if detect_match_uint(&x, set[i].value) {
if detect_match_uint(x, set[i].value) {
return 1;
}
}
@ -309,7 +309,7 @@ fn http2_detect_sizeupdate_match(
) -> std::os::raw::c_int {
for block in blocks.iter() {
if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate {
if detect_match_uint(&ctx, block.sizeupdate) {
if detect_match_uint(ctx, block.sizeupdate) {
return 1;
}
}

@ -99,7 +99,7 @@ impl PacketKey {
let (buffer, tag) = payload.split_at_mut(tag_pos);
let taga = GenericArray::from_slice(tag);
self.key
.decrypt_in_place_detached(GenericArray::from_slice(&nonce), header, buffer, &taga)
.decrypt_in_place_detached(GenericArray::from_slice(&nonce), header, buffer, taga)
.map_err(|_| ())?;
Ok(&payload[..tag_pos])
}

@ -62,7 +62,7 @@ impl Cyu {
let cyu_string = format!("{},{}", version, tags);
let mut hasher = Md5::new();
hasher.update(&cyu_string.as_bytes());
hasher.update(cyu_string.as_bytes());
let hash = hasher.finalize();
let cyu_hash = format!("{:x}", hash);

@ -94,10 +94,10 @@ fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonEr
js.set_string("version", String::from(tx.header.version).as_str())?;
if let Some(sni) = &tx.sni {
js.set_string("sni", &String::from_utf8_lossy(&sni))?;
js.set_string("sni", &String::from_utf8_lossy(sni))?;
}
if let Some(ua) = &tx.ua {
js.set_string("ua", &String::from_utf8_lossy(&ua))?;
js.set_string("ua", &String::from_utf8_lossy(ua))?;
}
}
if tx.cyu.len() > 0 {
@ -117,7 +117,7 @@ fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonEr
} else {
js.open_object("ja3s")?;
}
let hash = format!("{:x}", Md5::new().chain(&ja3).finalize());
let hash = format!("{:x}", Md5::new().chain(ja3).finalize());
js.set_string("hash", &hash)?;
js.set_string("string", ja3)?;
js.close()?;

@ -160,7 +160,7 @@ pub extern "C" fn rs_smb_tx_get_dce_iface(state: &mut SMBState,
if i.acked && i.ack_result == 0 && i.uuid == if_uuid {
if let Some(x) = &dce_data.du16 {
if detect_match_uint(&x, i.ver) {
if detect_match_uint(x, i.ver) {
return 1;
}
} else {

@ -100,7 +100,7 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
(true, ntstatus) => {
let status = smb_ntstatus_string(ntstatus);
match status {
Some(x) => jsb.set_string("status", &x)?,
Some(x) => jsb.set_string("status", x)?,
None => {
let status_str = format!("{}", ntstatus);
jsb.set_string("status", &status_str)?
@ -446,14 +446,14 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
}
#[no_mangle]
pub extern "C" fn rs_smb_log_json_request(mut jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
pub extern "C" fn rs_smb_log_json_request(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
{
smb_common_header(&mut jsb, state, tx).is_ok()
smb_common_header(jsb, state, tx).is_ok()
}
#[no_mangle]
pub extern "C" fn rs_smb_log_json_response(mut jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
pub extern "C" fn rs_smb_log_json_response(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool
{
smb_common_header(&mut jsb, state, tx).is_ok()
smb_common_header(jsb, state, tx).is_ok()
}

@ -231,7 +231,7 @@ impl TelnetState {
self.state = TelnetProtocolState::PasswdRecv;
}
TelnetProtocolState::AuthOk => {
let _message = std::str::from_utf8(&d);
let _message = std::str::from_utf8(d);
if let Ok(_message) = _message {
SCLogDebug!("=> {}", _message);
}
@ -322,7 +322,7 @@ impl TelnetState {
self.state = TelnetProtocolState::PasswdSent;
},
TelnetProtocolState::PasswdRecv => {
if let Ok(message) = std::str::from_utf8(&d) {
if let Ok(message) = std::str::from_utf8(d) {
match message {
"Login incorrect" => {
SCLogDebug!("LOGIN FAILED");
@ -339,7 +339,7 @@ impl TelnetState {
}
},
TelnetProtocolState::AuthOk => {
let _message = std::str::from_utf8(&d);
let _message = std::str::from_utf8(d);
if let Ok(_message) = _message {
SCLogDebug!("<= {}", _message);
}

Loading…
Cancel
Save