Skip to content

Commit 800f751

Browse files
nrxrepilys
authored andcommitted
melib/utils: remove tz arg in gettimeofday
The timezone struct is deprecated in the gettimeofday function, void in macOS and nullable in Linux systems, from the manpages of gettimeofday(2) in macOS, the signature is: int gettimeofday(struct timeval *restrict tp, void *restrict tzp); In ubuntu manpage: int gettimeofday(struct timeval *restrict tv, struct timezone *_Nullable restrict tz); Passing a null parameter to gettimeofday matches the expectation in the modern implementations of libc and avoids EXC_BAD_ACCESS errors in inlined-optimized builds. Signed-off-by: nrxr <[email protected]>
1 parent a1e1515 commit 800f751

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

melib/src/utils/datetime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,8 @@ where
554554
pub fn now() -> UnixTimestamp {
555555
use std::mem::MaybeUninit;
556556
let mut tv = MaybeUninit::<libc::timeval>::uninit();
557-
let mut tz = MaybeUninit::<libc::timezone>::uninit();
558557
unsafe {
559-
let ret = gettimeofday(tv.as_mut_ptr(), tz.as_mut_ptr());
558+
let ret = gettimeofday(tv.as_mut_ptr(), std::ptr::null_mut());
560559
if ret == -1 {
561560
unreachable!("gettimeofday returned -1");
562561
}

0 commit comments

Comments
 (0)