From: Jeff Lucovsky Date: Sat, 22 May 2021 13:12:43 +0000 (-0400) Subject: dhcp: Rework constructs to use Self/Default X-Git-Tag: suricata-7.0.0-beta1~1608 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aafb0a60b77315c44d04a11c5bf3b109b20d6fbb;p=thirdparty%2Fsuricata.git dhcp: Rework constructs to use Self/Default --- diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index e4ff939580..d90a281eb1 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -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 { diff --git a/rust/src/dhcp/logger.rs b/rust/src/dhcp/logger.rs index 97f1cda01c..135d523278 100644 --- a/rust/src/dhcp/logger.rs +++ b/rust/src/dhcp/logger.rs @@ -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 {