Skip to content

Commit

Permalink
Merge pull request #811 from ZhangHanDong/patch-1
Browse files Browse the repository at this point in the history
To add a `SAFETY` comment to the now function
  • Loading branch information
squell authored Jan 8, 2024
2 parents e5cf58e + ec6d41a commit 2fa9234
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/system/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ impl SystemTime {
crate::cutils::cerr(unsafe {
libc::clock_gettime(libc::CLOCK_BOOTTIME, spec.as_mut_ptr())
})?;
// SAFETY: The `libc::clock_gettime` will correctly initialize `spec`,
// otherwise it will return early with the `?` operator.
let spec = unsafe { spec.assume_init() };
Ok(spec.into())
}
Expand Down

0 comments on commit 2fa9234

Please sign in to comment.