From 71dc2df4a8d84616ac4426c5fde6c9f69c5c30d8 Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Mon, 13 May 2019 14:57:49 -0700
Subject: [PATCH 1/2] Initialize `libc::timespec` members directly, avoiding
some unsafe blocks.
---
src/hostcalls.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/hostcalls.rs b/src/hostcalls.rs
index 6726d3e..92395e1 100644
@@ -100,7 +100,10 @@ pub fn clock_res_get(
};
// no `nix` wrapper for clock_getres, so we do it ourselves
- let mut timespec = unsafe { std::mem::uninitialized::<libc::timespec>() };
+ let mut timespec = libc::timespec {
+ tv_sec: 0,
+ tv_nsec: 0,
+ };
let res = unsafe { libc::clock_getres(clock_id, &mut timespec as *mut libc::timespec) };
if res != 0 {
return wasm32::errno_from_nix(nix::errno::Errno::last());
@@ -142,7 +145,10 @@ pub fn clock_time_get(
};
// no `nix` wrapper for clock_getres, so we do it ourselves
- let mut timespec = unsafe { std::mem::uninitialized::<libc::timespec>() };
+ let mut timespec = libc::timespec {
+ tv_sec: 0,
+ tv_nsec: 0,
+ };
let res = unsafe { libc::clock_gettime(clock_id, &mut timespec as *mut libc::timespec) };
if res != 0 {
return wasm32::errno_from_nix(nix::errno::Errno::last());
--
2.17.1