From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0288782864 for ; Tue, 30 Nov 2021 13:12:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 893BD26A1B for ; Tue, 30 Nov 2021 13:12:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D474326910 for ; Tue, 30 Nov 2021 13:12:11 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AD32345D9B for ; Tue, 30 Nov 2021 13:12:11 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 30 Nov 2021 13:12:05 +0100 Message-Id: <20211130121209.216846-12-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211130121209.216846-1-d.csapak@proxmox.com> References: <20211130121209.216846-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.184 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs] Subject: [pbs-devel] [PATCH proxmox 11/14] proxmox-time: lib.rs: rustfmt X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 12:12:46 -0000 Signed-off-by: Dominik Csapak --- proxmox-time/src/lib.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/proxmox-time/src/lib.rs b/proxmox-time/src/lib.rs index fa59eee..53ba11e 100644 --- a/proxmox-time/src/lib.rs +++ b/proxmox-time/src/lib.rs @@ -145,8 +145,7 @@ extern "C" { /// Safe bindings to libc strftime pub fn strftime(format: &str, t: &libc::tm) -> Result { - let format = CString::new(format) - .map_err(|err| format_err!("{}", err))?; + let format = CString::new(format).map_err(|err| format_err!("{}", err))?; let mut buf = vec![0u8; 8192]; let res = unsafe { @@ -157,7 +156,8 @@ pub fn strftime(format: &str, t: &libc::tm) -> Result { t as *const libc::tm, ) }; - if res == !0 { // -1,, it's unsigned + if res == !0 { + // -1,, it's unsigned bail!("strftime failed"); } let len = res as usize; @@ -166,8 +166,7 @@ pub fn strftime(format: &str, t: &libc::tm) -> Result { bail!("strftime: result len is 0 (string too large)"); }; - let c_str = CStr::from_bytes_with_nul(&buf[..len + 1]) - .map_err(|err| format_err!("{}", err))?; + let c_str = CStr::from_bytes_with_nul(&buf[..len + 1]).map_err(|err| format_err!("{}", err))?; let str_slice: &str = c_str.to_str().unwrap(); Ok(str_slice.to_owned()) } @@ -229,10 +228,13 @@ pub fn epoch_to_rfc3339(epoch: i64) -> Result { /// Parse RFC3339 into Unix epoch pub fn parse_rfc3339(input_str: &str) -> Result { - parse_rfc3339_do(input_str) - .map_err(|err| { - format_err!("failed to parse rfc3339 timestamp ({:?}) - {}", input_str, err) - }) + parse_rfc3339_do(input_str).map_err(|err| { + format_err!( + "failed to parse rfc3339 timestamp ({:?}) - {}", + input_str, + err + ) + }) } fn parse_rfc3339_do(input_str: &str) -> Result { -- 2.30.2