diff options
| author | bors <bors@rust-lang.org> | 2014-02-24 14:37:01 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-24 14:37:01 -0800 |
| commit | b48bc9ec935f6c87d16628b026cc4b9c99746b94 (patch) | |
| tree | acf90ab35a460176c2e308fbc0dc8b250bdb7b11 /src/libnative | |
| parent | 68a4f7d9babb0c638f3425ced08e13f9fbfdcf56 (diff) | |
| parent | 9e8d5aa29e40066b9c247ef252b58c2092ecdfae (diff) | |
| download | rust-b48bc9ec935f6c87d16628b026cc4b9c99746b94.tar.gz rust-b48bc9ec935f6c87d16628b026cc4b9c99746b94.zip | |
auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichton
Commits for details. Highlights: - `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]` - a lot of `transmute`s removed outright or replaced with `as` (etc.)
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/addrinfo.rs | 12 | ||||
| -rw-r--r-- | src/libnative/io/file.rs | 2 | ||||
| -rw-r--r-- | src/libnative/io/net.rs | 2 | ||||
| -rw-r--r-- | src/libnative/task.rs | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs index 5bdeaa17e74..ff617e5a230 100644 --- a/src/libnative/io/addrinfo.rs +++ b/src/libnative/io/addrinfo.rs @@ -14,7 +14,7 @@ use std::cast; use std::io::IoError; use std::libc; use std::libc::{c_char, c_int}; -use std::ptr::null; +use std::ptr::{null, mut_null}; use super::net::sockaddr_to_addr; @@ -42,13 +42,13 @@ impl GetAddrInfoRequest { }); let hint_ptr = hint.as_ref().map_or(null(), |x| x as *libc::addrinfo); - let res = null(); + let mut res = mut_null(); // Make the call let s = unsafe { let ch = if c_host.is_null() { null() } else { c_host.with_ref(|x| x) }; let cs = if c_serv.is_null() { null() } else { c_serv.with_ref(|x| x) }; - getaddrinfo(ch, cs, hint_ptr, &res) + getaddrinfo(ch, cs, hint_ptr, &mut res) }; // Error? @@ -74,7 +74,7 @@ impl GetAddrInfoRequest { flags: (*rp).ai_flags as uint }); - rp = (*rp).ai_next; + rp = (*rp).ai_next as *mut libc::addrinfo; } } @@ -86,8 +86,8 @@ impl GetAddrInfoRequest { extern "system" { fn getaddrinfo(node: *c_char, service: *c_char, - hints: *libc::addrinfo, res: **libc::addrinfo) -> c_int; - fn freeaddrinfo(res: *libc::addrinfo); + hints: *libc::addrinfo, res: *mut *mut libc::addrinfo) -> c_int; + fn freeaddrinfo(res: *mut libc::addrinfo); #[cfg(not(windows))] fn gai_strerror(errcode: c_int) -> *c_char; #[cfg(windows)] diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs index d1d2dba383d..27430ddee97 100644 --- a/src/libnative/io/file.rs +++ b/src/libnative/io/file.rs @@ -91,7 +91,7 @@ impl FileDesc { #[cfg(not(windows))] type rlen = libc::size_t; let ret = retry(|| unsafe { libc::read(self.fd(), - buf.as_ptr() as *mut libc::c_void, + buf.as_mut_ptr() as *mut libc::c_void, buf.len() as rlen) as libc::c_int }); if ret == 0 { diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index d58e4d54342..d71f7544225 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -309,7 +309,7 @@ impl rtio::RtioTcpStream for TcpStream { let ret = retry(|| { unsafe { libc::recv(self.fd(), - buf.as_ptr() as *mut libc::c_void, + buf.as_mut_ptr() as *mut libc::c_void, buf.len() as wrlen, 0) as libc::c_int } diff --git a/src/libnative/task.rs b/src/libnative/task.rs index ccfc040e7df..5682697ebfc 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -186,7 +186,7 @@ impl rt::Runtime for Ops { cur_task.put_runtime(self as ~rt::Runtime); unsafe { - let cur_task_dupe = *cast::transmute::<&~Task, &uint>(&cur_task); + let cur_task_dupe = &*cur_task as *Task; let task = BlockedTask::block(cur_task); if times == 1 { @@ -218,7 +218,7 @@ impl rt::Runtime for Ops { } } // re-acquire ownership of the task - cur_task = cast::transmute::<uint, ~Task>(cur_task_dupe); + cur_task = cast::transmute(cur_task_dupe); } // put the task back in TLS, and everything is as it once was. |
