From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 89B021FF13E for ; Fri, 03 Apr 2026 18:56:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 52BE987F6; Fri, 3 Apr 2026 18:57:10 +0200 (CEST) From: Christoph Heiss To: pdm-devel@lists.proxmox.com Subject: [PATCH installer v3 27/38] common: options: move regex construction out of loop Date: Fri, 3 Apr 2026 18:53:59 +0200 Message-ID: <20260403165437.2166551-28-c.heiss@proxmox.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403165437.2166551-1-c.heiss@proxmox.com> References: <20260403165437.2166551-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775235365374 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.067 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 3PJWJJ3W2ZPIPD7DWWRNRFJJCY763FTT X-Message-ID-Hash: 3PJWJJ3W2ZPIPD7DWWRNRFJJCY763FTT X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: .. and make clippy happy. No functional changes. Signed-off-by: Christoph Heiss --- Changes v2 -> v3: * new patch proxmox-installer-common/src/options.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs index fbc0207..dcf4fe7 100644 --- a/proxmox-installer-common/src/options.rs +++ b/proxmox-installer-common/src/options.rs @@ -502,6 +502,15 @@ impl NetworkInterfacePinningOptions { /// - only contains ASCII alphanumeric characters and underscore, as /// enforced by our `pve-iface` json schema. pub fn verify(&self) -> Result<()> { + // Mimicking the `pve-iface` schema verification + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + RegexBuilder::new(r"^[a-z][a-z0-9_]{1,20}([:\.]\d+)?$") + .case_insensitive(true) + .build() + .unwrap() + }); + let mut reverse_mapping = HashMap::::new(); for (mac, name) in self.mapping.iter() { if name.len() < MIN_IFNAME_LEN { @@ -517,15 +526,6 @@ impl NetworkInterfacePinningOptions { ); } - // Mimicking the `pve-iface` schema verification - static RE: OnceLock = OnceLock::new(); - let re = RE.get_or_init(|| { - RegexBuilder::new(r"^[a-z][a-z0-9_]{1,20}([:\.]\d+)?$") - .case_insensitive(true) - .build() - .unwrap() - }); - if !re.is_match(name) { bail!( "interface name '{name}' for '{mac}' is invalid: name must start with a letter and contain only ascii characters, digits and underscores" -- 2.53.0