From: Mira Limbeck <m.limbeck@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH v2 pmg-log-tracker 4/5] cleanup: remove unused strftime function
Date: Mon, 19 Feb 2024 18:55:46 +0100 [thread overview]
Message-ID: <20240219175548.311288-4-m.limbeck@proxmox.com> (raw)
In-Reply-To: <20240219175548.311288-1-m.limbeck@proxmox.com>
since we switched to proxmox_time::strftime_local for printing the start
and end times using local time, the strftime functions in src/time.rs is
unused and can be removed
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
cleanup commit that depends on patch 1/5, only apply if patch 1/5 is
applied.
src/time.rs | 31 -------------------------------
1 file changed, 31 deletions(-)
diff --git a/src/time.rs b/src/time.rs
index 9a2ce73..d26dccd 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -59,13 +59,6 @@ impl fmt::Debug for Tm {
/// These are now exposed via `libc`, but they're part of glibc.
mod imports {
extern "C" {
- pub fn strftime(
- s: *mut libc::c_char,
- max: libc::size_t,
- format: *const libc::c_char,
- tm: *const libc::tm,
- ) -> libc::size_t;
-
pub fn strptime(
s: *const libc::c_char,
format: *const libc::c_char,
@@ -123,30 +116,6 @@ impl Tm {
}
}
-/// Wrapper around `strftime(3)` to format time strings.
-pub fn strftime(format: &CStr, tm: &Tm) -> Result<String, Error> {
- let mut buf = MaybeUninit::<[u8; 64]>::uninit();
-
- let size = unsafe {
- imports::strftime(
- buf.as_mut_ptr() as *mut libc::c_char,
- 64,
- format.as_ptr(),
- &tm.0,
- )
- };
- if size == 0 {
- bail!("failed to format time");
- }
- let size = size as usize;
-
- let buf = unsafe { buf.assume_init() };
-
- std::str::from_utf8(&buf[..size])
- .map_err(|_| format_err!("formatted time was not valid utf-8"))
- .map(str::to_string)
-}
-
/// Wrapper around `strptime(3)` to parse time strings.
pub fn strptime(time: &str, format: &CStr) -> Result<Tm, Error> {
// zero memory because strptime does not necessarily initialize tm_isdst, tm_gmtoff and tm_zone
--
2.39.2
next prev parent reply other threads:[~2024-02-19 17:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 17:55 [pmg-devel] [PATCH v2 pmg-log-tracker 1/5] rfc3339: move timezone offset compatibility code to old time parser Mira Limbeck
2024-02-19 17:55 ` [pmg-devel] [PATCH v2 pmg-log-tracker 2/5] tests: improve test output consistency Mira Limbeck
2024-02-19 17:55 ` [pmg-devel] [PATCH v2 pmg-log-tracker 3/5] tests: update for log tracker time handling changes Mira Limbeck
2024-02-19 17:55 ` Mira Limbeck [this message]
2024-02-19 17:55 ` [pmg-devel] [PATCH v2 5/5] cleanup: fix clippy warnings Mira Limbeck
2024-02-19 17:55 ` [pmg-devel] [PATCH v2 pmg-api] MailTracker: remove timezone offset Mira Limbeck
2024-02-20 9:37 ` [pmg-devel] [PATCH v2 pmg-log-tracker 1/5] rfc3339: move timezone offset compatibility code to old time parser Mira Limbeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240219175548.311288-4-m.limbeck@proxmox.com \
--to=m.limbeck@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.