rust: fix clippy lints for clippy::redundant_field_names

pull/8073/head
Jason Ish 3 years ago committed by Victor Julien
parent 5f7ba03e63
commit 565da0d0af

@ -250,8 +250,8 @@ impl AppLayerResult {
pub fn incomplete(consumed: u32, needed: u32) -> Self {
return Self {
status: 1,
consumed: consumed,
needed: needed,
consumed,
needed,
};
}
@ -479,7 +479,7 @@ pub struct AppLayerGetTxIterTuple {
impl AppLayerGetTxIterTuple {
pub fn with_values(tx_ptr: *mut std::os::raw::c_void, tx_id: u64, has_next: bool) -> AppLayerGetTxIterTuple {
AppLayerGetTxIterTuple {
tx_ptr: tx_ptr, tx_id: tx_id, has_next: has_next,
tx_ptr, tx_id, has_next,
}
}
pub fn not_found() -> AppLayerGetTxIterTuple {

@ -145,9 +145,9 @@ fn parse_iface_data(arg: &str) -> Result<DCEIfaceData, ()> {
}
Ok(DCEIfaceData {
if_uuid: if_uuid,
du16: du16,
any_frag: any_frag,
if_uuid,
du16,
any_frag,
})
}

@ -466,20 +466,20 @@ mod tests {
result: &str, base: ByteMathBase, endian: ByteMathEndian, bitmask_val: u32, flags: u8,
) {
let bmd = DetectByteMathData {
nbytes: nbytes,
offset: offset,
oper: oper,
nbytes,
offset,
oper,
rvalue_str: if !rvalue_str.is_empty() {
CString::new(rvalue_str).unwrap().into_raw()
} else {
std::ptr::null_mut()
},
rvalue: rvalue,
rvalue,
result: CString::new(result).unwrap().into_raw(),
base: base,
endian: endian,
bitmask_val: bitmask_val,
flags: flags,
base,
endian,
bitmask_val,
flags,
..Default::default()
};

@ -99,9 +99,9 @@ pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData> {
let (i, arg1) = map_opt(digit1, |s: &str| s.parse::<u8>().ok())(i)?;
let (i, _) = all_consuming(take_while(|c| c == ' '))(i)?;
let du8 = DetectUintData::<u8> {
arg1: arg1,
arg1,
arg2: 0,
mode: mode,
mode,
};
return Ok((i, DetectIPRepData { du8, cat, cmd }));
}

@ -70,9 +70,9 @@ pub fn detect_parse_stream_size(i: &str) -> IResult<&str, DetectStreamSizeData>
let (i, arg1) = map_opt(digit1, |s: &str| s.parse::<u32>().ok())(i)?;
let (i, _) = all_consuming(take_while(|c| c == ' '))(i)?;
let du32 = DetectUintData::<u32> {
arg1: arg1,
arg1,
arg2: 0,
mode: mode,
mode,
};
Ok((i, DetectStreamSizeData { flags, du32 }))
}

@ -162,7 +162,7 @@ fn detect_parse_uint_start_symbol<T: DetectIntType>(i: &str) -> IResult<&str, De
DetectUintData {
arg1,
arg2: T::min_value(),
mode: mode,
mode,
},
))
}

@ -85,7 +85,7 @@ impl DHCPTransaction {
pub fn new(id: u64, message: DHCPMessage) -> DHCPTransaction {
DHCPTransaction {
tx_id: id,
message: message,
message,
tx_data: applayer::AppLayerTxData::new(),
}
}

@ -102,13 +102,13 @@ pub fn parse_header(i: &[u8]) -> IResult<&[u8], DHCPHeader> {
Ok((
i,
DHCPHeader {
opcode: opcode,
htype: htype,
hlen: hlen,
hops: hops,
txid: txid,
seconds: seconds,
flags: flags,
opcode,
htype,
hlen,
hops,
txid,
seconds,
flags,
clientip: clientip.to_vec(),
yourip: yourip.to_vec(),
serverip: serverip.to_vec(),
@ -129,7 +129,7 @@ pub fn parse_clientid_option(i: &[u8]) -> IResult<&[u8], DHCPOption> {
Ok((
i,
DHCPOption {
code: code,
code,
data: None,
option: DHCPOptionWrapper::ClientId(DHCPOptClientId {
htype: 1,
@ -146,9 +146,9 @@ pub fn parse_address_time_option(i: &[u8]) -> IResult<&[u8], DHCPOption> {
Ok((
i,
DHCPOption {
code: code,
code,
data: None,
option: DHCPOptionWrapper::TimeValue(DHCPOptTimeValue { seconds: seconds }),
option: DHCPOptionWrapper::TimeValue(DHCPOptTimeValue { seconds }),
},
))
}
@ -160,7 +160,7 @@ pub fn parse_generic_option(i: &[u8]) -> IResult<&[u8], DHCPOption> {
Ok((
i,
DHCPOption {
code: code,
code,
data: None,
option: DHCPOptionWrapper::Generic(DHCPOptGeneric {
data: data.to_vec(),
@ -226,10 +226,10 @@ pub fn dhcp_parse(input: &[u8]) -> IResult<&[u8], DHCPMessage> {
}
}
let message = DHCPMessage {
header: header,
options: options,
malformed_options: malformed_options,
truncated_options: truncated_options,
header,
options,
malformed_options,
truncated_options,
};
return Ok((next, message));
}

@ -875,7 +875,7 @@ fn http2_tx_set_header(state: &mut HTTP2State, name: &[u8], input: &[u8]) {
let hs = parser::HTTP2FrameHeaders {
padlength: None,
priority: None,
blocks: blocks,
blocks,
};
let txdata = HTTP2FrameTypeData::HEADERS(hs);
let tx = state.find_or_create_tx(&head, &txdata, Direction::ToServer);
@ -1038,7 +1038,7 @@ mod tests {
let hs = parser::HTTP2FrameHeaders {
padlength: None,
priority: None,
blocks: blocks,
blocks,
};
let txdata = HTTP2FrameTypeData::HEADERS(hs);
tx.frames_ts.push(HTTP2Frame {

@ -106,7 +106,7 @@ impl JsonBuilder {
let mut buf = String::with_capacity(capacity);
buf.push('{');
Self {
buf: buf,
buf,
state: vec![State::None, State::ObjectFirst],
init_type: Type::Object,
}
@ -121,7 +121,7 @@ impl JsonBuilder {
let mut buf = String::with_capacity(capacity);
buf.push('[');
Self {
buf: buf,
buf,
state: vec![State::None, State::ArrayFirst],
init_type: Type::Array,
}

@ -242,7 +242,7 @@ impl KRB5Transaction {
etype: None,
ticket_etype: None,
error_code: None,
id: id,
id,
tx_data: applayer::AppLayerTxData::new(),
}
}

@ -155,7 +155,7 @@ impl NTPTransaction {
pub fn new(id: u64) -> NTPTransaction {
NTPTransaction {
xid: 0,
id: id,
id,
tx_data: applayer::AppLayerTxData::new(),
}
}

@ -77,7 +77,7 @@ impl PacketKey {
let key = Aes128Gcm::new(GenericArray::from_slice(&secret));
let mut r = PacketKey {
key: key,
key,
iv: [0u8; AES128_IV_LEN],
};
hkdf_expand_label(&hk, b"quic iv", &mut r.iv, AES128_IV_LEN as u16);

@ -237,8 +237,8 @@ impl QuicHeader {
rest,
QuicHeader {
flags,
ty: ty,
version: version,
ty,
version,
version_buf: version_buf.to_vec(),
dcid: dcid.to_vec(),
scid: Vec::new(),

@ -73,13 +73,13 @@ impl QuicTransaction {
fn new_empty(client: bool, header: QuicHeader) -> Self {
QuicTransaction {
tx_id: 0,
header: header,
header,
cyu: Vec::new(),
sni: None,
ua: None,
extv: Vec::new(),
ja3: None,
client: client,
client,
tx_data: AppLayerTxData::new(),
}
}

@ -143,7 +143,7 @@ fn parse_secblob_spnego(blob: &[u8]) -> Option<SpnegoRequest>
let s = SpnegoRequest {
krb: kticket,
ntlmssp: ntlmssp,
ntlmssp,
};
Some(s)
}
@ -181,9 +181,9 @@ fn parse_ntlmssp_blob(blob: &[u8]) -> Option<NtlmsspData>
domain.retain(|&i|i != 0x00);
let d = NtlmsspData {
host: host,
user: user,
domain: domain,
host,
user,
domain,
version: ad.version,
};
ntlmssp_data = Some(d);

@ -76,9 +76,9 @@ pub struct DCERPCIface {
impl DCERPCIface {
pub fn new(uuid: Vec<u8>, ver: u16, ver_min: u16) -> Self {
Self {
uuid: uuid,
ver:ver,
ver_min:ver_min,
uuid,
ver,
ver_min,
..Default::default()
}
}
@ -106,15 +106,15 @@ impl SMBTransactionDCERPC {
context_id: 0,
req_cmd: req,
req_set: true,
call_id: call_id,
call_id,
..Default::default()
}
}
fn new_response(call_id: u32) -> Self {
return Self {
call_id: call_id,
return Self {
call_id,
..Default::default()
}
};
}
pub fn set_result(&mut self, res: u8) {
self.res_set = true;

@ -169,7 +169,7 @@ impl SMBVerCmdStat {
smb_ver: 1,
smb1_cmd: cmd,
status_set: true,
status: status,
status,
..Default::default()
}
}
@ -186,7 +186,7 @@ impl SMBVerCmdStat {
smb_ver: 2,
smb2_cmd: cmd,
status_set: true,
status: status,
status,
..Default::default()
}
}
@ -312,11 +312,11 @@ impl SMBTransactionSetFilePathInfo {
-> Self
{
return Self {
filename: filename, fid: fid,
subcmd: subcmd,
loi: loi,
delete_on_close: delete_on_close,
}
filename, fid,
subcmd,
loi,
delete_on_close,
};
}
}
@ -369,8 +369,8 @@ pub struct SMBTransactionRename {
impl SMBTransactionRename {
pub fn new(fuid: Vec<u8>, oldname: Vec<u8>, newname: Vec<u8>) -> Self {
return Self {
fuid: fuid, oldname: oldname, newname: newname,
}
fuid, oldname, newname,
};
}
}
@ -414,7 +414,7 @@ impl SMBTransactionCreate {
disposition: disp,
delete_on_close: del,
directory: dir,
filename: filename,
filename,
..Default::default()
}
}
@ -434,10 +434,10 @@ pub struct SMBTransactionNegotiate {
impl SMBTransactionNegotiate {
pub fn new(smb_ver: u8) -> Self {
return Self {
smb_ver: smb_ver,
smb_ver,
server_guid: Vec::with_capacity(16),
..Default::default()
}
};
}
}
@ -456,9 +456,9 @@ pub struct SMBTransactionTreeConnect {
impl SMBTransactionTreeConnect {
pub fn new(share_name: Vec<u8>) -> Self {
return Self {
share_name:share_name,
share_name,
..Default::default()
}
};
}
}
@ -532,8 +532,8 @@ pub struct SMBFileGUIDOffset {
impl SMBFileGUIDOffset {
pub fn new(guid: Vec<u8>, offset: u64) -> Self {
Self {
guid:guid,
offset:offset,
guid,
offset,
}
}
}
@ -565,10 +565,10 @@ impl SMBCommonHdr {
}
pub fn new(rec_type: u32, ssn_id: u64, tree_id: u32, msg_id: u64) -> Self {
Self {
rec_type : rec_type,
ssn_id : ssn_id,
tree_id : tree_id,
msg_id : msg_id,
rec_type,
ssn_id,
tree_id,
msg_id,
}
}
pub fn from2(r: &Smb2Record, rec_type: u32) -> SMBCommonHdr {
@ -582,10 +582,10 @@ impl SMBCommonHdr {
};
SMBCommonHdr {
rec_type : rec_type,
rec_type,
ssn_id : r.session_id,
tree_id : tree_id,
msg_id : msg_id,
tree_id,
msg_id,
}
}
@ -601,10 +601,10 @@ impl SMBCommonHdr {
};
SMBCommonHdr {
rec_type : rec_type,
rec_type,
ssn_id : r.session_id,
tree_id : 0,
msg_id : msg_id,
msg_id,
}
}
pub fn from1(r: &SmbRecord, rec_type: u32) -> SMBCommonHdr {
@ -618,10 +618,10 @@ impl SMBCommonHdr {
};
SMBCommonHdr {
rec_type : rec_type,
rec_type,
ssn_id : r.ssn_id as u64,
tree_id : tree_id,
msg_id : msg_id,
tree_id,
msg_id,
}
}
@ -641,7 +641,7 @@ pub struct SMBHashKeyHdrGuid {
impl SMBHashKeyHdrGuid {
pub fn new(hdr: SMBCommonHdr, guid: Vec<u8>) -> Self {
Self {
hdr: hdr, guid: guid,
hdr, guid,
}
}
}
@ -655,8 +655,8 @@ pub struct SMBTree {
impl SMBTree {
pub fn new(name: Vec<u8>, is_pipe: bool) -> Self {
Self {
name:name,
is_pipe:is_pipe,
name,
is_pipe,
}
}
}

@ -56,9 +56,9 @@ pub fn smb1_session_setup_request_host_info(r: &SmbRecord, blob: &[u8]) -> Sessi
SCLogDebug!("name1 {:?} name2 {:?} name3 {:?}", native_os,native_lm,primary_domain);
SessionSetupRequest {
native_os:native_os,
native_lm:native_lm,
primary_domain:primary_domain,
native_os,
native_lm,
primary_domain,
}
} else {
let (native_os, native_lm, primary_domain) = match smb_get_ascii_string(blob) {
@ -78,9 +78,9 @@ pub fn smb1_session_setup_request_host_info(r: &SmbRecord, blob: &[u8]) -> Sessi
SCLogDebug!("session_setup_request_host_info: not unicode");
SessionSetupRequest {
native_os: native_os,
native_lm: native_lm,
primary_domain: primary_domain,
native_os,
native_lm,
primary_domain,
}
}
}
@ -102,8 +102,8 @@ pub fn smb1_session_setup_response_host_info(r: &SmbRecord, blob: &[u8]) -> Sess
SCLogDebug!("name1 {:?} name2 {:?}", native_os,native_lm);
SessionSetupResponse {
native_os:native_os,
native_lm:native_lm,
native_os,
native_lm,
}
} else {
SCLogDebug!("session_setup_response_host_info: not unicode");
@ -117,8 +117,8 @@ pub fn smb1_session_setup_response_host_info(r: &SmbRecord, blob: &[u8]) -> Sess
_ => { (Vec::new(), Vec::new()) },
};
SessionSetupResponse {
native_os: native_os,
native_lm: native_lm,
native_os,
native_lm,
}
}
}

@ -32,8 +32,8 @@ pub struct SMBTransactionIoctl {
impl SMBTransactionIoctl {
pub fn new(func: u32) -> Self {
return Self {
func: func,
}
func,
};
}
}

@ -245,7 +245,7 @@ impl<'a> SNMPTransaction<'a> {
community: None,
usm: None,
encrypted: false,
id: id,
id,
tx_data: applayer::AppLayerTxData::new(),
}
}

Loading…
Cancel
Save