Fix warnings in util.

This commit is contained in:
Ms2ger 2015-02-13 11:42:13 +01:00
parent b25564440d
commit 830e6741c7
9 changed files with 35 additions and 32 deletions

View file

@ -10,25 +10,25 @@ use std::slice;
fn hexdump_slice(buf: &[u8]) {
let mut stderr = io::stderr();
stderr.write(b" ").unwrap();
stderr.write_all(b" ").unwrap();
for (i, &v) in buf.iter().enumerate() {
let output = format!("{:02X} ", v as uint);
stderr.write(output.as_bytes()).unwrap();
stderr.write_all(output.as_bytes()).unwrap();
match i % 16 {
15 => { stderr.write(b"\n ").unwrap(); },
7 => { stderr.write(b" ").unwrap(); },
15 => { stderr.write_all(b"\n ").unwrap(); },
7 => { stderr.write_all(b" ").unwrap(); },
_ => ()
}
stderr.flush().unwrap();
}
stderr.write(b"\n").unwrap();
stderr.write_all(b"\n").unwrap();
}
pub fn hexdump<T>(obj: &T) {
unsafe {
let buf: *const u8 = mem::transmute(obj);
debug!("dumping at {:p}", buf);
let from_buf = slice::from_raw_buf(&buf, size_of::<T>());
let from_buf = slice::from_raw_parts(buf, size_of::<T>());
hexdump_slice(from_buf);
}
}

View file

@ -42,8 +42,6 @@
//! let mut stealer2 = stealer.clone();
//! stealer2.steal();
#![experimental]
// NB: the "buffer pool" strategy is not done for speed, but rather for
// correctness. For more info, see the comment on `swap_buffer`

View file

@ -2,16 +2,24 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(unsafe_destructor)]
#![feature(plugin)]
#![feature(int_uint)]
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(env)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(io)]
#![feature(libc)]
#![feature(optin_builtin_traits)]
#![feature(core, rustc_private, hash, alloc)]
#![feature(collections, libc, std_misc)]
#![feature(path)]
#![feature(plugin)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(unicode)]
#![feature(unsafe_destructor)]
#![allow(missing_copy_implementations)]
#![allow(unstable)]
#[macro_use] extern crate log;

View file

@ -13,7 +13,7 @@ use std::old_io::File;
use std::mem;
use std::mem::size_of;
#[cfg(target_os="linux")]
use std::os::page_size;
use std::env::page_size;
use std::ptr::null_mut;
use std::sync::mpsc::{Sender, channel, Receiver};
use std::time::duration::Duration;

View file

@ -13,9 +13,9 @@ use layers::geometry::DevicePixel;
use getopts;
use std::collections::HashSet;
use std::cmp;
use std::env;
use std::old_io as io;
use std::mem;
use std::os;
use std::ptr;
use std::rt;
@ -137,7 +137,7 @@ pub fn print_debug_usage(app: &str) {
fn args_fail(msg: &str) {
io::stderr().write_line(msg).unwrap();
os::set_exit_status(1);
env::set_exit_status(1);
}
// Always use CPU painting on android.

View file

@ -5,14 +5,6 @@
use std::old_io::{File, IoResult};
use std::old_path::Path;
#[cfg(not(target_os = "android"))]
use opts;
#[cfg(not(target_os = "android"))]
use std::old_io::fs::PathExtensions;
#[cfg(not(target_os = "android"))]
use std::os;
#[cfg(target_os = "android")]
pub fn resources_dir_path() -> Path {
Path::new("/sdcard/servo/")
@ -20,13 +12,18 @@ pub fn resources_dir_path() -> Path {
#[cfg(not(target_os = "android"))]
pub fn resources_dir_path() -> Path {
use opts;
use std::env;
use std::old_io::fs::PathExtensions;
match opts::get().resources_path {
Some(ref path) => Path::new(path),
None => {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
let mut path = os::self_exe_path().expect("can't get exe path");
let mut path = env::current_exe().ok().expect("can't get exe path");
path.pop();
path.pop();
path.pop();
path.pop();

View file

@ -44,7 +44,7 @@ impl<T> VecLike<T> for Vec<T> {
#[inline]
fn vec_slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
self.slice_mut(start, end)
&mut self[start..end]
}
}
@ -410,7 +410,7 @@ macro_rules! def_small_vector(
}
impl<T> FromIterator<T> for $name<T> {
fn from_iter<I: Iterator<Item=T>>(mut iter: I) -> $name<T> {
fn from_iter<I: Iterator<Item=T>>(iter: I) -> $name<T> {
let mut v = $name::new();
let (lower_size_bound, _) = iter.size_hint();
@ -428,7 +428,7 @@ macro_rules! def_small_vector(
}
impl<T> $name<T> {
pub fn extend<I: Iterator<Item=T>>(&mut self, mut iter: I) {
pub fn extend<I: Iterator<Item=T>>(&mut self, iter: I) {
let (lower_size_bound, _) = iter.size_hint();
let target_len = self.len() + lower_size_bound;

View file

@ -273,7 +273,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> {
// Step 12.
let mut length = input.len() / 3;
let (mut red, mut green, mut blue) = (input.slice_to(length),
let (mut red, mut green, mut blue) = (&input[..length],
&input[length..length * 2],
&input[length * 2..]);

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::rc::Rc;
use std::cell::RefCell;
static mut next_tid: AtomicUint = ATOMIC_UINT_INIT;
static mut next_tid: AtomicUsize = ATOMIC_USIZE_INIT;
thread_local!(static TASK_LOCAL_TID: Rc<RefCell<Option<uint>>> = Rc::new(RefCell::new(None)));