}
}
-// rust libc bindings do not include strftime
-#[link(name = "c")]
-extern "C" {
- #[link_name = "strftime"]
- fn libc_strftime(
- s: *mut libc::c_char,
- max: libc::size_t,
- format: *const libc::c_char,
- time: *const libc::tm,
- ) -> libc::size_t;
-}
-
/// Safe bindings to libc strftime
pub fn strftime(format: &str, t: &libc::tm) -> Result<String, Error> {
let format = CString::new(format).map_err(|err| format_err!("{}", err))?;
let mut buf = vec![0u8; 8192];
let res = unsafe {
- libc_strftime(
+ libc::strftime(
buf.as_mut_ptr() as *mut libc::c_char,
buf.len() as libc::size_t,
format.as_ptr(),
// -1,, it's unsigned
bail!("strftime failed");
}
+
+ // `res` is a `libc::size_t`, which on a different target architecture might not be directly
+ // assignable to a `usize`. Thus, we actually want a cast here.
+ #[allow(clippy::unnecessary_cast)]
let len = res as usize;
if len == 0 {