]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy lints for clippy::redundant_field_names
authorJason Ish <jason.ish@oisf.net>
Wed, 5 Oct 2022 14:58:55 +0000 (08:58 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 09:20:08 +0000 (11:20 +0200)
21 files changed:
rust/src/applayer.rs
rust/src/dcerpc/detect.rs
rust/src/detect/byte_math.rs
rust/src/detect/iprep.rs
rust/src/detect/stream_size.rs
rust/src/detect/uint.rs
rust/src/dhcp/dhcp.rs
rust/src/dhcp/parser.rs
rust/src/http2/detect.rs
rust/src/jsonbuilder.rs
rust/src/krb/krb5.rs
rust/src/ntp/ntp.rs
rust/src/quic/crypto.rs
rust/src/quic/parser.rs
rust/src/quic/quic.rs
rust/src/smb/auth.rs
rust/src/smb/dcerpc.rs
rust/src/smb/smb.rs
rust/src/smb/smb1_session.rs
rust/src/smb/smb2_ioctl.rs
rust/src/snmp/snmp.rs

index 9eb4518eac89636795d3d4371f0a02ef090a67c5..2d22e7a49a65898fda8ab18d869439feef8dd9a1 100644 (file)
@@ -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 {
index 5d616a66425fb23b658f0609f6b8e45ae4dc1b64..ab9c637ab88f462b378791d004b8de52aee49be0 100644 (file)
@@ -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,
     })
 }
 
index beb40ec864d3182f814ce729231eae1fe7072c6b..2d7c67aeedca86e9c0fdf52ab1f3f05f720dcc34 100644 (file)
@@ -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()
         };
 
index feefb8ab1e93718dfab803803615ceb66d3a4833..4018ea97a45edbd412a1f8945acec802454b1cb2 100644 (file)
@@ -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 }));
 }
index 394cd781a1104a3fb04f744602e6a33a6dff903e..cb8c826697a753513b821c41a7166f2d58af3fae 100644 (file)
@@ -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 }))
 }
index 4d99047572cae053a9ab88260829f59b44746780..6cf31b2dbcf18639dc427b3be3d692c9d8fa6fb7 100644 (file)
@@ -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,
         },
     ))
 }
index 626c368809d1354ef9305c3211583362c722e7f2..407a5c47adfa0793d8a43a265eb71dcfeabf8afc 100644 (file)
@@ -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(),
         }
     }
index cb7d2f8c61ff6ec51657f6b84fd9daca33cb9826..9f6397fd44041a6709e3c235ee15fe1101aa414f 100644 (file)
@@ -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));
         }
index 2cdb60449fb992d15cdf4d21b05375055080071c..58f62d1c65aa512cab0e282bf00fad00565c491f 100644 (file)
@@ -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 {
index 8fde424dd82846c8b16cba48035e35b4198d9c06..e3d47dad92807f7d7496c55456e8306ec895e429 100644 (file)
@@ -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,
         }
index 0399733c06219adf1a489d16fd8e3cc5919c528b..3370502b23d59255bf33494af921481b2e3a775a 100644 (file)
@@ -242,7 +242,7 @@ impl KRB5Transaction {
             etype: None,
             ticket_etype: None,
             error_code: None,
-            id: id,
+            id,
             tx_data: applayer::AppLayerTxData::new(),
         }
     }
index 5b3601a2b390d259cc90ec7e58ec37cf2797db45..63cb0bb7514f19d124c67548beef3995cd5f2cb1 100644 (file)
@@ -155,7 +155,7 @@ impl NTPTransaction {
     pub fn new(id: u64) -> NTPTransaction {
         NTPTransaction {
             xid: 0,
-            id: id,
+            id,
             tx_data: applayer::AppLayerTxData::new(),
         }
     }
index 22821728fc4c9c036b14351ddcbfc34e103103c4..c86b9958c3167dbb102cd1827c1810a9e9740dea 100644 (file)
@@ -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);
index aafc51b367c9df3bb156325286a1fed91aef0286..69d93a7ddae794c0e3ddf580e47f06ca857a858e 100644 (file)
@@ -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(),
index 2dfe2e608f6f00713f75be3dd9f1a282064585c7..846b493199446fcd5321f743d6bf1ed68a44a475 100644 (file)
@@ -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(),
         }
     }
index c6289e7af83cdf20ebf2e8d6d10e387f37736128..d92a0c9f44d0ead9838935db70a53a8419e3f53d 100644 (file)
@@ -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);
index 2be850c528698f5a20c226c38b120bf2442471ce..26de2f9402fd59947ced4aaf3da7233dd9b41aa7 100644 (file)
@@ -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;
index 42af767ce7324b4a14257b4a6e8a883133088c52..4ab807c46d1ee9782d1366093dffcf29b9a81e47 100644 (file)
@@ -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,
         }
     }
 }
index ad3f330fdaf1bc196bd7965feb1aa6761f60f56e..30c1637a485928ba5d0651bc50a108b1d642973a 100644 (file)
@@ -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,
         }
     }
 }
index 0a5eb8d1355daf7a0106de825395ca4d5fda8e87..997ed4ef0102dbcfc0f965172c79654f45dcd43e 100644 (file)
@@ -32,8 +32,8 @@ pub struct SMBTransactionIoctl {
 impl SMBTransactionIoctl {
     pub fn new(func: u32) -> Self {
         return Self {
-            func: func,
-        }
+            func,
+        };
     }
 }
 
index f2f2e59b7483bd108e39351bb155efb1cf25c1fb..2344acedaf9a57ac2824fef9e762992967aa790b 100644 (file)
@@ -245,7 +245,7 @@ impl<'a> SNMPTransaction<'a> {
             community: None,
             usm: None,
             encrypted: false,
-            id: id,
+            id,
             tx_data: applayer::AppLayerTxData::new(),
         }
     }