]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
dhcp: Rework constructs to use Self/Default
authorJeff Lucovsky <jeff@lucovsky.org>
Sat, 22 May 2021 13:12:43 +0000 (09:12 -0400)
committerVictor Julien <victor@inliniac.net>
Tue, 25 May 2021 08:45:47 +0000 (10:45 +0200)
rust/src/dhcp/dhcp.rs
rust/src/dhcp/logger.rs

index e4ff939580b40f29ef0f24b277026f87ebb6abcf..d90a281eb10f65cae10047a166a254a3e8df6ef8 100644 (file)
@@ -129,6 +129,7 @@ impl Drop for DHCPTransaction {
 export_tx_get_detect_state!(rs_dhcp_tx_get_detect_state, DHCPTransaction);
 export_tx_set_detect_state!(rs_dhcp_tx_set_detect_state, DHCPTransaction);
 
+#[derive(Default)]
 pub struct DHCPState {
     // Internal transaction ID.
     tx_id: u64,
@@ -140,12 +141,8 @@ pub struct DHCPState {
 }
 
 impl DHCPState {
-    pub fn new() -> DHCPState {
-        return DHCPState {
-            tx_id: 0,
-            transactions: Vec::new(),
-            events: 0,
-        };
+    pub fn new() -> Self {
+        Default::default()
     }
 
     pub fn parse(&mut self, input: &[u8]) -> bool {
index 97f1cda01c7916129da18120b2540268d410fa43..135d523278c16e3e1b0f3951ed85cbf9e303f1ef 100644 (file)
@@ -30,10 +30,10 @@ pub struct DHCPLogger {
 
 impl DHCPLogger {
     
-    pub fn new(conf: ConfNode) -> DHCPLogger {
-        return DHCPLogger{
+    pub fn new(conf: ConfNode) -> Self {
+        return Self {
             extended: conf.get_child_bool("extended"),
-        };
+        }
     }
 
     fn get_type(&self, tx: &DHCPTransaction) -> Option<u8> {