rust/clippy: fix lint: match_ref_pats

pull/8251/head
Jason Ish 4 years ago committed by Victor Julien
parent 359d5fcb7e
commit c026d8531b

@ -104,12 +104,12 @@ impl DHCPLogger {
for option in options {
let code = option.code;
match &option.option {
&DHCPOptionWrapper::ClientId(ref clientid) => {
match option.option {
DHCPOptionWrapper::ClientId(ref clientid) => {
js.set_string("client_id",
&format_addr_hex(&clientid.data))?;
}
&DHCPOptionWrapper::TimeValue(ref time_value) => {
DHCPOptionWrapper::TimeValue(ref time_value) => {
match code {
DHCP_OPT_ADDRESS_TIME => {
if self.extended {
@ -130,7 +130,7 @@ impl DHCPLogger {
_ => {}
}
}
&DHCPOptionWrapper::Generic(ref option) => {
DHCPOptionWrapper::Generic(ref option) => {
match code {
DHCP_OPT_SUBNET_MASK => {
if self.extended {

@ -37,7 +37,6 @@
#![allow(clippy::for_loops_over_fallibles)]
#![allow(clippy::manual_find)]
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::match_ref_pats)]
#![allow(clippy::module_inception)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::never_loop)]

@ -171,12 +171,12 @@ impl NFSState {
for c in &cr.commands {
SCLogDebug!("c {:?}", c);
match c {
&Nfs4RequestContent::PutFH(ref rd) => {
match *c {
Nfs4RequestContent::PutFH(ref rd) => {
last_putfh = Some(rd.value);
aux_opcodes.push(NFSPROC4_PUTFH);
}
&Nfs4RequestContent::Read(ref rd) => {
Nfs4RequestContent::Read(ref rd) => {
SCLogDebug!("READv4: {:?}", rd);
if let Some(fh) = last_putfh {
xidmap.chunk_offset = rd.offset;
@ -184,33 +184,33 @@ impl NFSState {
self.xidmap_handle2name(xidmap);
}
}
&Nfs4RequestContent::Open(ref rd) => {
Nfs4RequestContent::Open(ref rd) => {
SCLogDebug!("OPENv4: {}", String::from_utf8_lossy(rd.filename));
xidmap.file_name = rd.filename.to_vec();
}
&Nfs4RequestContent::Lookup(ref rd) => {
Nfs4RequestContent::Lookup(ref rd) => {
SCLogDebug!("LOOKUPv4: {}", String::from_utf8_lossy(rd.filename));
xidmap.file_name = rd.filename.to_vec();
}
&Nfs4RequestContent::Write(ref rd) => {
Nfs4RequestContent::Write(ref rd) => {
SCLogDebug!("WRITEv4: {:?}", rd);
if let Some(fh) = last_putfh {
self.write_v4(r, rd, fh);
}
}
&Nfs4RequestContent::Commit => {
Nfs4RequestContent::Commit => {
SCLogDebug!("COMMITv4");
if let Some(fh) = last_putfh {
self.commit_v4(r, fh);
}
}
&Nfs4RequestContent::Close(ref _rd) => {
Nfs4RequestContent::Close(ref _rd) => {
SCLogDebug!("CLOSEv4: {:?}", _rd);
if let Some(fh) = last_putfh {
self.close_v4(r, fh);
}
}
&Nfs4RequestContent::Create(ref rd) => {
Nfs4RequestContent::Create(ref rd) => {
SCLogDebug!("CREATEv4: {:?}", rd);
if let Some(fh) = last_putfh {
xidmap.file_handle = fh.to_vec();
@ -218,12 +218,12 @@ impl NFSState {
xidmap.file_name = rd.filename.to_vec();
main_opcode = NFSPROC4_CREATE;
}
&Nfs4RequestContent::Remove(rd) => {
Nfs4RequestContent::Remove(rd) => {
SCLogDebug!("REMOVEv4: {:?}", rd);
xidmap.file_name = rd.to_vec();
main_opcode = NFSPROC4_REMOVE;
}
&Nfs4RequestContent::SetClientId(ref _rd) => {
Nfs4RequestContent::SetClientId(ref _rd) => {
SCLogDebug!(
"SETCLIENTIDv4: client id {} r_netid {} r_addr {}",
String::from_utf8_lossy(_rd.client_id),
@ -231,7 +231,7 @@ impl NFSState {
String::from_utf8_lossy(_rd.r_addr)
);
}
&_ => {}
_ => {}
}
}
@ -319,70 +319,62 @@ impl NFSState {
for c in &cr.commands {
SCLogDebug!("c {:?}", c);
match c {
&Nfs4ResponseContent::ReadDir(_s, ref rd) => {
if let &Some(ref rd) = rd {
SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
match *c {
Nfs4ResponseContent::ReadDir(_s, Some(ref rd)) => {
SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
for d in &rd.listing {
if let &Some(ref _d) = d {
SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(_d.name));
}
for d in &rd.listing {
if let &Some(ref _d) = d {
SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(_d.name));
}
}
}
&Nfs4ResponseContent::Remove(s) => {
Nfs4ResponseContent::Remove(s) => {
SCLogDebug!("REMOVE4: status {}", s);
main_opcode_status = s;
main_opcode_status_set = true;
}
&Nfs4ResponseContent::Create(s) => {
Nfs4ResponseContent::Create(s) => {
SCLogDebug!("CREATE4: status {}", s);
main_opcode_status = s;
main_opcode_status_set = true;
}
&Nfs4ResponseContent::Read(s, ref rd) => {
if let &Some(ref rd) = rd {
SCLogDebug!(
"READ4: xidmap {:?} status {} data {}",
xidmap,
s,
rd.data.len()
);
// convert record to generic read reply
let reply = NfsReplyRead {
status: s,
attr_follows: 0,
attr_blob: &[],
count: rd.count,
eof: rd.eof,
data_len: rd.data.len() as u32,
data: rd.data,
};
self.process_read_record(r, &reply, Some(xidmap));
}
Nfs4ResponseContent::Read(s, Some(ref rd)) => {
SCLogDebug!(
"READ4: xidmap {:?} status {} data {}",
xidmap,
s,
rd.data.len()
);
// convert record to generic read reply
let reply = NfsReplyRead {
status: s,
attr_follows: 0,
attr_blob: &[],
count: rd.count,
eof: rd.eof,
data_len: rd.data.len() as u32,
data: rd.data,
};
self.process_read_record(r, &reply, Some(xidmap));
}
&Nfs4ResponseContent::Open(_s, ref rd) => {
if let &Some(ref _rd) = rd {
SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
insert_filename_with_getfh = true;
}
Nfs4ResponseContent::Open(_s, Some(ref _rd)) => {
SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
insert_filename_with_getfh = true;
}
&Nfs4ResponseContent::GetFH(_s, ref rd) => {
if let &Some(ref rd) = rd {
if insert_filename_with_getfh {
self.namemap
.insert(rd.value.to_vec(), xidmap.file_name.to_vec());
}
Nfs4ResponseContent::GetFH(_s, Some(ref rd)) => {
if insert_filename_with_getfh {
self.namemap
.insert(rd.value.to_vec(), xidmap.file_name.to_vec());
}
}
&Nfs4ResponseContent::PutRootFH(s) => {
Nfs4ResponseContent::PutRootFH(s) => {
if s == NFS4_OK && xidmap.file_name.is_empty() {
xidmap.file_name = b"<mount_root>".to_vec();
SCLogDebug!("filename {:?}", xidmap.file_name);
}
}
&_ => {}
_ => {}
}
}

@ -73,9 +73,9 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
let dialect = &smb2_dialect_string(state.dialect);
jsb.set_string("dialect", dialect)?;
} else {
let dialect = match &state.dialect_vec {
&Some(ref d) => str::from_utf8(d).unwrap_or("invalid"),
&None => "unknown",
let dialect = match state.dialect_vec {
Some(ref d) => str::from_utf8(d).unwrap_or("invalid"),
None => "unknown",
};
jsb.set_string("dialect", dialect)?;
}

Loading…
Cancel
Save