rust: fix needless borrows of references

Fixed automatically by cargo clippy --fix.
pull/8468/head
Jason Ish 3 years ago committed by Victor Julien
parent 29f345af1a
commit e7f5bd047d

@ -42,7 +42,7 @@ impl DHCPLogger {
let code = option.code;
#[allow(clippy::single_match)]
match &option.option {
&DHCPOptionWrapper::Generic(ref option) => {
DHCPOptionWrapper::Generic(option) => {
#[allow(clippy::single_match)]
match code {
DHCP_OPT_TYPE => {

@ -255,10 +255,10 @@ impl DNSTransaction {
/// Get the DNS transactions ID (not the internal tracking ID).
pub fn tx_id(&self) -> u16 {
if let &Some(ref request) = &self.request {
if let Some(request) = &self.request {
return request.header.tx_id;
}
if let &Some(ref response) = &self.response {
if let Some(response) = &self.response {
return response.header.tx_id;
}
@ -269,7 +269,7 @@ impl DNSTransaction {
/// Get the reply code of the transaction. Note that this will
/// also return 0 if there is no reply.
pub fn rcode(&self) -> u16 {
if let &Some(ref response) = &self.response {
if let Some(response) = &self.response {
return response.header.flags & 0x000f;
}
return 0;
@ -865,7 +865,7 @@ export_state_data_get!(rs_dns_get_state_data, DNSState);
pub unsafe extern "C" fn rs_dns_tx_get_query_name(
tx: &mut DNSTransaction, i: u32, buf: *mut *const u8, len: *mut u32,
) -> u8 {
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
if (i as usize) < request.queries.len() {
let query = &request.queries[i as usize];
if !query.name.is_empty() {
@ -898,7 +898,7 @@ pub extern "C" fn rs_dns_tx_get_response_flags(tx: &mut DNSTransaction) -> u16 {
pub unsafe extern "C" fn rs_dns_tx_get_query_rrtype(
tx: &mut DNSTransaction, i: u16, rrtype: *mut u16,
) -> u8 {
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
if (i as usize) < request.queries.len() {
let query = &request.queries[i as usize];
if !query.name.is_empty() {

@ -611,7 +611,7 @@ fn dns_log_query(
tx: &mut DNSTransaction, i: u16, flags: u64, jb: &mut JsonBuilder,
) -> Result<bool, JsonError> {
let index = i as usize;
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
if index < request.queries.len() {
let query = &request.queries[index];
if dns_log_rrtype_enabled(query.rrtype, flags) {
@ -651,7 +651,7 @@ pub extern "C" fn rs_dns_log_json_query(
pub extern "C" fn rs_dns_log_json_answer(
tx: &mut DNSTransaction, flags: u64, js: &mut JsonBuilder,
) -> bool {
if let &Some(ref response) = &tx.response {
if let Some(response) = &tx.response {
for query in &response.queries {
if dns_log_rrtype_enabled(query.rrtype, flags) {
return dns_log_json_answer(js, response, flags).is_ok();
@ -663,7 +663,7 @@ pub extern "C" fn rs_dns_log_json_answer(
#[no_mangle]
pub extern "C" fn rs_dns_do_log_answer(tx: &mut DNSTransaction, flags: u64) -> bool {
if let &Some(ref response) = &tx.response {
if let Some(response) = &tx.response {
for query in &response.queries {
if dns_log_rrtype_enabled(query.rrtype, flags) {
return true;

@ -32,12 +32,12 @@ pub extern "C" fn rs_dns_lua_get_tx_id(clua: &mut CLuaState, tx: &mut DNSTransac
pub extern "C" fn rs_dns_lua_get_rrname(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
let lua = LuaState { lua: clua };
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
if let Some(query) = request.queries.first() {
lua.pushstring(&String::from_utf8_lossy(&query.name));
return 1;
}
} else if let &Some(ref response) = &tx.response {
} else if let Some(response) = &tx.response {
if let Some(query) = response.queries.first() {
lua.pushstring(&String::from_utf8_lossy(&query.name));
return 1;
@ -74,7 +74,7 @@ pub extern "C" fn rs_dns_lua_get_query_table(
// We first look in the request for queries. However, if there is
// no request, check the response for queries.
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
for query in &request.queries {
lua.pushinteger(i);
i += 1;
@ -91,7 +91,7 @@ pub extern "C" fn rs_dns_lua_get_query_table(
lua.settable(-3);
}
} else if let &Some(ref response) = &tx.response {
} else if let Some(response) = &tx.response {
for query in &response.queries {
lua.pushinteger(i);
i += 1;
@ -127,7 +127,7 @@ pub extern "C" fn rs_dns_lua_get_answer_table(
// table even in the absence of any authorities.
lua.newtable();
if let &Some(ref response) = &tx.response {
if let Some(response) = &tx.response {
for answer in &response.answers {
lua.pushinteger(i);
i += 1;
@ -206,7 +206,7 @@ pub extern "C" fn rs_dns_lua_get_authority_table(
// table even in the absence of any authorities.
lua.newtable();
if let &Some(ref response) = &tx.response {
if let Some(response) = &tx.response {
for answer in &response.authorities {
lua.pushinteger(i);
i += 1;

@ -321,7 +321,7 @@ impl NFSState {
SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
for d in &rd.listing {
if let &Some(ref _d) = d {
if let Some(_d) = d {
SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(_d.name));
}
}

@ -28,7 +28,7 @@ pub const PGSQL_LOG_PASSWORDS: u32 = BIT_U32!(0);
fn log_pgsql(tx: &PgsqlTransaction, flags: u32, js: &mut JsonBuilder) -> Result<(), JsonError> {
js.set_uint("tx_id", tx.tx_id)?;
if let &Some(ref request) = &tx.request {
if let Some(request) = &tx.request {
js.set_object("request", &log_request(request, flags)?)?;
} else if tx.responses.is_empty() {
SCLogDebug!("Suricata created an empty PGSQL transaction");

Loading…
Cancel
Save