servo: Merge #5288 - Fix various build warnings (from Ms2ger:warnings); r=SimonSapin

Source-Repo: https://github.com/servo/servo
Source-Revision: 0663cd632517c9a9c86db47456c5a4da637045ed
This commit is contained in:
Ms2ger 2015-03-20 11:00:54 -06:00
Родитель c7a10f319e
Коммит 01a90574bd
16 изменённых файлов: 32 добавлений и 35 удалений

Просмотреть файл

@ -58,7 +58,7 @@ use std::fmt;
use std::iter::Zip;
use std::num::FromPrimitive;
use std::raw;
use std::sync::atomic::{AtomicUint, Ordering};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::slice::IterMut;
use style::computed_values::{clear, empty_cells, float, position, text_align};
use style::properties::ComputedValues;
@ -740,9 +740,9 @@ pub struct BaseFlow {
/// NB: Must be the first element.
///
/// The necessity of this will disappear once we have dynamically-sized types.
strong_ref_count: AtomicUint,
strong_ref_count: AtomicUsize,
weak_ref_count: AtomicUint,
weak_ref_count: AtomicUsize,
pub restyle_damage: RestyleDamage,
@ -951,8 +951,8 @@ impl BaseFlow {
damage.remove(RECONSTRUCT_FLOW);
BaseFlow {
strong_ref_count: AtomicUint::new(1),
weak_ref_count: AtomicUint::new(1),
strong_ref_count: AtomicUsize::new(1),
weak_ref_count: AtomicUsize::new(1),
restyle_damage: damage,
children: FlowList::new(),
intrinsic_inline_sizes: IntrinsicISizes::new(),
@ -982,11 +982,11 @@ impl BaseFlow {
self.children.iter_mut()
}
pub unsafe fn strong_ref_count<'a>(&'a self) -> &'a AtomicUint {
pub unsafe fn strong_ref_count<'a>(&'a self) -> &'a AtomicUsize {
&self.strong_ref_count
}
pub unsafe fn weak_ref_count<'a>(&'a self) -> &'a AtomicUint {
pub unsafe fn weak_ref_count<'a>(&'a self) -> &'a AtomicUsize {
&self.weak_ref_count
}

Просмотреть файл

@ -102,9 +102,7 @@ impl Drop for FlowRef {
let object_align = vtable[2];
let fake_data = heap::allocate(object_size, object_align);
ptr::copy_memory(fake_data,
flow_ref.object.data as *const u8,
object_size);
ptr::copy(fake_data, flow_ref.object.data as *const u8, object_size);
let fake_box = raw::TraitObject { vtable: flow_ref.object.vtable, data: fake_data as *mut () };
let fake_flow = mem::transmute::<raw::TraitObject, Box<Flow>>(fake_box);

Просмотреть файл

@ -25,7 +25,7 @@ use util::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan, profi
use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
use std::mem;
use std::ptr;
use std::sync::atomic::{AtomicInt, Ordering};
use std::sync::atomic::{AtomicIsize, Ordering};
#[allow(dead_code)]
fn static_assertion(node: UnsafeLayoutNode) {
@ -68,13 +68,13 @@ pub fn mut_borrowed_flow_to_unsafe_flow(flow: &mut Flow) -> UnsafeFlow {
/// Information that we need stored in each DOM node.
pub struct DomParallelInfo {
/// The number of children that still need work done.
pub children_count: AtomicInt,
pub children_count: AtomicIsize,
}
impl DomParallelInfo {
pub fn new() -> DomParallelInfo {
DomParallelInfo {
children_count: AtomicInt::new(0),
children_count: AtomicIsize::new(0),
}
}
}
@ -187,7 +187,7 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
/// Information that we need stored in each flow.
pub struct FlowParallelInfo {
/// The number of children that still need work done.
pub children_count: AtomicInt,
pub children_count: AtomicIsize,
/// The address of the parent flow.
pub parent: UnsafeFlow,
}
@ -195,7 +195,7 @@ pub struct FlowParallelInfo {
impl FlowParallelInfo {
pub fn new() -> FlowParallelInfo {
FlowParallelInfo {
children_count: AtomicInt::new(0),
children_count: AtomicIsize::new(0),
parent: null_unsafe_flow(),
}
}

Просмотреть файл

@ -99,7 +99,7 @@ impl CallbackInterface {
-> Result<JSVal, ()> {
let mut callable = UndefinedValue();
unsafe {
let name = CString::from_slice(name.as_bytes());
let name = CString::new(name).unwrap();
if JS_GetProperty(cx, self.callback(), name.as_ptr(), &mut callable) == 0 {
return Err(());
}

Просмотреть файл

@ -122,7 +122,7 @@ pub fn report_pending_exception(cx: *mut JSContext, obj: *mut JSObject) {
pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) -> JSBool {
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
let message = format!("argument could not be converted to any of: {}", names);
let string = CString::from_slice(message.as_bytes());
let string = CString::new(message).unwrap();
unsafe { ReportError(cx, string.as_ptr()) };
return 0;
}
@ -153,7 +153,7 @@ unsafe extern fn get_error_message(_user_ref: *mut libc::c_void,
/// Throw a `TypeError` with the given message.
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
let error = CString::from_slice(error.as_bytes());
let error = CString::new(error).unwrap();
unsafe {
JS_ReportErrorNumber(cx,
Some(get_error_message as

Просмотреть файл

@ -92,7 +92,7 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: JSVal) {
}
unsafe {
let name = CString::from_slice(description.as_bytes());
let name = CString::new(description).unwrap();
(*tracer).debugPrinter = None;
(*tracer).debugPrintIndex = -1;
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
@ -110,7 +110,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
/// Trace a `JSObject`.
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject) {
unsafe {
let name = CString::from_slice(description.as_bytes());
let name = CString::new(description).unwrap();
(*tracer).debugPrinter = None;
(*tracer).debugPrintIndex = -1;
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;

Просмотреть файл

@ -197,7 +197,7 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject,
match constructor {
Some((native, name, nargs)) => {
let s = CString::from_slice(name.as_bytes());
let s = CString::new(name).unwrap();
create_interface_object(cx, global, receiver,
native, nargs, proto,
members, s.as_ptr())
@ -516,7 +516,7 @@ pub fn get_dictionary_property(cx: *mut JSContext,
}
}
let property = CString::from_slice(property.as_bytes());
let property = CString::new(property).unwrap();
if object.is_null() {
return Ok(None);
}

Просмотреть файл

@ -126,8 +126,8 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
match self.bytes {
None => Blob::new(global.r(), None, relativeContentType.as_slice()),
Some(ref vec) => {
let start = relativeStart.to_uint().unwrap();
let end = (relativeStart + span).to_uint().unwrap();
let start = relativeStart.to_usize().unwrap();
let end = (relativeStart + span).to_usize().unwrap();
let mut bytes: Vec<u8> = Vec::new();
bytes.push_all(&vec[start..end]);
Blob::new(global.r(), Some(bytes), relativeContentType.as_slice())

Просмотреть файл

@ -198,8 +198,8 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
scope: *mut JSObject,
ty: &str,
source: DOMString) {
let url = CString::from_slice(url.serialize().as_bytes());
let name = CString::from_slice(ty.as_bytes());
let url = CString::new(url.serialize()).unwrap();
let name = CString::new(ty).unwrap();
let lineno = 0; //XXXjdm need to get a real number here
let nargs = 1; //XXXjdm not true for onerror

Просмотреть файл

@ -32,7 +32,6 @@ use util::str::DOMString;
use string_cache::Atom;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::default::Default;

Просмотреть файл

@ -33,7 +33,7 @@ impl ImageData {
if let Some(vec) = data {
let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, cx);
ptr::copy_nonoverlapping_memory(js_object_data, vec.as_ptr(), vec.len())
ptr::copy_nonoverlapping(js_object_data, vec.as_ptr(), vec.len())
}
ImageData {

Просмотреть файл

@ -470,7 +470,7 @@ impl<'a, T: Reflectable> ScriptHelpers for JSRef<'a, T> {
let global = global_object_for_js_object(this).root().r().reflector().get_jsobject();
let code: Vec<u16> = code.as_slice().utf16_units().collect();
let mut rval = UndefinedValue();
let filename = CString::from_slice(filename.as_bytes());
let filename = CString::new(filename).unwrap();
with_compartment(cx, global, || {
unsafe {

Просмотреть файл

@ -30,8 +30,8 @@ use net::resource_task::{ProgressMsg, LoadResponse};
use util::task_state;
use util::task_state::IN_HTML_PARSER;
use std::ascii::AsciiExt;
use std::borrow::Cow;
use std::old_io::{Writer, IoResult};
use std::string::CowString;
use url::Url;
use html5ever::Attribute;
use html5ever::serialize::{Serializable, Serializer, AttrRef};
@ -120,7 +120,7 @@ impl<'a> TreeSink for servohtmlparser::Sink {
Ok(())
}
fn parse_error(&mut self, msg: CowString<'static>) {
fn parse_error(&mut self, msg: Cow<'static, str>) {
debug!("Parse error: {}", msg);
}

Просмотреть файл

@ -81,7 +81,7 @@ fn redirect_output(file_no: c_int) {
let mut pipes: [c_int; 2] = [ 0, 0 ];
pipe(pipes.as_mut_ptr());
dup2(pipes[1], file_no);
let mode = CString::from_slice("r".as_bytes());
let mode = CString::new("r").unwrap();
let input_file = FilePtr(fdopen(pipes[0], mode.as_ptr()));
spawn_named("android-logger".to_owned(), move || {
loop {

Просмотреть файл

@ -67,7 +67,7 @@ pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, na
if o.as_slice().starts_with(opt.as_slice()) {
let mut string = mem::uninitialized();
let arg = o[opt.len() + 1..].as_bytes();
let c_str = ffi::CString::from_slice(arg);
let c_str = ffi::CString::new(arg).unwrap();
cef_string_utf16_set(c_str.as_bytes().as_ptr() as *const _,
arg.len() as size_t,
&mut string,

Просмотреть файл

@ -47,7 +47,7 @@ fn load_gl() {
gl::load_with(|s| {
unsafe {
let c_str = CString::from_slice(s.as_bytes());
let c_str = CString::new(s).unwrap();
dlsym(RTLD_DEFAULT, c_str.as_ptr()) as *const c_void
}
});
@ -61,7 +61,7 @@ fn load_gl() {
gl::load_with(|s| {
unsafe {
let c_str = CString::from_slice(s.as_bytes());
let c_str = CString::new(s).unwrap();
glXGetProcAddress(c_str.as_ptr()) as *const c_void
}
});