Skip to content

Commit

Permalink
rust/smb: fix clippy nightly warning
Browse files Browse the repository at this point in the history
error: unnecessary use of `to_vec`
    --> src/smb/smb.rs:1048:62
     |
1048 |         let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
     |                                                              ^^^^^^^^^^^^^^ help: replace it with: `guid`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
     = note: `#[deny(clippy::unnecessary_to_owned)]` implied by `#[deny(warnings)]`

And also other uses of to_vec() on already Vec

(cherry picked from commit f7cde8f)
  • Loading branch information
catenacyber committed Mar 21, 2024
1 parent 5a05e02 commit fce01da
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rust/src/dhcp/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl DHCPLogger {

js.set_uint("id", header.txid as u64)?;
js.set_string("client_mac",
&format_addr_hex(&header.clienthw.to_vec()))?;
&format_addr_hex(&header.clienthw))?;
js.set_string("assigned_ip", &dns_print_addr(&header.yourip))?;

if self.extended {
Expand Down
2 changes: 1 addition & 1 deletion rust/src/smb/smb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ impl SMBState {

pub fn get_service_for_guid(&self, guid: &[u8]) -> (&'static str, bool)
{
let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
let (name, is_dcerpc) = match self.guid2name_map.get(guid) {
Some(n) => {
let mut s = n.as_slice();
// skip leading \ if we have it
Expand Down
2 changes: 1 addition & 1 deletion rust/src/smb/smb1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ fn smb1_request_record_one(state: &mut SMBState, r: &SmbRecord, command: u8, and
state.ssn2vec_map.insert(name_key, name_val);

let tx_hdr = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
let tx = state.new_create_tx(&cr.file_name.to_vec(),
let tx = state.new_create_tx(&cr.file_name,
cr.disposition, del, dir, tx_hdr);
tx.vercmd.set_smb1_cmd(command);
SCLogDebug!("TS CREATE TX {} created", tx.id);
Expand Down

0 comments on commit fce01da

Please sign in to comment.