1
Fork 0

Fix warnings during tests

The deny(warnings) attribute is now enabled for tests so we need to weed out
these warnings as well.
This commit is contained in:
Alex Crichton 2016-01-22 23:49:57 -08:00
parent 4b3c35509b
commit cb343c33ac
24 changed files with 137 additions and 141 deletions

View file

@ -8,14 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(missing_docs, bad_style)]
use io::{self, ErrorKind};
use libc;
use num::One;
use ops::Neg;
use alloc::oom;
#[cfg(target_os = "android")] pub use os::android as platform;
#[cfg(target_os = "bitrig")] pub use os::bitrig as platform;
@ -46,25 +44,10 @@ pub mod thread_local;
pub mod time;
pub mod stdio;
// A nicer handler for out-of-memory situations than the default one. This one
// prints a message to stderr before aborting. It is critical that this code
// does not allocate any memory since we are in an OOM situation. Any errors are
// ignored while printing since there's nothing we can do about them and we are
// about to exit anyways.
fn oom_handler() -> ! {
use intrinsics;
let msg = "fatal runtime error: out of memory\n";
unsafe {
libc::write(libc::STDERR_FILENO,
msg.as_ptr() as *const libc::c_void,
msg.len() as libc::size_t);
intrinsics::abort();
}
}
#[cfg(not(any(target_os = "nacl", test)))]
#[cfg(not(test))]
pub fn init() {
use libc::signal;
use alloc::oom;
// By default, some platforms will send a *signal* when an EPIPE error
// would otherwise be delivered. This runtime doesn't install a SIGPIPE
// handler, causing it to kill the program, which isn't exactly what we
@ -73,15 +56,33 @@ pub fn init() {
// Hence, we set SIGPIPE to ignore when the program starts up in order
// to prevent this problem.
unsafe {
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
reset_sigpipe();
}
oom::set_oom_handler(oom_handler);
}
#[cfg(all(target_os = "nacl", not(test)))]
pub fn init() {
oom::set_oom_handler(oom_handler);
// A nicer handler for out-of-memory situations than the default one. This
// one prints a message to stderr before aborting. It is critical that this
// code does not allocate any memory since we are in an OOM situation. Any
// errors are ignored while printing since there's nothing we can do about
// them and we are about to exit anyways.
fn oom_handler() -> ! {
use intrinsics;
let msg = "fatal runtime error: out of memory\n";
unsafe {
libc::write(libc::STDERR_FILENO,
msg.as_ptr() as *const libc::c_void,
msg.len() as libc::size_t);
intrinsics::abort();
}
}
#[cfg(not(target_os = "nacl"))]
unsafe fn reset_sigpipe() {
assert!(libc::signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
}
#[cfg(target_os = "nacl")]
unsafe fn reset_sigpipe() {}
}
pub fn decode_error_kind(errno: i32) -> ErrorKind {