From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BD59E1FF16F for ; Tue, 14 Oct 2025 15:22:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 476DA3F2A; Tue, 14 Oct 2025 15:22:48 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 14 Oct 2025 15:21:50 +0200 Message-ID: <20251014132207.1171073-6-c.heiss@proxmox.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014132207.1171073-1-c.heiss@proxmox.com> References: <20251014132207.1171073-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760448095865 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.037 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [setup.rs, options.rs] Subject: [pve-devel] [PATCH installer 05/14] common: setup: simplify network address list serialization X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Option> is redundant in combination with #[serde(default)], as the latter already defaults to an empty Vec<..> if the key does not exist. No functional changes. Signed-off-by: Christoph Heiss --- proxmox-installer-common/src/options.rs | 26 ++++++++++--------------- proxmox-installer-common/src/setup.rs | 6 +++--- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs index 50fd74e..59e8560 100644 --- a/proxmox-installer-common/src/options.rs +++ b/proxmox-installer-common/src/options.rs @@ -518,24 +518,20 @@ impl NetworkOptions { if let Some(gw) = &routes.gateway4 { if let Some(iface) = network.interfaces.get(&gw.dev) { this.ifname.clone_from(&iface.name); - if let Some(addresses) = &iface.addresses { - if let Some(addr) = addresses.iter().find(|addr| addr.is_ipv4()) { - this.gateway = gw.gateway; - this.address = addr.clone(); - filled = true; - } + if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv4()) { + this.gateway = gw.gateway; + this.address = addr.clone(); + filled = true; } } } if !filled { if let Some(gw) = &routes.gateway6 { if let Some(iface) = network.interfaces.get(&gw.dev) { - if let Some(addresses) = &iface.addresses { - if let Some(addr) = addresses.iter().find(|addr| addr.is_ipv6()) { - this.ifname.clone_from(&iface.name); - this.gateway = gw.gateway; - this.address = addr.clone(); - } + if let Some(addr) = iface.addresses.iter().find(|addr| addr.is_ipv6()) { + this.ifname.clone_from(&iface.name); + this.gateway = gw.gateway; + this.address = addr.clone(); } } } @@ -679,9 +675,7 @@ mod tests { state: InterfaceState::Up, driver: "dummy".to_owned(), mac: "01:23:45:67:89:ab".to_owned(), - addresses: Some(vec![ - CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(), - ]), + addresses: vec![CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap()], }, ); @@ -807,7 +801,7 @@ mod tests { state: InterfaceState::Up, driver: "dummy".to_owned(), mac: "01:23:45:67:89:ab".to_owned(), - addresses: None, + addresses: vec![], }, ); diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs index 4fda39d..4873fff 100644 --- a/proxmox-installer-common/src/setup.rs +++ b/proxmox-installer-common/src/setup.rs @@ -321,7 +321,7 @@ where .collect()) } -fn deserialize_cidr_list<'de, D>(deserializer: D) -> Result>, D::Error> +fn deserialize_cidr_list<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { @@ -347,7 +347,7 @@ where ); } - Ok(Some(result)) + Ok(result) } fn serialize_as_display(value: &T, serializer: S) -> Result @@ -478,7 +478,7 @@ pub struct Interface { #[serde(default)] #[serde(deserialize_with = "deserialize_cidr_list")] - pub addresses: Option>, + pub addresses: Vec, } impl Interface { -- 2.51.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel