Fix some warnings in util.

This commit is contained in:
Simon Sapin 2015-03-18 21:35:06 +01:00
parent d553bfefbb
commit 1e858ecbc6
4 changed files with 13 additions and 8 deletions

View file

@ -6,15 +6,20 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(env)]
#![feature(exit_status)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(io)]
#![feature(optin_builtin_traits)]
#![feature(old_io)]
#![feature(old_path)]
#![feature(page_size)]
#![feature(path)]
#![feature(path_ext)]
#![feature(plugin)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(str_words)]
#![feature(unicode)]
#![feature(unsafe_destructor)]

View file

@ -451,12 +451,12 @@ fn get_jemalloc_stat(value_name: &str) -> Option<u64> {
// request. Without that jemalloc gives cached statistics(!) which can be
// highly inaccurate.
let epoch_name = "epoch";
let epoch_c_name = CString::from_slice(epoch_name.as_bytes());
let epoch_c_name = CString::new(epoch_name).unwrap();
let mut epoch: u64 = 0;
let epoch_ptr = &mut epoch as *mut _ as *mut c_void;
let mut epoch_len = size_of::<u64>() as size_t;
let value_c_name = CString::from_slice(value_name.as_bytes());
let value_c_name = CString::new(value_name).unwrap();
let mut value: size_t = 0;
let value_ptr = &mut value as *mut _ as *mut c_void;
let mut value_len = size_of::<size_t>() as size_t;

View file

@ -9,10 +9,10 @@ use cssparser::{self, RGBA, Color};
use libc::c_char;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::ffi::c_str_to_bytes;
use std::ffi::CStr;
use std::iter::Filter;
use std::num::{Int, ToPrimitive};
use std::str::{from_utf8, CharEq, FromStr, Split};
use std::str::{from_utf8, FromStr, Split};
pub type DOMString = String;
pub type StaticCharVec = &'static [char];
@ -333,5 +333,5 @@ impl Str for LowercaseString {
/// Creates a String from the given null-terminated buffer.
/// Panics if the buffer does not contain UTF-8.
pub unsafe fn c_str_to_string(s: *const c_char) -> String {
from_utf8(c_str_to_bytes(&s)).unwrap().to_owned()
from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned()
}

View file

@ -14,7 +14,7 @@ pub fn spawn_named<F>(name: String, f: F)
let builder = thread::Builder::new().name(name);
builder.spawn(move || {
f()
});
}).unwrap();
}
/// Arrange to send a particular message to a channel if the task fails.
@ -40,7 +40,7 @@ pub fn spawn_named_with_send_on_failure<F, T>(name: &'static str,
dest.send(msg).unwrap();
}
}
});
}).unwrap();
}
#[test]